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

The result of ancestor-or-self()::node() contains duplicated Document nodes.

           Summary: The result of ancestor-or-self()::node() contains
                    duplicated Document nodes.
           Product: XalanJ2
           Version: 2.3
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Major
          Priority: Other
         Component: org.apache.xpath
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


The following code simply sets the root element to the context node and
selects "ancestor-or-self()::node()".  Expected result is a node-set
consisted of two nodes, Document and `root' Element, and actual result is
a node-set that has three nodes, Document, Document and `root' Element.

// ----------------------------------------------------------------
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.xpath.XPathAPI;
import org.apache.xpath.objects.XObject;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.traversal.NodeIterator;

public class XPathBug0612 {
    public static void main(String[] argv) throws Exception {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document doc = builder.newDocument();
        Element root = doc.createElement("root");
        doc.appendChild(root);

        NodeIterator nl = XPathAPI.selectNodeIterator(root, "ancestor-or-
self::node()");
        Node n;
        int i = 0;
        while ((n = nl.nextNode()) != null) {
            System.out.println(n.getNodeName());
            i++;
        }
        // assertEquals(2, i);
    }
}
// ----------------------------------------------------------------

Reply via email to