[
https://issues.apache.org/jira/browse/XALANJ-2361?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12467018
]
Guillaume Nodet commented on XALANJ-2361:
-----------------------------------------
Sorry, forgot to mention that this fails when using the
org.apache.xalan.xsltc.trax.TransformerFactoryImpl transformer factory,
while it works when using the org.apache.xalan.processor.TransformerFactoryImpl.
So the test case can be replaced with:
{{code}}
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
TransformerFactory tf = new
org.apache.xalan.xsltc.trax.TransformerFactoryImpl();
String src = "<root><xmlConfiguration:xmlConfiguration
xmlns:xmlConfiguration=\"urn:configuration\" /></root>";
Document doc = dbf.newDocumentBuilder().parse(new
ByteArrayInputStream(src.getBytes()));
ByteArrayOutputStream res = new ByteArrayOutputStream();
tf.newTransformer().transform(new DOMSource(doc), new
StreamResult(res));
System.out.println(res);
dbf.newDocumentBuilder().parse(new
ByteArrayInputStream(res.toByteArray()));
{{code}}
> DOM to stream conversion fails on prefix beginning like "xmlConfiguration"
> --------------------------------------------------------------------------
>
> Key: XALANJ-2361
> URL: https://issues.apache.org/jira/browse/XALANJ-2361
> Project: XalanJ2
> Issue Type: Bug
> Components: Serialization
> Affects Versions: 2.7
> Reporter: Guillaume Nodet
> Priority: Critical
>
> Here is a simple test case to reproduce the problem:
> {{code}}
> DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> dbf.setNamespaceAware(true);
> TransformerFactory tf = TransformerFactory.newInstance();
>
> String src = "<root><xmlConfiguration:xmlConfiguration
> xmlns:xmlConfiguration=\"urn:configuration\" /></root>";
> Document doc = dbf.newDocumentBuilder().parse(new
> ByteArrayInputStream(src.getBytes()));
> ByteArrayOutputStream res = new ByteArrayOutputStream();
> tf.newTransformer().transform(new DOMSource(doc), new
> StreamResult(res));
> System.out.println(res);
> dbf.newDocumentBuilder().parse(new
> ByteArrayInputStream(res.toByteArray()));
> {{code}}
> The last line throws an exception, because the xmlns:xmlConfiguration
> attribute has been lost.
> While debugging, I found that the problem comes from
> http://svn.apache.org/repos/asf/xalan/java/trunk/src/org/apache/xml/serializer/NamespaceMappings.java,
> line 228:
> {{code}}
> // Prefixes "xml" and "xmlns" cannot be redefined
> if (prefix.startsWith(XML_PREFIX))
> {
> return false;
> }
> {{code}}
> It seems this test is wrong, and it should be
> {{code}}
> // Prefixes "xml" and "xmlns" cannot be redefined
> if (prefix.equals("xml") || prefix.equals("xmlns")
> {
> return false;
> }
> {{code}}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]