lower case the first character of a string using only xslt 1.0
Asked Answered
S

4

11

I have seen patterns for translating a string into lower (or upper case) using the translate function for folks stuck using xslt 1.0.

Is there a elegant way of just making the first letter of a string lowercase?

TestCase => testCase
Stitching answered 17/3, 2009 at 17:37 Comment(0)
M
14

If your string were, for example, in an attribute called name:

<xsl:value-of select="concat(translate(substring(@name, 1, 1), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'), substring(@name, 2))"/>
Martlet answered 17/3, 2009 at 17:48 Comment(0)
A
3

You should be able to combine substring and concat with translate to do it like so:

concat(translate(substring(s,1,1), $smallcase, $uppercase),substring(s,2))
Abnormality answered 17/3, 2009 at 17:44 Comment(0)
I
0

Use the XPath translate function, having separated the string into first character and the rest. This will require somewhat long winded XSLT using multiple variables to hold intermediate results.

Intravasation answered 17/3, 2009 at 17:40 Comment(0)
I
0

XSLT has a substring function, so you could use that pattern with the substring function to get what you want.

Inhuman answered 17/3, 2009 at 17:41 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.