Subject: [xsl] Problem with key() From: Kevin Burges <xmldude@xxxxxxxxxxxxxxxx> Date: Fri, 25 May 2001 12:56:36 +0100 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Re:Re:How to robustly han, Jeni Tennison | Thread | Re: [xsl] Problem with key(), Jeni Tennison |
RE: [xsl] Using variables in xsl:so, Michael Kay | Date | RE: [xsl] XLST including image in H, Michael Kay |
Month |