an...">

Do xslt 2.0 processors optimize selecting only the first item in a sequence?

For example, with the input document:

<root b="1" />

      

and the stylesheet:

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/*">
        <xsl:variable name="vTest" select="(@a, @b, @c)[1]" />
        <xsl:value-of select="$vTest" />
    </xsl:template>

</xsl:stylesheet>

      

Optimize XSLT processors by not evaluating an element @c

in a sequence (@a, @b, @c)[1]

?

The rational to define it vTest

this way is to try and emulate the logic xsl:choose

shorter.

I guess this might be tricky to answer in general, I'm especially interesting in Saxon XSLT 2.0 version 9.5+.

+3


source to share


1 answer


Saxon will certainly do this optimization. But there is nothing in the specification that guarantees this. And there may be situations when this does not happen, for example. execution strategy may be slightly different in try / catch. But generally, yes, most semi-pro XSLT processors will not fully evaluate EXPR when you write EXPR [1].



+3


source







All Articles