[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Upper-casing the first character of a string -- Am I mis

Subject: Re: Upper-casing the first character of a string -- Am I missing some thing?
From: Oliver Becker <obecker@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 1 Aug 2000 11:42:43 +0200 (MET DST)
first char to upper
> I need to upper-case the first character of a string contained in my 
> input XML prior to output.  I was wondering if there was a better way, 
> this seems a bit clunky:
> 
> <xsl:value-of select="translate(substring(@name, 1, 1), 
> 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')" />
> <xsl:value-of select="substring(@name, 2, string-length(@name) - 1)" />

I would say: if you don't want to use proprietary extensions - that's it!
Two points:
 - you may use one xsl:value statement and connect the strings by concat
 - you can omit the 3rd parameter of substring 

Thus you get
<xsl:value-of select="concat(translate(substring(@name, 1, 1),    
                                       'abcdefghijklmnopqrstuvwxyz', 
                                       'ABCDEFGHIJKLMNOPQRSTUVWXYZ'),
                             substring(@name, 2))" />

Is that less clunky?
... whatever that means - couldn't find it in my Muret-Sanders dictionary ;-)

Cheers,
Oliver


/-------------------------------------------------------------------\
|  ob|do        Dipl.Inf. Oliver Becker                             |
|  --+--        E-Mail: obecker@xxxxxxxxxxxxxxxxxxxxxxx             |
|  op|qo        WWW:    http://www.informatik.hu-berlin.de/~obecker |
\-------------------------------------------------------------------/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.