Wrong encoding for element and attribute names

Michael Ludwig <[email protected]>
Newsgroups gmane.text.xml.xalan.java.user
Message-ID <20090330224720.GD2224@wladimir>
Non-ASCII element and attribute names appear to be output in the wrong
encoding when US-ASCII is specified in xsl:output/@encoding. A runtime
error might be due in this case.

This happens in Xalan-J 2.7.1.

No such problems exist for output encoding UTF-8 or ISO-8859-1.

C:\dev\XML\entities :: more /t2 Kaese.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output encoding="US-ASCII"/>

  <xsl:template match="@*|node()">
    <xsl:copy><xsl:apply-templates select="@*|node()"/></xsl:copy>
  </xsl:template>

</xsl:stylesheet>

C:\dev\XML\entities :: type Kaese.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<KÀse sÌß="nö">
blödes Beispiel
</KÀse>

C:\dev\XML\entities :: xalan Kaese.xml Kaese.xsl
<?xml version="1.0" encoding="US-ASCII"?><KÀse sÌß="n&#246;">
bl&#246;des Beispiel
</KÀse>

Saxon 6.5 and 9.1 flag runtime errors. So does Gestalt 3.7. So do MSXML
3.0, 4.0 and 6.0. LibXSLT 1.1.24 adheres to the desired encoding but
unduely uses numerical character references in element and attribute
names.

Michael Ludwig
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.