xsl-list
[Top] [All Lists]

Re: [xsl] Designing streamable XPath expressions

2014-01-05 15:04:09
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(_at_)mitre(_dot_)org> 
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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--