You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2003/04/25 00:02:29 UTC
DO NOT REPLY [Bug 19295] New: -
SAX startElement() namespaceURI is null
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19295>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19295
SAX startElement() namespaceURI is null
Summary: SAX startElement() namespaceURI is null
Product: XalanJ2
Version: 2.5Dx
Platform: Other
OS/Version: Other
Status: NEW
Severity: Normal
Priority: Other
Component: org.apache.xalan.transformer
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: jmercay@scdi.org
When using a SAXResult in a Transformer.transform(), the first startElement()
event (representing the root node) contains a null namespaceURI. From the SAX
spec., it must be the empty string instead of null.
I can reproduce this on the Xalan bundled with JDK 1.4.1 and Xalan 2.5D1.
Below is a simple example:
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;
import java.io.File;
public class SAXTest {
public static void main(String[] args) throws Exception {
Transformer trans = TransformerFactory.newInstance().newTransformer(new
StreamSource(new File("stylesheet.xsl")));
trans.transform(new StreamSource(new File("input.xml")), new
SAXResult(new DefaultHandler() {
public void startElement(String uri, String localName,
String qName, Attributes attributes)
throws SAXException {
System.out.println("uri="+uri+" name="+localName);
super.startElement(uri, localName, qName, attributes);
}
}));
}
}
stylesheet.xsl:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="/root/*"/>
</xsl:template>
</xsl:stylesheet>
input.xml:
<root>
<note>
<to>Tove</to>
<from>Jani1</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
</root>
Result:
uri=null name=note
uri= name=to
uri= name=from
uri= name=heading
uri= name=body