Reputation: 1379
I have the following XML:
<item>
<description><![CDATA[Euro sign: €]]></description>
</item>
When I run it against this XSL:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
<xsl:output method="xml" name="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="item">
<xsl:result-document href="test.xml" format="xml">
<feed>
<xsl:value-of select="description" />
</feed>
</xsl:result-document>
</xsl:template>
</xsl:stylesheet>
the "test.xml" is equal to:
<feed>
<description>Euro sign: €</description>
</feed>
which is perfect. However, when the <xsl:result-document>
is removed, like so:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions" xmlns:xdt="http://www.w3.org/2005/xpath-datatypes">
<xsl:output method="xml" name="xml" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes" />
<xsl:template match="item">
<feed>
<xsl:value-of select="description" />
</feed>
</xsl:template>
</xsl:stylesheet>
the output equals:
<feed>
<description>Euro sign: €</description>
</feed>
which is incorrect as the euro sign has been escaped it seems.
Is there any way to keep the euro sign as is when using plain output?
Thanks in advance.
Upvotes: 0
Views: 1140
Reputation: 1379
We were displaying the data in the Console window of Eclipse, which wasn't setup for UTF-8. Once we altered the settings of the console to output in UTF-8, the output was fixed.
Upvotes: 2
Reputation: 13169
Try removing the name attribute from your xsl:output element:
<xsl:output method="xml" version="1.0" encoding="UTF-8"
indent="yes" omit-xml-declaration="yes" />
By making it an unnamed xsl:output element it should apply to the current run.
Upvotes: 1