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

Re: Key/Use

Subject: Re: Key/Use
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Wed, 5 Sep 2001 16:01:32 -0400
xslt dynamic lookup tables
[<Kevin_Gutch@xxxxxxxxxxx>]


>  <xsl:key name="lookup" match="row" use="US_layer_name"/>
>
> All I actually want to do is  pass in a parameter from a servlet and use a
> dynamic key value to be used in a XSLT LookUp Table. Everything works I
> just want to use a dynamic lookup table so I do not have to have more than
> one lookup table. So basically US could be BG(Great Britian),CN(Canada)
> etc.
>

Isn't this more or less what you were after?  The country could be passed in
as a global parameter instead of being a variable.  This example makes use
of an index (which you were asking for), and you can pass in the country
dynamically.  Here the index isn't buying you much, but if the example were
more complicated (and long) it might.   The point is to use the variable at
lookup time, not when you define the key.

XML:
<root>
<row country='US'>us1</row>
<row country='US'>us2</row>

<row country='GB'>gb1</row>
<row country='GB'>gb2</row>
<row country='GB'>gb3</row>

<row country='FR'>fr1</row>
<row country='FR'>fr2</row>
</root>

XSLT:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name='c' select='"GB"'/>
<xsl:key name='country' match='row' use='@country'/>

<xsl:template match="/">
<results>
   <xsl:for-each select='key("country",$c)'>
        <xsl:value-of select='.'/>
   </xsl:for-each>
</results>
</xsl:template>
</xsl:stylesheet>

Output:

<results>gb1gb2gb3</results>


Cheers,

Tom P


 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.