This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Who can give me tech info about xsl:key and key()? (was: Lookup in a xml file with a key)
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: [xsl] Who can give me tech info about xsl:key and key()? (was: Lookup in a xml file with a key)
- From: Rene de Vries <RdVries at PCL-HaGe dot nl>
- Date: Tue, 10 Jul 2001 15:24:06 +0200
- Organization: PCL HaGé b.v.
- Reply-To: xsl-list at lists dot mulberrytech dot com
Hi xsl:key/key()-experts,
I've seen more of these XSL's as shown below and I'm surprised that they
work.
Could someone give me more technical info about how it works?
What surprises me is that you declare an xsl:key at the top of the XSL, for
a second XML-file which is to be read by the document()-function. So is it
possible to use xsl:key for multiple XML's and how do you use the
key()-function then?
And when is the key-table build, what is its scope and how must I imagine
such a table (if it is one)?
Greetings Rene
{ @ @ }
^
\__/
"You don't need eyes to see, you need vision!"
-----Oorspronkelijk bericht-----
Van: Dimitre Novatchev [SMTP:dnovatchev@yahoo.com]
Verzonden: dinsdag 10 juli 2001 12:53
Aan: gaston_annebicque@yahoo.com
CC: xsl-list@lists.mulberrytech.com
Onderwerp: [xsl] Re: Lookup in a xml file with a key
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" omit-xml-declaration="yes"/>
<xsl:key name="kLookup" match="name" use="../abbr"/>
<xsl:template match="/">
<out>
<xsl:apply-templates select="in/country"/>
<xsl:text>
</xsl:text>
</out>
</xsl:template>
<xsl:template match="country">
<xsl:variable name="input" select="."/>
<xsl:for-each select="document('lookup2.xml')">
<xsl:for-each select="key('kLookup',$input)">
<xsl:text>
</xsl:text>
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list