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

Re: NodeTest expected here - problem with creating xs

Subject: Re: NodeTest expected here - problem with creating xsl:key from document(url)
From: Trevor Nash <tcn@xxxxxxxxxxxxx>
Date: Tue, 27 Aug 2002 14:15:11 +0100
xpath nodetest expected here
On Mon, 26 Aug 2002 15:53:59 -0700, Chuck White wrote:

>...
><xsl:variable name="lookup" select="document('LookupTable.xml')" />
><xsl:key name="keyedLookupTable" match="LookupTable/Value" use="@key"/>

You might as well just say match="Value", unless you really do have
Value elements which are *not* children of a LookupTable and you want
to ignore them.

>
><xsl:value-of select="$lookup[key('keyedLookupTable' , $currentKey)]"/>
>...
Not quite.  This will either return an empty string or the string
value of the *whole* LookupTable.xml document, according to whether
there are any nodes in the document matching $currentKey.

You are executing the key() function in the right context, but
unfortunately there isn't a way of getting at the value: it is being
cast to a boolean which is then used to filter the node set $lookup,
which contains a single node which is the root node of the
LookupTable.xml document.

See Wendell's message for the right approach, using xsl:for-each.  Or
use XPath 2.0, where there is a pure XPath syntax for changing
context.

Trevor Nash
--
Traditional training & distance learning,
Consultancy by email

Melvaig Software Engineering Limited
voice:     +44 (0) 1445 771 271 
email:     tcn@xxxxxxxxxxxxx

 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.