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

Re: [xsl] XSLT Streaming: circumvent the one downward selection rule using xsl:fork


Subject: Re: [xsl] XSLT Streaming: circumvent the one downward selection rule using xsl:fork
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Sat, 7 Dec 2013 17:30:45 +0000

It's a design that attempts to find a compromise between conflicting goals.

Consider

<xsl:template match="doc">
  <xsl:apply-templates mode="toc"/>
  <xsl:apply-templates mode="body"/>
</xsl:template>

This makes two downward selections: it processes the entire document twice,
once to create the table of contents, once to create the body. The spec deems
this not streamable, because the output order isn't the same as the input
order.

But that's inconvenient for people who want to do this kind of transformation,
so we allow you to do

<xsl:template match="doc">
  <xsl:fork>
    <xsl:sequence>
      <xsl:apply-templates mode="toc"/>
    </xsl:sequence>
    <xsl:sequence>
      <xsl:apply-templates mode="body"/>
    </xsl:sequence>
  </xsl:fork>
</xsl:template>

The expected processing model for this is that the input is processed in such
a way that both prongs of the fork are executed during the same pass over the
input document. This means that to assemble the result tree, the *output* of
these two prongs (or at any rate, the output of all but the first) must be
buffered in memory. So the amount of memory needed is not independent of
document size; it's not a pure streaming approach. We wanted to make it
possible to do this kind of processing, but we also wanted "pure streaming" to
be the norm; we didn't want processors to do this kind of buffering
automatically without the user explicitly requesting it.

Michael Kay
Saxonica




On 7 Dec 2013, at 10:33, Costello, Roger L. <costello@xxxxxxxxx> wrote:

> Hi Folks,
>
> I am learning about the new xsl:fork element.
>
> It allows you to simultaneously perform multiple instructions on the input
as it is being streamed.
>
> Hmm ...
>
> So the one downward selection rule *prohibits* accessing more than one child
or descendent node from the context node. The xsl:fork element *enables*
accessing more than one child or descendent node from the context node.
>
> That's weird.
>
> It seems conflicting/contradicting. Yes?
>
> Please help me to understand.
>
> /Roger


Current Thread