Subject: RE: [xsl] Changing case using translate() From: "Andrew Welch" <andrew@xxxxxxxxxxxxxxxxxxxxxxx> Date: Thu, 15 Feb 2001 14:29:45 -0000 |
Thanks, that works perfectly - however I have one further, slightly un-related issue: 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. <business> ..... <keyword>A</keyword> <keyword>B</keyword> </business> Searching for 'A' on the above xml produces no results. <business> ..... <keyword>A</keyword> </business> However, searching for 'A' here returns the required result because there is only a single <keyword> element. Is this a problem with the structure of my xml files, or is there a way of modifying the search line to take into account multiple elements with the same name??? Thanks once again for all the help Andrew -------- Hi Andrew, > As I understand it, case conversion is done using > > translate(xxxx,abcdefghijklmnopqrstuvwxyz,ABCDEFGHIJKLMNOPQRSTUVWXYZ) Well, you have to have quotes around the alphabets so that they're recognised as strings, but basically you're right. To save time, I'd save the alphabets in variables: <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" /> <xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz'" /> > Im trying to incorporate it into the following line of code, to allow > case-independant searching: > > <xsl:for-each select="TBD/business[contains(*[local-name() = $param1], $param2)]"> > > By converting both params to uppercase it should allow, for example, > 'rising' to match 'Rising Sun'. They should go around both of the values that you're comparing. You don't want to translate $param1 because that will change which child of the business element you're testing. Rather, you want to translate: *[local-name() = $param1] (i.e. the value of the business element's child called $param1) with: translate(*[local-name() = $param1], $lowercase, $uppercase) The second value is $param2, so changing that to uppercase can be done with: translate($param2, $lowercase, $uppercase) Putting this together, you get the select expression: TBD/business[contains(translate(*[local-name() = $param1], $lowercase, $uppercase), translate($param2, $lowercase, $uppercase))] 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, Jeni Tennison | Thread | Re: [xsl] Changing case using trans, Jeni Tennison |
[xsl] RE: syntax sugar for call-tem, Dimitre Novatchev | Date | Re: [xsl] context, Michael Beddow |
Month |