[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Problem with key()
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
|
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
|