The following comment has been added to this issue:
Author: Jonathan Au
Created: Fri, 4 Jun 2004 2:52 PM
Body:
Please note that the sample code mixes DOM Level 1 and DOM Level 2 nodes (i.e. through
the use of createElement from Level 1 and createDocument from Level 2). Using
createElement, as opposed to createElementNS, returns an element with namespaceURI set
to null. Therefore, "commands" is not bound to any namespace, while "sieve-script" is
bound to the the default namespace corresponding to the URI
http://www.finalist.com/sieve. Because "commands" is not bound to any namespace, the
XPath expression /sieve-script/commands is invalid if the document is not passed
through the XMLSerializer.
XMLSerializer does not perform namespace fixup, so nodes not originally bound to a
particular namespace URI will become associated with the default namespace upon
serialization. This behavior would explain why the XPath expression
/sieve-script/commands works after using the XMLSerializer.
---------------------------------------------------------------------
View this comment:
http://issues.apache.org/jira/browse/XERCESJ-898?page=comments#action_35915
---------------------------------------------------------------------
View the issue:
http://issues.apache.org/jira/browse/XERCESJ-898
Here is an overview of the issue:
---------------------------------------------------------------------
Key: XERCESJ-898
Summary: Document creation by hand different than parsed document
Type: Bug
Status: Open
Project: Xerces2-J
Components:
DOM
Versions:
2.6.0
Assignee: Xerces-J Developers Mailing List
Reporter: Ronald Wildenberg
Created: Mon, 23 Feb 2004 3:55 PM
Updated: Fri, 4 Jun 2004 2:52 PM
Environment: Operating System: Other
Platform: Other
Description:
I create an XML document from another document using the org.w3c.dom API. When I
attempt to parse the document using Jaxen, it fails to find nodes that are
obviously present in the document.
However, when I write the document to a stream
(org.apache.xml.serialize.XMLSerializer) and parse it again using a
javax.xml.parsers.DocumentBuilder, the exact same XPath expressions in Jaxen
reproduce the correct nodes. I would expect behavior to be the same, no matter
how I created the document.
Below a code sample for creating the document (sorry for not providing a better
test case). The XPath "/sieve-script/commands" returns no results if I directly
use it on the produced document (both using Jaxen and the Xalan XPath API). If I
serialize the document, parse it again to an org.w3c.dom.Document and then use
the same XPath, it correctly finds nodes.
Creating the document
---------------------
DOMImplementation domImplementation = documentBuilder.getDOMImplementation();
DocumentType docType = domImplementation.createDocumentType(
"sieve-script", "-//Finalist IT Group//DTD Sieve-Script//EN", dtdLocation);
Document document = domImplementation.createDocument(
"http://www.finalist.com/sieve", "sieve-script", docType);
Element commandsElement = document.createElement("commands");
document.getDocumentElement().appendChild(commandsElement);
Element requireCommandElement = document.createElement("require-command");
commandsElement.appendChild(requireCommandElement);
---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
If you want more information on JIRA, or have a bug to report see:
http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]