[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Key/Use
[<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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|