[xml] xpath problem
- From: Aleksey Sanin <aleksey aleksey com>
- To: xml gnome org
- Cc: FMoultrie iss net
- Subject: [xml] xpath problem
- Date: Wed, 28 Aug 2002 22:09:01 -0700
Hi, Daniel!
One of XML Security Library customers reported a strange problem with
XPath. It's quite late
here and I am not absolutelly sure but it looks like a bug. If it is
possible, will you take a look, please?
Thank you in advance,
Aleksey.
The problem:
===========================================================
There are two files a.xml and b.xml with a difference of \n in the last
line:
--- a.xml ---
<?xml version="1.0"?>
<EndUsers><EndUser Id="aaa"><Version>1.0</Version>
</EndUser>
</EndUsers>
--- b. xml ---
<?xml version="1.0"?>
<EndUsers><EndUser Id="aaa"><Version>1.0</Version>
</EndUser></EndUsers>
-------------
And there is an XPath expression:
(//. | //@* | //namespace::*) [ (ancestor::node() =
/EndUsers[1]/child::EndUser[ Id='aaa']) ]
The expected result is that this expression selects all childs of the
EndUser node with
Id attribute equal to 'aaa' (I know that it's ugly because the Id
attribute selected w/o node :) ).
However, it should work! But running this expression on these two files
gives different results
(correct result in the a.xml case and wrong result in the b.xml case):
[aleksey shell dd]$ ./testXPath --debug -f test.xpath -i a.xml
========================
Expression: (//. | //@* | //namespace::*)[(ancestor::node() =
/EndUsers[1]/child::EndUser[ Id='aaa'])]
Object is a Node Set :
Set contains 6 nodes:
1 ATTRIBUTE Id
TEXT
content=aaa
2 ELEMENT Version
3 TEXT
content=1.0
4 TEXT
content=
5 namespace xml href=http://www.w3.org/XML/1998/namespace
6 namespace xml href=http://www.w3.org/XML/1998/namespace
[aleksey shell dd]$ ./testXPath --debug -f test.xpath -i b.xml
========================
Expression: (//. | //@* | //namespace::*)[(ancestor::node() =
/EndUsers[1]/child::EndUser[ Id='aaa'])]
Object is a Node Set :
Set contains 8 nodes:
1 ELEMENT EndUser
ATTRIBUTE Id
TEXT
content=aaa
2 ATTRIBUTE Id
TEXT
content=aaa
3 ELEMENT Version
4 TEXT
content=1.0
5 TEXT
content=
6 namespace xml href=http://www.w3.org/XML/1998/namespace
7 namespace xml href=http://www.w3.org/XML/1998/namespace
8 namespace xml href=http://www.w3.org/XML/1998/namespace
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]