[Bug 29604] [XSLT30] Request for clarification of statement in section https://www.w3.org/TR/xslt-30/#stream-examples

https://www.w3.org/Bugs/Public/show_bug.cgi?id=29604

--- Comment #1 from Michael Kay <mike@saxonica.com> ---
I really have no idea what we were thinking of when we wrote the sentence:

"To compute both the count and the maximum value in a single pass over the
input, it is possible to use two variables."

Perhaps the spec was different when we wrote that, and we failed to notice the
effect of a change.

In fact the way I would recommend computing multiple aggregates is to use a
map:

<xsl:template name="xsl:initial-template" expand-text="yes">
  <xsl:stream href="transactions.xml">
    <xsl:variable name="aggregates" 
      select="map{'count': count(transactions/transaction),
                  'maxValue':
"max(transactions/transaction/xs:decimal(@value))}"/>
    <count>{$count}</count>
    <maxValue>{$max}</maxValue>
  </xsl:stream>
</xsl:template>

I haven't tested this under Saxon but it ought to work, and I think it would be
a good idea to add the example to the spec.

(We decided to special-case map constructors so that multiple consuming
operands are allowed: they therefore become a convenient way to capture
multiple results during a single scan of the input. This can also be achieved
using xsl:fork or using accumulators, but those mechanisms are much more
complex.)

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Thursday, 12 May 2016 10:16:00 UTC