W3C home > Mailing lists > Public > public-qt-comments@w3.org > April 2016

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

From: <bugzilla@jessica.w3.org>
Date: Sat, 30 Apr 2016 10:20:23 +0000
To: public-qt-comments@w3.org
Message-ID: <bug-29604-523@http.www.w3.org/Bugs/Public/>
https://www.w3.org/Bugs/Public/show_bug.cgi?id=29604

            Bug ID: 29604
           Summary: [XSLT30] Request for clarification of statement in
                    section https://www.w3.org/TR/xslt-30/#stream-examples
           Product: XPath / XQuery / XSLT
           Version: Candidate Recommendation
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSLT 3.0
          Assignee: mike@saxonica.com
          Reporter: martin.honnen@gmx.de
        QA Contact: public-qt-comments@w3.org
  Target Milestone: ---

The section https://www.w3.org/TR/xslt-30/#stream-examples shows two uses of
xsl:stream with the accumulator functions count and max and the examples work
fine for me with Saxon 9.7. However that sections ends with the statement "To
compute both the count and the maximum value in a single pass over the input,
it is possible to use two variables.". I would like to see an example that does
that as it appears the naive approach of 

        <xsl:template name="xsl:initial-template">
                <xsl:stream href="transactions.xml">
                        <xsl:variable name="count"
select="count(transactions/transaction)"/>
                        <xsl:variable name="max"
select="max(transactions/transaction/xs:decimal(@value))"/>
                        <count>
                                <xsl:value-of select="$count"/>
                        </count>
                        <maxValue>
                                <xsl:value-of select="$max"/>
                        </maxValue>
                </xsl:stream>
        </xsl:template>

does not work with Saxon, it complains 

Static error in xsl:stream/@href on line 10 column 41 of test201604300104.xsl:
  XTSE3430: The body of the xsl:stream instruction is not streamable
  *  There is more than one consuming operand: {count(...)} on line 11, and
{let $max :=
  ...} on line 10

What I got to work is an example using a map

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

but that is no a use of two variables. 

So I hope the comment "To compute both the count and the maximum value in a
single pass over the input, it is possible to use two variables." could be
accompanied by an example that shows how to do that.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
Received on Saturday, 30 April 2016 10:20:25 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:58:00 UTC