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

RE: Capitalizing content of a variable

Subject: RE: Capitalizing content of a variable
From: Joerg Pietschmann <joerg.pietschmann@xxxxxx>
Date: Thu, 09 Aug 2001 10:29:54 +0200
xml translate and substring concat
"Nitin Dutt Mathur" <nitin@xxxxxxxxxxxx> wrote:
[snip]
> <component ..>
> <xsl:variable name="foo">
> <!-- do dome processing to get the value of variable-->
> </xsl:variable>
> <!-- At this point I want to have the capitalize value of the contents of
> foo variable (may be in same variable or in some other variable. -->
> </component>
> 
> Since at the time of transforming the contents of variable I don't know the
> exact contents hence I unable to figure out how to use translate function.
> 
You have to split the string using substring(), translate the substring
containing the first character, and concat the results.
Try
  <xsl:variable name="bar"
    select="concat(translate(substring($foo,1,1),'abc...','ABC...'),
                   substring($foo,2))"/>

In order to keep it more readable, often variables are declared
and used for the constant strings:
  <xsl:variable name="lower" select="'abc...'"/>
  <xsl:variable name="upper" select="'ABC...'"/>
  ...
    translate(...,$lower,$upper)
  ...

You may also include non-ASCII characters in the translation string, if
necessary. The following can be used to upcase german umlauts:
  <xsl:variable name="lower" select="'&#xE4;&#xF6;&#xFC;'"/>
  <xsl:variable name="upper" select="'&#xC4;&#xD6;&#xDC;'"/>
  
HTH
J.Pietschmann

 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-2013 All Rights Reserved.