Subject: Re: [xsl] Changing case using translate() From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Date: Thu, 15 Feb 2001 17:46:12 +0000 |
Hi Andrew, > The code > > TBD/business[contains(translate(*[local-name() = $param1],$lowercase, > $uppercase),translate($param2, $lowercase, $uppercase)] > > works fine if there is only one child element of business, such as > 'name'. However, each business node currently contains several > <keyword> child nodes, that don't get picked up by the above. If I > reduce the number of <keyword> nodes to one (for each business node) > then it searches no problem. Oh. That's different then, but actually it's a problem to do with the contains() rather than the translate() - the contains() forces the first argument to be a string, so within contains(): *[local-name() = $param1] will only pick the value of the *first* of business's children called $param1. To get the effect you want, you actually want to look at all the business elements, and select those for which there is any child element called $param1 such that their value contains $param2 (case insensitively). Repeating that more slowly so that we can build an XPath: all the business elements: TBD/business for which there is any child element called $param1: TBD/business[*[local-name() = $param1]] such that their value contains $param2: TBD/business[*[local-name() = $param1][contains(., $param2)]] (case insensitively): TBD/business[*[local-name() = $param1] [contains(translate(., $lowercase, $uppercase), translate($param2, $lowercase, $uppercase))]] You could cut down on the size of this a bit (and improve its efficiency) by getting a capitalised version of $param2 defined separately: <xsl:variable name="PARAM2" select="translate($param2, $lowercase, $uppercase)" /> and then: TBD/business[*[local-name() = $param1] [contains(translate(., $lowercase, $uppercase), $PARAM2)]] I hope that helps, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Changing case using trans, Andrew Welch | Thread | [xsl] context, Jo Bourne |
RE: [xsl] xsl:include still a probl, Michael Kay | Date | Re: [xsl] Cropping results - count(, Jeni Tennison |
Month |