This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: the "use" parameter for a key is to be a path expression
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: TSchutzerWeissmann at uk dot imshealth dot com
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 27 Feb 2002 17:49:57 +0000
- Subject: Re: [xsl] the "use" parameter for a key is to be a path expression
- Organization: Jeni Tennison Consulting Ltd
- References: <9723092BA4DBD111816D0000F6B093610C27E628@imsuklndsx1.lnd.uk.imshealth.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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 http://www.w3.org/TR/xslt#key and
http://www.w3.org/TR/xpath#NT-Expr if you don't believe me!)
So:
<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 ').
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list