Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.7, 2.6, 2.5
-
None
-
PatchAvailable
Description
Run this class:
--%<--
import java.io.StringReader;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
public class Test {
private static final String IDENTITY_XSLT_WITH_INDENT =
"<xsl:stylesheet version='1.0' " +
"xmlns:xsl='http://www.w3.org/1999/XSL/Transform' " +
"xmlns:xalan='http://xml.apache.org/xslt' " +
"exclude-result-prefixes='xalan'>" +
"<xsl:output method='xml' indent='yes' xalan:indent-amount='4'/>" +
"<xsl:template match='@*|node()'>" +
"<xsl:copy>" +
"<xsl:apply-templates select='@*|node()'/>" +
"</xsl:copy>" +
"</xsl:template>" +
"</xsl:stylesheet>";
public static void main(String[] args) throws Exception
}
--%<--
Just using plain JDK 5.0 JAXP, I get the expected
--%<--
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="root">
<child xmlns="child"/>
</root>
--%<--
If I add Xalan-J to the classpath, I get
--%<--
<?xml version="1.0" encoding="UTF-8"?>
<root xmlns="root">
<child xmlns="root"/>
</root>
--%<--
Note the incorrect namespace on the child element.
This is true in Xalan 2.5.2, 2.6.0, 2.7.0, and dev builds (xalan-gump-24102005.jar).
Prevents Xalan from being bundled with the NetBeans IDE, as it causes incorrectly written project metadata:
http://www.netbeans.org/issues/show_bug.cgi?id=66563
If you use newTransformer() with no stylesheet the problem goes away (though of course you lose indentation unless it is readded using setOutputProperty). Also if the Document is created in memory rather than parsed (see commented-out code) the problem goes away.
Does not seem to be reproducible in JDK 6, I don't know why.
Inclusion of the bundled Xerces in the classpath does not appear to make any difference.
Attachments
Attachments
Issue Links
- blocks
-
HARMONY-3221 [netbeans] Netbeans fails to start with Xalan in bootclasspath
- Open
- is related to
-
XALANJ-2302 Prefix collision bug during serialization
- Open
- relates to
-
XALANJ-2302 Prefix collision bug during serialization
- Open