Re: [xslt] long processing time when using key that returns an empty node set



Tim Chen schrieb:
Hi,

When I have a xsl:key who's select results in no nodes, I notice a
ridiculous increase in processing time.

Below is an example that runs in 4ms when the select returns nodes and
2400ms when no nodes are in the key.

I can confirm this using LibXSLT 1.1.22.

Here's the OP's stylesheet reformatted and a line to generate the
document:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
  <xsl:output method="text" version="1.0" encoding="utf-8" indent="no"/>
  <!--
  <xsl:key name="idKey" match="/document/node[ id='2000']" use="@id"/>
  -->
  <xsl:key name="idKey" match="/document/node[ id='-1']" use="@id"/>
  <xsl:template match="/">
    <xsl:value-of select="count( key('idKey', /document/node/@id) )"/>
  </xsl:template>
</xsl:stylesheet>

perl -lwe 'print for q{<document>}, map( qq{<node id="$_"/>}, 1 .. 2000), q{</document>}'

Michael Ludwig


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]