Re: [xsl] First character in a word as capital-letter.

Subject: Re: [xsl] First character in a word as capital-letter.
From: andrew welch <andrew.j.welch@xxxxxxxxx>
Date: Tue, 13 Sep 2005 10:18:13 +0100
On 9/13/05, Dariusz Borowski <d.borowski@xxxxxx> wrote:
>
> Hi!
>
> Could anyobdy tell me if there is a function in xpath which can make the
first character in a word as a capital-letter.
>
> e.g.
> - closed
> (should be written as)
> - Closed

define two variables:

<xsl:variable name="uppercase" select="'ABC..XYZ'"/>
<xsl:variable name="lowercase" select="'abc..zyz'"/>

(but write out the whole alphabet)

then use:

<xsl:value-of select="concat(translate(substring(., 1, 1), $lowercase,
$uppercase), substring(.,2))"/>

If your target output is HTML then there's a CSS instruction that can do it.

cheers
andrew

Current Thread