This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Loading an external file of index
- To: xsl-list at mulberrytech dot com
- Subject: Re: Loading an external file of index
- From: Jeni Tennison <Jeni dot Tennison at epistemics dot co dot uk>
- Date: Thu, 22 Jun 2000 12:29:20 +0100
- References: <4.3.2.7.2.20000622094023.00aef090@pop.dial.oleane.com>
- Reply-To: xsl-list at mulberrytech dot com
At 12:42 PM 6/22/00 +0200, Eric van der Vlist wrote:
>I haven't tested it since my favorite XSLT processors is lacking key
>support, but something like :
>
><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>version="1.0">
>
> <xsl:output method="html" indent="no"/>
>
> <xsl:key name="mysetofkeys"
> match="document('../shared/shared.xml')/keybase/key"
> use="@name"/>
>
> ....
>
></xsl:stylesheet >
>
>should work from my understanding of the rec.
Unfortunately, I know from struggling with some fairly recent questions
that this doesn't work. You can't use the document() function within the
'match' attribute of xsl:key. Instead, define the key as if the input
document was the one with the keys in, at the top level of the stylesheet:
<xsl:key name="mysetofkeys" match="/keybase/key" use="@name" />
Then, when you want to use it, put the key() function within an
xsl:for-each that has the document that holds the keys as its 'select'
attribute:
<xsl:template match="keyref">
<xsl:variable name="keyrefname" select="@name" />
<xsl:for-each select="document('../shared/shared.xml')">
<b><xsl:value-of select="key('mysetofkeys', $keyrefname)/ACRONYM" /></b>
</xsl:for-each>
</xsl:template>
This is kind of explained in the XSLT Recommendation at
http://www.w3.org/TR/xslt#function-key, right at the end of that section.
I hope that helps,
Jeni
Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 • Fax 0115 9061304 • Email
jeni.tennison@epistemics.co.uk
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list