All,

A colleague has pointed out that an XPath expression is, by default,
evaluated against the children of the context node.  Therefore you have
to use an XPath expression such as:

        'self::ibis:positionRef'

to test against the QName of the context node itself.  If you only specify

        'ibis:positionRef'

then the test is performed on the node set formed by the CHILDREN of the
context node.

The conclusion?  No bug.

Thanks,

-bryan

-----Original Message-----
From: Bryan Thompson [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 04, 2003 1:35 PM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: jaxen: XPath context node bug?


I've been looking at this issue for a few days and I have become reasonably
convinced that this is a bug in Jaxen dealing with the context node when the
context node is neither the Document nor the root element in the document --
or, perhaps, when the context node was returned by a previous XPath
expression.

The problem is that XPath fails to match on the context node under these
circumstances.  I've written a program that demonstrates the behavior using
nothing but dom4j (dom4j-patched-1.3).

The program has two version of the same XML document built into it:
'theXML1' and 'theXML2'.  The only difference between those two versions
are that one uses the default namespace where the other uses explicit
namespaces prefixes. Both versions of the XML document demonstrate the
problem:

The program accepts zero or more XPath expression on the command line.  The
first XPath expression is applied to the Document.  Subsequent XPath
expressions are applied to the result of the previous XPath expression.  If
the result is a node-set, then the first member of that node set is used for
the subsequent test.

If you compile and run the program using the inputs specified below, the
first XPath:

        '//[EMAIL PROTECTED]:href]'

will select all XLink elements in the XML document.

The second XPath:

        'ibis:positionRef'

_SHOULD_ match on the <ibis:positionRef> XLink, but that match is failing,
which is the problem.

        ------------------

To compile:

        javac -classpath WEB-INF/lib/dom4j-full.jar XPathContextNodeBug.java

To run:

        java -classpath WEB-INF/lib/dom4j-full.jar\;. XPathContextNodeBug \
                '//[EMAIL PROTECTED]:href]' \
                'ibis:positionRef'

Thanks,

-bryan

[EMAIL PROTECTED]



-------------------------------------------------------
This SF.net email is sponsored by: Etnus, makers of TotalView, The debugger 
for complex code. Debugging C/C++ programs can leave you feeling lost and 
disoriented. TotalView can help you find your way. Available on major UNIX 
and Linux platforms. Try it free. www.etnus.com
_______________________________________________
dom4j-dev mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-dev

Reply via email to