[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: 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: > > B Upper Case: UPPER CASE > B Lower Case: lower case > B Title Case: Title Case > > Regards, > > Ramkumar > R&D - Software Engineer > PreMedia Global Ltd -- Regards, Mukul Gandhi
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|