Re: [xsl] Streaming terminology: Grounded

Subject: Re: [xsl] Streaming terminology: Grounded
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Mon, 20 Jan 2014 12:07:51 +0000
On 20 Jan 2014, at 10:38, Costello, Roger L. <costello@xxxxxxxxx> wrote:

> Hi Folks,
>
> I am having a hard time understanding the new streaming terminology. And,
truthfully, I am feeling overwhelmed with all the new terminology.

Yes, it is overwhelming. Believe me, we put it in place because we found we
were using the same words to mean different things at different times and were
getting ourselves very confused as a result.
>
> Perhaps we could collectively discuss each term, one at a time, and
understand them?
>
> How about starting with "grounded".
>
> The spec defines it this way:
>
> 	 Grounded: indicates that the value returned
> 	by the construct does not contain nodes from
> 	the streamed input document. Atomic values
> 	and function items are always grounded; nodes
> 	are grounded if it is known that the they are in
> 	a non-streamed document. For example the
> 	expressions doc('x') and copy-of(.) both return
> 	grounded nodes.
>
> So this string
>
> 	"Hello World"
>
> is grounded because it is an atomic value and clearly it doesn't involve
reading anything from the input. That seems reasonable to me.

Correct.
>
> I am puzzled why
>
> 	copy-of(.)
>
> is grounded, as it surely *does* result in reading (consuming) the input,
right?

It's sweep is consuming, because it consumes the input. But its posture is
grounded, because the node it returns is a non-streamed node; it's an ordinary
in-memory tree, which means you can do any navigation you like on the result,
with no restrictions imposed by the streaming rules.
>
> And why is
>
> 	doc('Book.xml')
>
> grounded? Surely that expression results in reading new input (i.e., the
content of Book.xml), right?

It's what it returns that counts. We've defined that doc() returns an ordinary
in-memory tree, allowing free navigation in any direction with no streaming
restrictions.
>
> What are other examples of things that you might put in an XSLT program that
doesn't result in consuming any input?
>
> So, grounded means "anything that doesn't result in consuming input",
right?
>
No. That was one of the key mistakes we were making before we introduced this
terminology. Grounded expressions can be consuming, and non-grounded
expressions can be non-consuming. They are orthogonal concepts. One is about
the input to the expression, one is about its output.

Michael Kay
Saxonica

Current Thread