[xsl] key with many uses's

Subject: [xsl] key with many uses's
From: Elizabeth Barham <soggytrousers@xxxxxxxxx>
Date: 06 Feb 2002 11:01:11 -0600
Hi,

I have a series of elements that I would like to group based on more
than one parameter.

1. <phone>713-228-XXXX</phone>
2. <phone type="fax">713-228-XXXX</phone>
3. <phone type="special" description="clients" paren="1" description-place="before">713-228-XXXX</phone>
4. <phone type="special" description="AIDS legal hotline:" paren="0" description-place="before">713-528-XXXX</phone>
5. <phone type="special" description="AIDS legal hotline:" paren="0" description-place="before" >800-528-XXXX</phone>

In this example, I'd like to somehow get both 4 and 5 together. I've
considered using three keys:
	
<xsl:key name="special-phone-d" match="phone[@type='special']" use="@description"/>
<xsl:key name="special-phone-p" match="phone[@type='special']" use="@paren"/>
<xsl:key name="special-phone-w" match="phone[@type='special']" use="@description-place"/>

and one key:

<xsl:key name="special-phone" match="phone[@type='special']" use ="@description | @paren | @description-place" />

Using the Muenchian Method it'd be something like this using the three
keys:

<xsl:for-each select="$nodes[generate-id(.)] = generate-id(key('special-phone-d', @description)[1])]
	and
	$nodes[generate-id(.)] = generate-id(key('special-phone-p', @paren)[1])
	and
	$nodes[generate-id(.)] = generate-id(key('special-phone-w', @description-place)[1])">

But from here, how do I get the group? ($nodes is passed in as a
parameter and makes up the phone elements themselves).

Would it be something like:

<xsl:value-of select="key('special-phone-p', @paren) and key('special-phone-d', @description) and key('special-phone-w', @description-place)" />

Thank you for any help! :-)

Elizabeth

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


Current Thread