This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]