[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: John Lumley <john@xxxxxxxxxxxx>
Date: Mon, 13 Jan 2014 18:19:08 +0000

On 13/01/2014 12:53, Michael Kay wrote:
No. Counter-example: count(following-sibling::x) is not streamable.

More specifically, count(X) is streamable (more specifically, its posture is grounded) if the posture of X is grounded, climbing, striding, or crawling, but not if it is roaming.

Sorry - I know that's a lot of new jargon to absorb on a Monday morning!

To clarify (or muddy) the situation a little more ..... whilst:


   count(//h)
   on its own would be streamable (it has grounded posture, and returns
   NO nodes from the context subtree),

   count(//h) + count(//j)
   is not streamable, since though each separately is grounded, BOTH
   have consuming sweep, i.e. they each consume the entirety of the
   context subtree and the posture becomes roaming - there has to be
   some form of buffering to be able to satisfy the second operand's
   sweep over its data.

   If both were members of a choice group (i.e. only one of them can
   actually operate in any execution) then streamability may be
   restored - such a case would be      if($h) then count(//h) else
   count(//j).

Of course clever understanding of the deeper semantics could cause a rewrite, such as count(//*[self::h|self::j]) to have grounded posture and be streamable on its own, but that requires knowledge of a distribution rule for count() and + and rewrites for (//h|//j).

Actually that's a pretty simple case, so perhaps we need machines to at least help check.... I hope to have something we can show at XMLPrague.

John

--
*John Lumley* MA PhD CEng FIEE
john@xxxxxxxxxxxx <mailto:john@xxxxxxxxxxxx>
on behalf of Saxonica Ltd


Current Thread