[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Using a tree read with document() as a hash-table -- wor

Subject: RE: Using a tree read with document() as a hash-table -- working solution
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Wed, 14 Jun 2000 14:41:40 +0100
read hash table
> A quick test showed that the template-call could be avoided by using
> 
>     <value><xsl:value-of 
> select="$packtypetree//ROW[packcode=$packinfopacktype][1]/modu
> ltxt"/></value>
> 
> instead.  This is just what I needed for a hash-lookup!
> 
> On a final note - would a key() make this faster?  I still 
> have a bit of a problem understanding how it works.
> 
Yes, it would be faster, assuming that the lookup table is of some size and
is used fairly often. (In fact, it's not a hash-lookup at all unless you use
a key - it's likely to be a serial search on most processors).

Write
<xsl:key name="packcode" match="ROW" select="packcode"/>

and then replace the above code with
<value>
<xsl:for-each select="$packtypetree">
<xsl:value-of select="key('packcode',$packinfopacktype)[1]/modultxt"/>
</xsl:for-each>
</value>

The for-each is not an iteration, it's needed to establish the current
document for the key() function.

Mike Kay


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.