Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
2.7.2
-
Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
-
None
-
Windows 10, Linux
Java 9, Java 10
Description
We found a problem using Xalan / Serializer with Java 9 and 10 when transforming an XML document with a styleheet containing an output-encoding.
<?xml version="1.0" encoding="UTF-8"?> <Message> <Value>This is a test input.</Value> </Message>
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="text" indent="no" encoding="ISO-8859-1"/> <xsl:template match="/"> <xsl:text>Tramsformed text: </xsl:text> <xsl:value-of select="//Message/Value"/> </xsl:template> </xsl:stylesheet>
@Test public void test2() throws Exception { final InputStream is1 = Java9Test.class.getClassLoader().getResourceAsStream("test/Input.xml"); assertNotNull(is1); final Document input = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(is1); assertNotNull(input); final InputStream is2 = Java9Test.class.getClassLoader().getResourceAsStream("test/Transform.xsl"); assertNotNull(is2); final OutputStream os = new FileOutputStream("Output-" + System.getProperty("java.version") + ".txt", false); StreamSource xsl = new StreamSource(is2); Transformer t = TransformerFactory.newInstance().newTransformer(xsl); DOMSource src = new DOMSource(input); t.transform(src, new StreamResult(os)); }
Using Java 7 or Java 8 the result is correct: Tramsformed text: This is a test input.. Using Java 9 or Java 10 the result is not correct:
Tramsformed text: This is a test input.
indicating an invalid or unknown encoding.
In Java 7 or Java 8 org.apache.xml.serializer.Encodings.getEncodingInfo("ISO-8859-1") returns "ISO8859_1" which is a valid Java encoding name. In Java 9 oder Java 10 the method returns "8859-1" which is not a valid name.
The problem is caused by a change to the method keys() in the java.util.Properties class. This method returns die entries of the Encodings.properties in a different order since Java 9.