Descendant axis sometimes includes the context node
---------------------------------------------------

                 Key: XALANJ-2319
                 URL: http://issues.apache.org/jira/browse/XALANJ-2319
             Project: XalanJ2
          Issue Type: Bug
          Components: parse-or-compile
    Affects Versions: 2.7
            Reporter: Igor Peshansky


The following code:

import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.DOMImplementation;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class Y {
        public static void main(String[] stringArr) throws Exception {
                DOMImplementation domImpl = 
DocumentBuilderFactory.newInstance().newDocumentBuilder().getDOMImplementation();
                Document document = domImpl.createDocument(null, "foo", null);
                Element element = document.getDocumentElement();
                element.appendChild(document.createElement("bar"));

                XPath xpath = XPathFactory.newInstance().newXPath();
                String result = (String) 
xpath.evaluate("name(./descendant::*)", element, XPathConstants.STRING);
                System.out.println(result);
        }
}

prints "foo", whereas it should have printed "bar".  Changing the XPath 
expression from "name(./descendant::*)" to "name(self::node()/./descendant::*)" 
makes Xalan produce the correct result, but "name(self::node()/descendant::*)" 
still exhibits the incorrect behavior.

A bit of debugging shows that when DescendantIterator is created, the 
constructor sets the axis to DESCENDANTORSELF, because the first step is a 
FROM_SELF (even though the subsequent steps are not supposed to return the self 
node).

-- 
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
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to