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=4336>. 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=4336 Xalan 2.2.D11 adds a strange Attribute ------- Additional Comments From [EMAIL PROTECTED] 2001-11-15 11:31 ------- Dear Joe, I have the following problem. The XPath catches the xmlns:xml attribute which has been added for resolving the xml namespace. When I try to get the owner document of the node, I get an exception: /* Apache Xerces Xerces 1.4.3 Apache Xalan Xalan Java 2.2.D11 0 DOCUMENT [#document: null] 1 COMMENT [#comment: full document with decl ] 2 ELEMENT [doc: null] 3 ATTRIBUTE org.apache.xml.dtm.ref.dom2dtm.DOM2DTM$defaultNamespaceDeclarationNode@2effdf 3 xmlns:xml http://www.w3.org/XML/1998/namespace 3 specified false java.lang.NullPointerException at org.apache.xml.dtm.ref.dom2dtm.DOM2DTM$defaultNamespaceDeclarationNode.getOwnerD ocument(DOM2DTM.java:1722) at org.apache.xml.security.temp.XalanBug4336.main(XalanBug4336.java:120) Exception in thread "main" */ import java.io.*; import org.w3c.dom.*; import javax.xml.parsers.*; import javax.xml.parsers.ParserConfigurationException; import javax.xml.transform.TransformerException; import org.xml.sax.SAXException; import org.apache.xpath.XPathAPI; /** * Xalan Bug 4336 * * @author $Author: geuerp $ * @version $Revision: 1.4 $ * @see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=4336 */ public class XalanBug4336 { static final String _nodeSetInput1 = "<?xml version=\"1.0\"?>\n" + "<!DOCTYPE doc [\n" + "<!ELEMENT doc (n+)>\n" + "<!ELEMENT n (#PCDATA)>\n" + "]>\n" + "<!-- full document with decl -->" + "<doc><n>1</n></doc>"; public static void main(String unused[]) throws Exception { System.out.println("Apache Xerces " + org.apache.xerces.framework.Version.fVersion); System.out .println("Apache Xalan " + org.apache.xalan.processor.XSLProcessorVersion.S_VERSION); DocumentBuilderFactory dfactory = DocumentBuilderFactory.newInstance(); dfactory.setValidating(false); dfactory.setNamespaceAware(true); DocumentBuilder db = dfactory.newDocumentBuilder(); Document document = db.parse(new ByteArrayInputStream(_nodeSetInput1.getBytes())); NodeList nl = XPathAPI.selectNodeList(document, "(.//. | .//@* | .//namespace::*)"); for (int i = 0; i < nl.getLength(); i++) { System.out.println(i + " " + getNodeTypeString(nl.item(i)) + " " + nl.item(i)); if (nl.item(i).getNodeType() == Node.ATTRIBUTE_NODE) { Attr a = (Attr) nl.item(i); System.out.println(i + " " + a.getNodeName() + " " + a.getNodeValue()); System.out.println(i + " specified " + a.getSpecified()); System.out.println(i + " owner document: " + a.getOwnerDocument()); } } } static String[] nodeTypeString = new String[]{ "", "ELEMENT", "ATTRIBUTE", "TEXT_NODE", "CDATA_SECTION", "ENTITY_REFERENCE", "ENTITY", "PROCESSING_INSTRUCTION", "COMMENT", "DOCUMENT", "DOCUMENT_TYPE", "DOCUMENT_FRAGMENT", "NOTATION" }; public static String getNodeTypeString(short nodeType) { if ((nodeType > 0) && (nodeType < 13)) { return nodeTypeString[nodeType]; } else { return ""; } } public static String getNodeTypeString(Node n) { return getNodeTypeString(n.getNodeType()); } }
