xml editor

Supported platforms

Compatible with Windows7 & Mac OS X Snow Leopard

Ready for data server software
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] NodeTest expected here - problem with creating xsl:key from document(url)


Subject: Re: [xsl] 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

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
Keywords
XML Editor | XML Author | WYSIWYG Editors | Schema Editor | XSD Documentation | XSL/XSLT Editor | XQuery | XML Databases | SVN Client
© 2002-2011 SyncRO Soft Ltd. All rights reserved. | Sitemap | Privacy Policy | This website was created & generated with <oXygen/>®XML Editor