Chris
One way is the use of xsl:key
First you define a key at the top level of the stylesheet:
{xsl:key name="text-to-be-fetched" select="*[@ID]" use="@ID"/}
Now you can use the key() function.
A key is always applied to the current context.
So, the only thing to do is to change the context.
This can be done using {xsl:for-each}
{xsl:variable name="LookupID" select="AnID-ofTheElementYouWantToLookup"/}
{xsl:for-each select="document('YourLookupDocument')"}
{xsl:value-of select="key('text-to-be-fetched',$LookupID)"/}
{/xsl:for-each}
hope this helps.
Rudolf P. Weinmann
Senior Consultant
Innovation Process Technology Inc.
http://www.ipt.ch
From: "Vittorio Viarengo"
Chris,
I just did something similar (with the help of our talented engineering team
of course :) but I'm not sure it is the same. Anyway, here it is
I needed to use a string table (modeled in XML and saved into a file called
string_table_english.xml which contains an ID attribute for quick lookup of
strings) from within a stylesheet front_page.xsl applied to another XML file
(news.xml).
In front_page.xsl I used this instruction to load the string table.
{xsl:variable name="st"
select="document('pictures:/string_table_engligh.xml')/STRING_TABLE/STRING"/
}
this creates a node set containing all the strings from the
'string_table_engligh.xml' file.
Then I used the string table inside the stylesheet this way
{xsl:value-of select="$st[@ID='there_are']"/}
In this way you load the data at the beginning and then you use it inside
the stylesheet. Having the ID declared an as ID element should speed up the
look up.
You can also change the document you are including at any given execution of
the stylesheet by using a parameter in the document function
{xsl:variable name="string_table_file"}
{xsl:choose}
{xsl:when
test="$language='English'"}pictures:/string_table_english.xml{/xsl:when}
{xsl:when
test="$language='Italiano'"}pictures:/string_table_italian.xml{/xsl:when}
{/xsl:choose}
{xsl:variable name="st"
select="document($string_table_file)/STRING_TABLE/STRING"/}
Another way of doing it is to use the document function every time you need
to access data from the other file.
{xsl:value-of
select="document('pictures:/string_table_english.xml')/STRING_TABLE/STRING[@
ID='there_are']"/}
Ciao
Vittorio
On 5/21/01 10:42:28 AM, Chris Longfield wrote:
>
>Here is a simple question:
>How do I use two different
>documents with one stylesheet
>to produce another XML
>document?
>For example, say I have
>produced a sorted list of id's
>in some XML format, and now I
>want to search a tree of items
>that correspond to these id's.
>
>I would probably want to apply
>the stylesheet to the document
>that has the in-depth
>information, so the id set
>might come in as a parameter.
>(Is this the right way?)
>
>If so, how do I apply an xpath
>expression to some parameter
>that holds a node set?
>
>xsl:foreach select=???
>
>If not, what is the best way
>to do it?
>
>Also, I am testing out 3.0 (I
>have rc3 and some 3.0 version
>of stylus studio) Does this
>change my approach?
>
>Chris Longfield
>clongfield@merrilhall.com