[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Understanding xsl:key
Hello, I've got trouble understanding the proper use of xsl:key and the key() function. Here's my XML-File: <booklist> <book> <title> <name>Design Patterns</name> </title> <author>Erich Gamma</author> <author>Richard Helm</author> <author>Ralph Johnson</author> <author>John Vlissides</author> </book> <book> <title> <name>Pattern Hatching</name> </title> <author>John Vlissides</author> </book> <book> <title> <name>Building Applications</name> </title> <author>Mohamed Fayad</author> <author>Douglas C. Schmidt</author> <author>Ralph Johnson</author> </book> </booklist> Here's the XSL: <xsl:key name="test" match="title" use="name"/> <xsl:template match="booklist"> <booklist> <xsl:apply-templates/> </booklist> </xsl:template> <xsl:template match="book"> <xsl:if test="key('test','Pattern Hatching')"> <node> <xsl:value-of select="."/> <xsl:text> -EndOfKeyValue-</xsl:text> </node> </xsl:if> </xsl:template> Now, I'd expect the xsl:if to make sure only "name" elements that are children of "title" and have the content "Pattern Hatching" are shown. Instead, I get ALL contents, including the author names; only the various "book" contents are (naturally) placed into single "node" elements. Now, to make a long question short: WHY??? :) Thanks, Heiner (who's read all "key"-explanations that he could find, but just seems to get something wrong) 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
|