[Xpath-ng] My favorite XPath language]

David Carlisle davidc at nag.co.uk
Fri Nov 22 02:35:41 MST 2002


> Number two on my list is the node set vs. node list distinction.
> The problem being that XPath doesn't _make_ the distinction;
> instead it augments nodes in a node set with "context positions"
> when it needs to do list-like operations.

I was going to comment on this last night but decided to leave it till
the morning, when I find that  Uche's already predicted that I'd keep an
eye on this point:-)

Xpath 1 does make the distinction between node sets (which are first
class objects) and the current node list (which isn't). while some
people have objected to the set paradigm it does make many things
natural.

In Xpath2 which has moved to ordered lists as the basic data structure,
the definition of almost every peration has to be modified to re-assert
document order on the result, thus the fact that path expressions
produce something in document order is a result of ad hoc specification
of lots of individual functions whereas in the Xpath1 model it is
natural that set operations just create the union of sets, so ordering is
not an issue and duplication removal is part of the semantics of the
data type (sets) rather than being part of the semantics of each
operation.

Currently the XPath draft omits to specify document order for
one operation (selecting nodes in a step) so document order (and
backward compatibility) isn't maintained.
http://lists.w3.org/Archives/Public/public-qt-comments/2002Nov/0087.html
This will no doubt be fixed in the next draft but it shows the dangers
of enforcing document order separately in each operation.

That said, there are some advantages to moving to lists, especially if
lists can be nested, Xpath2 lists where ((1,2),(3,4)) is legal but equal
to (1,2,3,4) will, I think, cause some nasty surprises for users down the
road, and make several "standard" functional programming operations
difficult as the result of mapping a function over a list always gets
flattened in this way...

I think this choice of basic data type for node collections

a) node sets
b) XPath2 flattened lists
c) nested lists

will have a fundamental effect on the flavour of any Xpath NG language.
I _think_ I'd go for (c).


David


_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.



More information about the Xpath-ng mailing list