Subject: Re: [xsl] [solved] key with many uses's From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Thu, 7 Feb 2002 10:57:37 +0000 |
Hi Elizabeth, > Try this: > > <xsl:for-each select="$nodes[generate-id(.) = > generate-id(key('special-phones', string(@description, @paren, > @description-place))[1])]"> I think you meant concat() rather than string() there? The string() function can only take one argument. concat() will concatenate the values of the @description, @paren and @description-place attributes together into one long string, which will be different for every combination of @description, @paren and @description-place. > Why does this work as opposed to > > <xsl:for-each select="$nodes[generate-id(.) = > generate-id(key('special-phones', @description | @paren | > @description-place)[1])]"> @description | @paren | @description-place creates a node set of (up to) three nodes - description, paren, and description-place attributes. When the second argument to key() is a node set, it's equivalent to calling the key with the string values of each of those nodes individually, and unioning the results together. In other words: key('special-phones', @description | @paren | @description-place) is roughly equivalent (assuming that all three attributes are present) to: key('special-phones', @description) | key('special-phones', @paren) | key('special-phones', @description-place) So what the key returns is a set of nodes that share *any* of the values of @description, @paren, @description-place with the node you're looking at (compared to with concat(), where you get those nodes that share *all* the values). Which is why it doesn't work. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] [solved] key with many us, Elizabeth Barham | Thread | [xsl] weird think with saxon, Jakub . Valenta |
Re: [xsl] converting attributes to , Jeni Tennison | Date | RE: [xsl] Grouping conditions, Michael Kay |
Month |