Re: [xsl] Can a streaming loop be inside a non-streaming loop?

Subject: Re: [xsl] Can a streaming loop be inside a non-streaming loop?
From: "Michael Kay michaelkay90@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 8 Aug 2025 16:39:24 -0000
There is actually a technical difference. The second form (which can also be
written /*/record ! copy-of() ) obliges the processor to respect the order of
`record` elements; the first form doesn't. That's because
"/*/record/copy-of()" is required to deliver the copies in document order, and
document order across different trees is undefined. In practice when
streaming, however, there's no reason to want to do things in anything other
than document order, so they are very likely to be equivalent.

I probably got into this habit with collection(). When you do
collection()/copy-of() that's effectively a license to the processor to
process the items in the collection in any order, which can avoid a sort.

But I wasn't thinking about this, I just did it out of habit and to save a few
keystrokes.

Michael Kay

> On 8 Aug 2025, at 16:58, Roger L Costello costello@xxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> This morning Michael Kay showed this streaming code:
>
> <xsl:for-each select="/*/record/copy-of()">
>          ...
> </xsl:for-each>
>
> His placement of copy-of() is interesting. Is the following loop
equivalent?
>
> <xsl:for-each select="/*/record">
>      <xsl:variable name="record" select="copy-of()"/>
>          ...
> </xsl:for-each>
>
> Is one form better/preferred?
>
> /Roger

Current Thread