This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Understanding xsl:key


From Jeni's reply
When you define the key:

> <xsl:key name="test" match="title" use="name"/>

Then you are setting up a number of associations between 'title' nodes and
key values given to them through their 'name' child:

node		key value
title[1]	'Design Patterns'
title[2]	'Pattern Hatching'
title[3]	'Building Applications'

When you use:

  key('test', 'Pattern Hatching')

you are saying "What nodes within the 'test' key have the key value of
'Pattern Hatching'?"

So
<xsl:key name="test" match="title" use="substring-before(name, ' ')"/>
will create 
node		key value
title[1]	'Design'
title[2]	'Pattern'
title[3]	'Building'

I assume though I haven't tried it.

Ciao Chris

XML/XSL Portal 
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@mulberrytech.com
>[mailto:owner-xsl-list@mulberrytech.com]On Behalf Of Heiner de Wendt
>Sent: 21 August 2000 10:18
>To: xsl-list@mulberrytech.com
>Subject: Re: Understanding xsl:key
>
>
>Hello,
>
>Jeni and everyone else, big thanks for the help. I've understood the 
>beast now, I think ;-)
>
>I have one last problem with it, though. If I use, e.g.,
>
><xsl:apply-templates select="key('test','Pattern Hatching')"/>
>
>this selects all my appropriate nodes with "Pattern Hatching" as
>contents. But if I wanna select all nodes in which the word "Pattern" 
>appears, I don't know how to do it. I've tried 
>"key('test',contains(.,'Pattern'))" and some other things like that, 
>but I don't get it to work.
>
>Big thanks again,
>
>Heiner
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]