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

Re: [xsl] Designing streamable XPath expressions


Subject: Re: [xsl] Designing streamable XPath expressions
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sun, 5 Jan 2014 21:03:54 +0000

In the XSLT 3.0 specification, the expression count(//section/head) is
streamable. This is explained in section 19.1

http://www.w3.org/TR/xslt-30/#pattern-scanning

Specifically, because //section/head is a motionless pattern, it can be
evaluated in a single pass scanning all descendants in document order.

However, the expression

distinct-values(//section/head)

would not be streamable, because at analysis time you cannot tell that there
will be no overlapping <head> elements.

Saxon in these cases is more liberal than the XSLT 3.0 specification; it
treats such expressions as streamable, and if necessary does some run-time
buffering to cope with overlapping elements if they actually exist.

Michael Kay
Saxonica


On 5 Jan 2014, at 10:24, Costello, Roger L. <costello@xxxxxxxxx> wrote:

> Hi Folks,
>
> Suppose you want to count the <head> elements within the <section>
elements.
>
> You might use this simple XPath expression:
>
> 	count(//section/head)
>
> However, that has a subtle problem when used in a streaming program.
>
> I created a few slides that describe the problem, as well as the solution:
>
> http://xfront.com/Streamable-XPath-expression.pptx
>
> /Roger


Current Thread
Keywords