[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] General rule for designing XPath expressions to return items in document order?

Subject: Re: [xsl] General rule for designing XPath expressions to return items in document order?
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 09 Jan 2014 10:48:52 +0000

On 09/01/2014 10:36, Costello, Roger L. wrote:
Hi Folks,

In yesterday's discussions we concluded that XPath expressions always
return values in document order. However, I have a counter-example
(from section 19.1 of the XSLT 3.0 specification).

It's an example of something but not a counterexample to the statement that path expressions return nodes in document order.

Consider this XML:

<Document> <head> <head>B</head> A </head> </Document>

Clearly "A" comes after "B" in the document. But this XPath:


results in outputting the latter value ("A") first and the earlier
value ("B") second.

well no, it doesn't output anything, it just selects the head elements in document order.

In fact, because of this non-document-order
behavior, that XPath expression is not streamable (the processor
would fetch "A" and then have to back up to fetch "B", and backing up
is not allowed in streaming).

I haven't checked the streaming rules in detail but I would expect //head to be streamable. (You might not be able to access any of the
child nodes in a streamable way but for example count(//head) ought to be able to count all the head in the document in a single pass.

On the other hand, this XPath expression results in outputting the values in document order:


That XPath results in outputting "B" followed by "A". Consequently
that XPath is streamable.

This one is streamable as discussed yesterday, the spec makes special provision for it.

So, some XPath expressions output in document order, some XPath expressions do not


Some XPath expressions are streamable, some are


Some XPath expressions are rewritten internally by the
XPath-processor to make them streamable, some XPath expressions are
not rewritten.


I am completely bewildered.




________________________________________________________________________ The Numerical Algorithms Group Ltd is a company registered in England and Wales with company number 1249803. The registered office is: Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________

Current Thread