|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Problem with key()
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








