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

Re: [xsl] Does the count() function require access to the whole subtree?

Subject: Re: [xsl] Does the count() function require access to the whole subtree?
From: "Costello, Roger L." <costello@xxxxxxxxx>
Date: Wed, 15 Jan 2014 10:48:33 +0000

A couple days ago Michael Kay wrote:

	count(//x) is streamable, but data(//x) is not.
	Here //x is a "crawling" expression - one that
	selects nodes which may overlap each other.
	When an expression returns (potentially)
	overlapping nodes, the W3C spec says you
	can apply inspection operations like count()
	to those nodes, but you cannot apply absorption
	expressions like data(), because doing so would
	require buffering.

I'm getting hung up on terminology: crawling, inspection, absorption,

Even though (I think) that I now understand those terms, I still don't
understand why one expression is streamable while another is not. For example,
why is count(//x) streamable whereas data(//x) is not?  I don't want to
remember a bunch of definitions and rules (which I will quickly forget). I
want to understand the concepts (which I won't forget).

I understand best with examples. Consider this XML:


This XPath expression:


returns a sequence of two subtrees:



Michael, would you take us  (conceptually) through the process an XSLT
processor would go through - as it incrementally steps through the XML
document - to count the number of <x> elements?

And would you explain why the data(//x) operation would require buffering and
is therefore not streamable, please?


Current Thread