This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Capitalizing content of a variable
- To: XSL List <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] Capitalizing content of a variable
- From: Joerg Pietschmann <joerg dot pietschmann at zkb dot ch>
- Date: Thu, 09 Aug 2001 10:29:54 +0200
- Organization: ZKB
- Reply-To: xsl-list at lists dot mulberrytech dot com
"Nitin Dutt Mathur" <nitin@pscindia.com> 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="'äöü'"/>
<xsl:variable name="upper" select="'ÄÖÜ'"/>
HTH
J.Pietschmann
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list