You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2004/02/23 16:55:58 UTC

DO NOT REPLY [Bug 27163] New: - Document creation by hand different than parsed document

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=27163>.
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=27163

Document creation by hand different than parsed document

           Summary: Document creation by hand different than parsed document
           Product: Xerces2-J
           Version: 2.2.0
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: xerces-j-dev@xml.apache.org
        ReportedBy: ronald@finalist.com


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);

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org