You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Igor Peshansky (JIRA)" <xa...@xml.apache.org> on 2006/09/12 02:53:23 UTC

[jira] Created: (XALANJ-2319) Descendant axis sometimes includes the context node

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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2319) Descendant axis sometimes includes the context node

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2319?page=comments#action_12445967 ] 
            
Brian Minchau commented on XALANJ-2319:
---------------------------------------

If in the Java code you add this before creating the factory:
System.setProperty("javax.xml.xpath.XPathFactory:http://java.sun.com/jaxp/xpath/dom","org.apache.xpath.jaxp.XPathFactoryImpl");

or the equivalent as a JVM argument, then one always gets the class:
        org.apache.xpath.jaxp.XPathImpl
which is the class supported by Apache Xalan.

The other class, com.sun.org.apache.xpath.internal.jaxp.XPathImpl is SUN's repackaging of Xalan into their JRE and we can't help you much there. Also the class named org.apache.xpath.jaxp.XPathImpl with IBM J9 1.5.0 VM is also probably a repackaging of Xalan's code into their JRE.  I have to admit that either company may do more than repackage, they might improve it .... hard to say.

In any case it is likely that all three versions (Apache, SUN, IBM) probably have the same bug anyway. I'm afraid that I don't have the energy to look further into this one at this time, and I can't promise about the future (especially the limited future between now and the 2.7.1 release which is in a few weeks), so if you want this one fixed and you happen to think you know how it can be fixed please propose a patch.  

Running a patch through the regression tests is not as difficult as actually finding the fix for the the bug.

Regards,
Brian Minchau



> 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
>         Assigned To: Brian Minchau
>
> 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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Assigned: (XALANJ-2319) Descendant axis sometimes includes the context node

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XALANJ-2319?page=all ]

Brian Minchau reassigned XALANJ-2319:
-------------------------------------

    Assignee: Brian Minchau

> 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
>         Assigned To: Brian Minchau
>
> 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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2319) Descendant axis sometimes includes the context node

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2319?page=comments#action_12445770 ] 
            
Brian Minchau commented on XALANJ-2319:
---------------------------------------

Igor,
I reproduced your problem with the latest development code, exactly as you described.

I'm a little suspicious about your XPath object, you you add this to your code after you get your
XPath object:
        System.out.println("Class "+ xpath.getClass().getName());

What class does it print out for you?

> 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
>         Assigned To: Brian Minchau
>
> 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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2319) Descendant axis sometimes includes the context node

Posted by "Igor Peshansky (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2319?page=comments#action_12445901 ] 
            
Igor Peshansky commented on XALANJ-2319:
----------------------------------------

Brian,
I get different output depending on the JVM.

With the IBM J9 1.5.0 VM (build 2.3), I get "Class org.apache.xpath.jaxp.XPathImpl".  With the Sun HotSpot 1.5.0_04 VM, I get "Class com.sun.org.apache.xpath.internal.jaxp.XPathImpl".  I'm not sure how to find out which version of Xalan was bundled with those VMs.

The behavior is the same in both cases.

> 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
>         Assigned To: Brian Minchau
>
> 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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2319) Descendant axis sometimes includes the context node

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2319?page=comments#action_12442998 ] 
            
Brian Minchau commented on XALANJ-2319:
---------------------------------------

Per the JIRA triage meeting on Oct 16, 2005, Brian M. agreed to look at this one.

> 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
>         Assigned To: Brian Minchau
>
> 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: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org