|
Subject: Understanding xsl:key From: "Heiner de Wendt" <H.dewendt@xxxxxxxxx> Date: Thu, 17 Aug 2000 12:42:10 +0200 |
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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: Indexing Tree Elements, G. Ken Holman | Thread | Re: Understanding xsl:key, Jeni Tennison |
| RE: "replies go to the list" policy, FINLEY, Mike | Date | Re: "replies go to the list" policy, v . rudowitsch |
| Month |