Jens Annighöfer created XALANJ-2614:
---------------------------------------

             Summary: Serializer 2.7.2 / Xalan 2.7.2 - Bug using Mime-Encoding 
'ISO-8859-1'
                 Key: XALANJ-2614
                 URL: https://issues.apache.org/jira/browse/XALANJ-2614
             Project: XalanJ2
          Issue Type: Bug
      Security Level: No security risk; visible to anyone (Ordinary problems in 
Xalan projects.  Anybody can view the issue.)
          Components: Serialization
    Affects Versions: 2.7.2
         Environment: Windows 10, Linux
Java 9, Java 10
            Reporter: Jens Annighöfer
            Assignee: Steven J. Hathaway
             Fix For: The Latest Development Code
         Attachments: test.zip

We found a problem using Xalan / Serializer with Java 9 and 10 when 
transforming an XML document with a styleheet containing an output-encoding. 

{code:xml|title=Simple input|borderStyle=solid}
<?xml version="1.0" encoding="UTF-8"?>
<Message>
  <Value>This is a test input.</Value>
</Message>
{code}

{code:xml|title=Simple stylesheet containing an 
output-encoding|borderStyle=solid}
<?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>
{code}

{code:java|title=Simple transformation code|borderStyle=solid}
    @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));
    }
{code}

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: 
\{{&#84;&#114;&#97;&#109;&#115;&#102;&#111;&#114;&#109;&#101;&#100;&#32;&#116;&#101;&#120;&#116;&#58;&#32;&#84;&#104;&#105;&#115;&#32;&#105;&#115;&#32;&#97;&#32;&#116;&#101;&#115;&#116;&#32;&#105;&#110;&#112;&#117;&#116;&#46;}}
 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.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org
For additional commands, e-mail: dev-h...@xalan.apache.org

Reply via email to