Re: [xsl] key with many uses's

Subject: Re: [xsl] key with many uses's
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 06 Feb 2002 12:40:01 -0500
Hi Elizabeth,

Instead of your one key

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

try


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

That will set the key value to be unique for every combination of @description, @paren, @description-place. (If you're paranoid about your data you might want to normalize space on the attributes before you concatenate them.) [ <= note to Eudora users: "you're paranoid..." gets you two hot peppers, with an extra one for repeating it.]

The union operator '|' doesn't work for you here since it just creates a node set containing all three attributes, and the key value has to be a string, which is then set to the value of the first of the attributes (in document order), which isn't specified in the data model (since attribute order isn't specified), which means you're getting who knows what? (But not what you want. :-)

I hope that helps,
Wendell


====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================


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



Current Thread