[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

using document() function in match attribute of xsl:ke

Subject: 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
using document function in xslt
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.