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

Problem with key()

Subject: Problem with key()
From: Kevin Burges <xmldude@xxxxxxxxxxxxxxxx>
Date: Fri, 25 May 2001 12:56:36 +0100
datastructure problems
I'm trying to use keys from an external document, and having problems. Here's the relevant XSLT:

<!-- 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"/>

<xsl:template match="field">
   <!-- keep a note of current location -->
   <xsl:variable name="currentlocation" select="."/>
   
   <!-- change context to the external document -->
   <xsl:for-each select="document('datastructure.xml')">
      <xsl:variable name="length"><xsl:value-of select="key(fieldlength, $currentlocation/@name)"/></xsl:variable>
      <!-- other stuff in here -->
   </xsl:for-each>
</xsl:template>


When processing, I am given an error saying:
   "An empty string '' is not a valid name"

If I comment out the bit that sets the @length variable, it works fine, so presumably this is what's causing the problem.

The format of the external file is:
<datastructure>
   <file>
      <group>
         <field name="a0" length="2"/>  (@name mandatory, @length optional)
      </group>
   </file>
</datastructure>

The format of the <field> element in the document being processed is:
<field name="a0"/>  (@name mandatory)


What is causing this not to work?


-- 
May the flares be with you,
 Kevin                    mailto:xmldude@xxxxxxxxxxxxxxxx

++++++++++++ Cool music - http://mp3.com/marshan
++++++ Attitude Webzine - http://burieddreams.com/attitude



 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.