[xsl] using document() function in match attribute of xsl:key element- possible?

Subject: [xsl] using document() function in match attribute of xsl:key element- possible?
From: Mike McGraw <mmcgraw@xxxxxxx>
Date: Thu, 10 May 2001 12:30:32 -0400
I would like to access elements from a static xml file in addition to
processing the xml source tree. 

Let's assume I have an xml source tree, but I also want to construct a list
of people of a certain shirt size within my html output, and this people
data is stored in a static xml file called people.xml.
Let's say the xml looks like this:


<?xml version="1.0"?>
<!-- people.xml -->
<data>
	<person size="M">George</person>
	<person size="L">Fred</person>
	<person size="M">Jill</person>
	<person size="S">Kim</person>
	<person size="M">Jack</person>
</data>

I had thought I could create a key element in my stylesheet like this:

<xsl:key name="people" match="document('people.xml')/data/person"
use="@size"/>

and then later in the stylesheet, to display a list of all people who wear
medium size shirts, I would do this:

<xsl:for-each select="key('people','M')">
<xsl:value-of select="."/><br/>
</xsl:for-each>


I had hoped my output would be:
George
Jill
Jack



However, this doesn't work. The XSL processor complains about the document()
function in the key's match attribute. Is there a way I can create a key
that references a node set from a static xml file? My apologies if this
question doesn't make sense; I haven't been at this xslt stuff very long =)



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


Current Thread