[Xpath-ng] FIXPath (XPath NG core) straw man draft posted
Uche Ogbuji
uche.ogbuji at fourthought.com
Sun Jan 5 18:32:48 MST 2003
> Uche Ogbuji wrote:
>
> >i.e. the LHS returns the nodes in *reverse* document order, does this cause
> >any problem that the result of the overall expression forces everything back
> >to forward document order because of the merge? I think this may indeed be a
> >problem. If my doc is:
> >
> ><a><b><c/></b><d/><e/></a>
> >
> >and the context node is c, then I think I would expect
> >
> >ancestor:*/child::*
> >
> >to result in
> >
> >[c, b, d, e, a]
> >
> >But the way I have merge in the straw man, instead we'd get
> >
> >[a, b, c, d, e]
> >
> >Or is my brain indeed fried? :-)
> >
> Eh, it looks to me you should just get [a,b] as c has no children:
Wrong. Try it in an XPath processor and see.
Let's break it down in XPath 1.0 terms.
The context is <c/>
From this, ancestor::* returns
{b, a} ("{}" notation for set)
It is a reverse axis, so if it's part of a step, it is resolvesd to a context
node *list* for processing in the next step in *reverse* document order:
[b, a, /] ("[]" notation for list, "/" notation for root node)
Now according to the rules for location paths, this becomes the context node
list for the child::* step. Therefore, all children of each of these three
nodes are obtained as the result of that step:
{c, b, d, e, a}
As I had in my post.
Now according to XPath 1.0 rules, this is a node set, and the weird ordering
is in effect forgotten. My entire point is that it might make sense to write
merge so that this ordering is not lost and that the result of this operation
is indeed.
[c, b, d, e, a]
See. I said reverse axes are brain busters ;-)
--
Uche Ogbuji Fourthought, Inc.
http://uche.ogbuji.net http://4Suite.org http://fourthought.com
A Python & XML Companion - http://www.xml.com/pub/a/2002/12/11/py-xml.html
XML class warfare - http://www.adtmag.com/article.asp?id=6965
MusicBrainz metadata - http://www-106.ibm.com/developerworks/xml/library/x-thi
nk14.html
More information about the Xpath-ng
mailing list