w3c / xslt30-test

24 stars 14 forks source link

copy-3002 - applicability of accumulators #50

Open michaelhkay opened 2 years ago

michaelhkay commented 2 years ago

I think copy-3002 should fail because the accumulator is not applicable.

We're doing this:

    <xsl:variable name="v" as="element()">
      <xsl:copy-of select="//*[@x='a3-4']" copy-accumulators="yes"/>
    </xsl:variable>
    <xsl:value-of select="$v/accumulator-before('latest-pick'), 
                          $v/accumulator-after('latest-pick') "/>

so we're looking at an accumulator on a temporary tree that was copied from the accumulator values on the principal source document. The spec says (in §18.2.2 #5)

For a document containing nodes supplied in the initial match selection, the accumulators that are applicable are those determined by the xsl:mode declaration of the initial mode. This means that in the absence of an xsl:mode declaration, no accumulators are applicable.

and rule 6 says:

For a tree T created by copying a node in a tree S using the copy-of or snapshot functions, or the instruction xsl:copy-of with copy-accumulators="yes", an accumulator is applicable to T if and only if it is applicable to S.

Taking these rules together, the accumulator is not applicable to the initial match selection, therefore it is not applicable to $v, therefore the test should fail with XTDE3362.

I proposed to fork the test, creating one variant with the stylesheet unchanged, expecting an error, and another variant that corrects the error by making the accumulator applicable.