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

Re: Problem with key()

Subject: Re: Problem with key()
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Fri, 25 May 2001 14:28:31 +0100
xsl key function namespace problems
Hi Kevin,

There are a couple of problems here:

> <!-- define a key of lengths, only including instances where the
> length is specified -->
> <xsl:key name="fieldlength"
>          match="/file/group/field/@length[@length]"
>          use="@name"/>

The match pattern here will match length attributes (on field elements
that are children of group elements that are children of the 'file'
document element) which have a length attribute.  Since attributes
can't have attributes, it'll never match any nodes, so you won't get
anything from the key.  I think you meant:

<xsl:key name="fieldlength" match="field[@length]" use="@name" />

(Although if field elements might reside under things other than group
elements, then you might want to make it more specific.)

The problem that's causing the error you're getting, though, is:

> <xsl:value-of select="key(fieldlength, $currentlocation/@name)"/>

The first argument to the key function should be a string.  You're
missing quotes:

  <xsl:value-of select="key('fieldlength', $currentlocation/@name)" />

Since you haven't used quotes, the XSLT processor will interpret the
first argument as a path to the fieldlength element under the current
node - so unless the document element of 'datastructure.xml' is called
'fieldlength', it'll return an empty node set, which will be converted
to an empty string, hence the error message.

I hope that helps,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/



 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.