xsl-list
[Top] [All Lists]

RE: Re: xslt query a data

2003-04-22 12:02:02

for example I have a table or equavalent XML have
below information
1, a
2, b
3, c
4, d

In my stylesheet, I only have a, b, c, d value
but I need to use 1, 2, 3, 4 as a substitution


Set up a document called lookup.xml as follows:

<table>
<entry code="1" val="a"/>
<entry code="2" val="b"/>
...
</table>

Then you can do:

document('lookup.xml')/table/entry[(_at_)val=$val]/@code

For convenience, you can put the table inside the stylesheet - in
standard XSLT 1.0 you can reference the stylesheet as document(''), but
more efficiently you can put the lookup table in a variable and
reference it with the extension function xx:node-set().

For further efficiency with large lookup tables, learn about xsl:key and
the key function.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 


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



<Prev in Thread] Current Thread [Next in Thread>