This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
In the XSLT 3.0 spec, in the section "18.1 The xsl:source-document Instruction", following example is provided, <xsl:source-document streamable="yes" href="book.xml"> <xsl:for-each select="book"> <xsl:for-each select="chapter"> <xsl:result-document href="chapter{position()}.xml"> <xsl:copy-of select="."/> </xsl:result-document> </xsl:for-each> </xsl:for-each> </xsl:source-document> It seems, this example could be better written as follows, <xsl:source-document streamable="yes" href="book.xml"> <xsl:for-each select="book/chapter"> <xsl:result-document href="chapter{position()}.xml"> <xsl:copy-of select="."/> </xsl:result-document> </xsl:for-each> </xsl:source-document> (i.e with one for loop instead of two. The example talks about *one* book)
I also meant, that this suggestion is also a possible errata to spec.
I agree, the example code could be simplified (though it is not actually incorrect). I guess there's probably some history as to why it was written this way (perhaps some restriction on use of the position() function when streaming) but I don't intend to research it. (Actually, I sadly don't have the ability to research it. The WG kept all its discussions on a member-only list, and since my invited expert status has lapsed, I no longer have access to the archives.)
Out of curiosity, I briefly checked how this example looked historically, and it turns out that you have to go all the way back to the public draft of 2010 (!) to find that we originally used this: <xsl:stream href="book.xml"> <xsl:for-each select="book/chapter"> <xsl:result-document href="chapter{position()}.xml"> <xsl:copy-of select="."/> </xsl:result-document> </xsl:for-each> </xsl:stream> After that (Draft of 2012), it was changed into: <xsl:stream href="book.xml"> <xsl:for-each select="book"> <xsl:for-each select="chapter"> <xsl:result-document href="chapter{position()}.xml"> <xsl:copy-of select="."/> </xsl:result-document> </xsl:for-each> </xsl:for-each> </xsl:stream> But since we didn't have revision markings on these early drafts, there's no way of saying why we split the xsl:for-each. It could have had something to do with the concept of "incrementally consuming" expressions, which was a thing in the draft of 2012, but was later dropped as a concept. However, even with the rules of the time, both examples above would validate as streamable. From previous minutes and mail discussions I couldn't find anything meaningful (I have a local backup of some of the communication that is now inaccessible online, but not all). I agree that we could editorially improve this.
Related to this bug report, following is another point that may be editorially corrected. In the section, "18.1.2 Examples of xsl:source-document" there's an example mentioned as follows, Example: Using xsl:source-document with xsl:apply-templates The use of on-no-match="deep-copy" in the xsl:mode declaration means that the built-in template rule copies nodes unchanged, except where overridden by a user-defined template rule. And the XSLT transform below above text mentions, <xsl:transform version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:mode name="delete-ednotes" streamable="yes" on-no-match="shallow-copy"/> ....... i.e the XSLT transform above mentions, on-no-match="shallow-copy" Whereas, paragraph above mentions on-no-match="deep-copy".