Jump to content

Character encoding coversions through xslt


Recommended Posts

You can transform XML to XML with the help of XSLT and you can specify the output enoding:

<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  version="1.0">  <xsl:output method="xml" encoding="UTF-8"/>  <xsl:template match="/">	 <xsl:copy-of select="."/>  </xsl:template></xsl:stylesheet>

Depending on your XML input that approach can have shortcomings however as it does not copy the input unchanged to the output but rather parses the XML input into the tree model of XSLT/XPath and copies that tree to the output. As the XSLT/XPath data model does not model all kind of nodes an XML document can have, such as DOCTYPE nodes or CDATA section nodes, the output can look different from the input (e.g. the DOCTYPE would be dropped and CDATA sections would be replaced with text nodes with escaped characters).

Link to post
Share on other sites
  • 4 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...