You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Thorbjoern Ravn Andersen <tr...@mrbean.stibo.dk> on 2000/11/22 11:03:20 UTC
Is failed key-lookups slow in Xalan-J 1.2?
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
Re: Is failed key-lookups slow in Xalan-J 1.2?
Posted by Claudio Sacerdoti Coen <sa...@students.cs.unibo.it>.
On Wed, Nov 22, 2000 at 11:03:20 +0100, Thorbjoern Ravn Andersen wrote:
> 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.
I have observed the same behaviour some time ago: replacing keys
with a linear search on a list (=a flat tree) gave to me better
performance!
So I am also curious for an explanation and I hope that the problem
with key slowness will be fixed.
Thanks in advance,
C.S.C.
--
----------------------------------------------------------------
Real name: Claudio Sacerdoti Coen
Graduate Computer Science Student at University of Bologna
Now on leaving at INRIA (Rocquencourt)
E-mail: sacerdot@cs.unibo.it
http://caristudenti.cs.unibo.it/~sacerdot
----------------------------------------------------------------