Subject: RE: [xsl] String Case Conversion: Title Case From: "Ramkumar" <ramkumar@xxxxxxxxxxxxxxxxxx> Date: Wed, 7 Oct 2009 15:20:24 +0530 |
Hi Mukul, I got expected. Thanks a lot for your detailed explanation. Regards, Ramkumar, R&D - Software Engineer PreMedia Global Ltd -----Original Message----- From: Mukul Gandhi [mailto:gandhi.mukul@xxxxxxxxx] Sent: Wednesday, October 07, 2009 2:33 PM To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: [xsl] String Case Conversion: Title Case you might use a custom XSLT (2.0) function like below: <xsl:function name="my:titleCase" as="xs:string"> <xsl:param name="str" as="xs:string" /> <xsl:sequence select="string-join(for $x in tokenize($str,'\s') return concat(upper-case(substring($x, 1, 1)), lower-case(substring($x, 2))), ' ')" /> </xsl:function> and call it like: <xsl:value-of select="my:titleCase($str)" /> please make sure, that a namespace is declared as well (e.g, xmlns:my="http://www.example.com/myfuncs"). For e.g, this function when called with argument, heLLO worLD produces output: Hello World You could also think, about cultural issues as pointed by Mike. But I think, the above example could be a simple algorithm for transforming English phrases, where you just want to capitalize the first letter of the word, and keep rest of letters in the word as small case. On Wed, Oct 7, 2009 at 12:34 PM, Ramkumar <ramkumar@xxxxxxxxxxxxxxxxxx> wrote: > > Hi List, > > I have used upper-case and lower-case methods in xslt2.0. But I like > to know, how to convert Title-Case/Upper-Lower Case. Could any one > share with me the logic for this. > > Ex: > > Upper Case: UPPER CASE > Lower Case: lower case > Title Case: Title Case > > Regards, > > Ramkumar > R&D - Software Engineer > PreMedia Global Ltd -- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] String Case Conversion: T, Mukul Gandhi | Thread | [xsl] How to copy only the really e, Ben Stover |
RE: [xsl] String Case Conversion: T, Michael Kay | Date | Re: [xsl] Seed problem in FXSL rand, Jesper Tverskov |
Month |