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

Re: lookup problem

Subject: Re: lookup problem
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Tue, 16 Oct 2001 13:28:57 -0400
key lookup problem
This works on your example:

<xsl:key name="MyKey" match="c" use="../b"/>

Personally, I'd put the lookup table in another file and get it using
doument().  It's more work to use in the stylesheet because you have to
change context when you apply the key expression, but it separates the
lookup values from the application producing the xml.

You ought to wrap your output in a document element, too.

Cheers,

Tom P

[Steve Renshaw]

> how do you do a simple lookup? i need the following lookup
> function available !throughout! my XSLT:
>
> Lookup('1') -> 'one'
> Lookup('2') -> 'two'
> LOokup('3') -> 'thre'
> Lookup('4') -> 'four'
>
> I tried the folloowing xslt without any luck. ANy help please?
>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:key name="MyKey" match="/root/a/b" use="/root/a/c"/>
> <xsl:template match="/">
>   <xsl:value-of select="key('MyKey','1')"/><br/>
>   <xsl:value-of select="key('MyKey','2')"/><br/>
> <xsl:value-of select="key('MyKey','3')"/><br/>
> <xsl:value-of select="key('MyKey','4')"/><br/>
> </xsl:template>
> </xsl:stylesheet>
>
>
> <?xml version="1.0" ?>
> <?xml:stylesheet type="text/xsl" href="style.xsl"?>
> <root>
> <a><b>1</b><c>one</c></a>
> <a><b>2</b><c>two</c></a>
> <a><b>3</b><c>three</c></a>
> <a><b>4</b><c>four</c></a>
> <BulkOfApplicationDataGoesHere/>
> </root>
>



 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.