Jump to content

Character encoding coversions through xslt


vipasane

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 comment
Share on other sites

  • 4 weeks later...

So yep silly me, thanks for your help and for clearing this up for me.It turned out that I already implemented this.This is what you get when you don't fully understand technology or method you're utilizing

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...