xsl-list
[Top] [All Lists]

[xsl] Performance of xsl:for-each with key() lookup

2018-09-26 15:39:58
Hi,

I'm using the following pattern in multiple places in my stylesheets:

    <xsl:for-each select="key('some', $value, $doc)">

My question is, would iteration be optimized if I selected the nodes
into a variable first?

    <xsl:variable name="elems" select="key('some', $value, $doc)"
as="element()*"/>
    <xsl:for-each select="$elems">

I guess it should be faster if the key() function is called only once
instead of multiple times? But if there is an index maybe it doesn't
matter?

And does the same apply to

    <xsl:apply-templates select="key('some', $value, $doc)"/>

as well?

I'm using Saxon 9.1.0.8.


Martynas
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>