Re: [xsl] the "use" parameter for a key is to be a path expression

Subject: Re: [xsl] the "use" parameter for a key is to be a path expression
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Wed, 27 Feb 2002 17:49:57 +0000
Hi Tom,

> You were right about the leading and trailing spaces, but I'm
> intruiged that you say that the use parameter for a key has to be an
> XPath expression: in that case what about all the examples I have
> seen using concat(@this,'+',@that)?

The XPath:

  concat(@this, '+', @that)

*is* an expression. Possibly you (or Tom P?) are confusing the general
term "expression" with the more specific term "path expression" - a
path expression is just one kind of expression, function calls are
another, literal strings are another and so on. The use attribute
takes an expression, which can be any of those sorts of expression.

(Check and if you don't believe me!)


<xsl:key name="billcodes" match="Billcode"
         select="concat(@corp, '+', @country)" />

Should be just fine, though given your whitespace issues, probably:

<xsl:key name="billcodes" match="Billcode"
         select="concat(normalize-space(@corp), '+',
                        normalize-space(@country))" />

Would be safer! That should enable you to do:

  key('billcodes', 'EvilEmpire+USA')

to get back the Billcode elements whose @corp attribute has the value
'EvilEmpire' (or even '  EvilEmpire   ') and whose @country attribute
has the value 'USA' (or, again, ' USA ').



Jeni Tennison

 XSL-List info and archive:

Current Thread