[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: the "use" parameter for a key is to be a path expr

Subject: Re: 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
xsl key parameter
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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.