Is failed key-lookups very slow in Xalan-J 1.2?

Subject: Is failed key-lookups very slow in Xalan-J 1.2?
From: tra@xxxxxxxxxxxxxxx (Thorbjoern Ravn Andersen)
Date: Wed, 22 Nov 2000 11:04:22 +0100
I am developing an XSLT-version of our current application in which we
need to render XHTML-documents representing products, where the prices
shown to the customer depends on the ACCESSCODE which is passed to the
style sheet as a parameter.

My question deals with the speed of the "key"-construction in Xalan
1.2 (which is the platform we use -- I need good arguments to switch
to e.g Saxon.   Speed might be a good argument)

My timings show that if I replace the key-lookup with an empty string,
my code runs in 0.5 seconds (overhead from other routines), and if my
key-function succeedes in all 66 cases for my sample file then it runs
in about 1.0 second.  Each key-lookup returns either 0 or 1 node.

If the key-function _fails_ in all 66 cases then it runs in 5.5
seconds, which is rather unfortunate, since this is the default setup
for unregistered users.

Narrowing the scope for the key-function with a xsl:for-each around,
did not help.

Could a kind soul help me understand why Xalan-J 1.2 behaves like
this?  Is there a way to circumvent it?


The XSLT-code follows.  The various constructions I have tried is
still there as comments.


<xsl:key name="price-for" match="VALUENUM" use="../PRICEKEY"/>

<xsl:template match="STIBO-PRICE">
  <xsl:variable name="value" select="concat(@value,',',$ACCESSCODE)"/>

  <!--  <xsl:for-each select="$database">
-->

    <xsl:variable name="price" select="key('price-for', $value)"/>
      <!--<xsl:variable name="price" select="''"/>-->
    <xsl:choose>
      <xsl:when test="string-length($price)=0"> 
        <xsl:value-of select="$PRICELESS"/>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$price"/>
      </xsl:otherwise>
    </xsl:choose>
    <!--      </xsl:for-each>
-->
</xsl:template>



The database section looks like

<html>
  <database ...>
    <table0 ....>
      <record0>
        <PRICEKEY>2360455,1,RSES</PRICEKEY>
        <VALUENUM>247</VALUENUM>
      </record0>
      <record0>
        <PRICEKEY>2360455,2,RSES</PRICEKEY>
        <VALUENUM>222</VALUENUM>
      </record0>
    ....
    </table0>
    <table1>... [other irrelevant stuff]
    ...
    </table1>
  </database>

  ... rest of XHTML-file
</html>

The database variable which I have experimented with (to narrow the
scope) is defined as

    <xsl:variable name="database" select="/html/database"/>




Thanks in advance,

-- 
  Thorbjørn Ravn Andersen                   "...sound of... Tubular Bells!"
  http://bigfoot.com/~thunderbear


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread