[Home] [By Thread] [By Date] [Recent Entries]

  • To: XML-DEV <xml-dev@l...>
  • Subject: XPath node-set ordering
  • From: Peter Finch <peter@h...>
  • Date: Sun, 20 Jan 2002 15:16:35 +1100

Hi all,

Sorry if this is a dumb [newbie] question but I was 
just reading the XPath [http://www.w3c.org/TR/xpath] 
spec for the first time and I have a question about 
node-set ordering.

The introduction says that a "node-set" is "an unordered 
collection of nodes without duplicates", however, section 5
"Data Model" seems to indicate that they do have an order 
"There is an ordering, document order, defined on all 
the nodes in the document..."

My initial reaction was, "Ok, I know nodes have an
implicit order in the document so no big deal"... but 
further investigation seems to show that there are no
Node Set functions to compare node order, or even order
a node or node set.

What I'm asking is, if I were to perform a XPath
expression like "/descendant::chapter" and the chapters
were not in document order does anyone think that
this is a problem? 

Is there some way to make sure that the node sets
returned are in order?

Also, when I think about it, if node-sets are
unordered then performing ordered operations on
them like "[position()=5]" does not make sense?

Or... does a node only have an order during the
node test part of the expression?

Cheers,
Peter Finch

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member