Re: Loading an external file of index

Subject: Re: Loading an external file of index
From: Pierre Attar <patt@xxxxxxxxx>
Date: Fri, 23 Jun 2000 11:58:49 +0200

Thanks a lot, it works. Also, sorry for all of this because you are right, it was in the XSLT spec.

So now, I'm happy because I have what I want ... but I have a little regret because I dont't understand why it works.

What does means this "for-each" as soon as I use it only to load a document ? Why not only ask to load the document using an "apply-template" for loading ? Does this "for-each" means that a processor needs to load and reparse all keys declarations each time ?

Also, I'm a little bit curious on performances : for now the document database is not so heavy. But let suppose, later having a 10 000 document database with something like 100 keyref in each document.
Would an XSL transformer need to load the shared file 100 times per document ? Even, looking at the syntax, would it need to load it, for each keyref element, as many times as needed before finding the right key in the shared document ?

I know this is a question of implementation but the syntax is hard to understand if someont wants to know what it really means.



At 12:29 22/06/2000 +0100, you wrote:
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="";
>        <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'

<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>

This is kind of explained in the XSLT Recommendation at, right at the end of that section.

I hope that helps,


Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email

XSL-List info and archive:

XSL-List info and archive:

Current Thread