License Public Domain
Lines 1
Keywords
capitalize (1) lxml (1) xpath (1)
Permissions
Owner: Stou S.
Viewable by Everyone
Editable by All Siafoo Users
Hide
Siafoo is here to make coding less frustrating and to save you time. Join Siafoo Now or Learn More

Capitalize a string in XSLT Atom Feed 0

In Brief A somewhat hakish way of capitalizing the first character of a string inside an XSLT transform, that is turn 'foo' into 'Foo'. Supposedly XPath has a function fn:capitalize that can be used instead of the translate method above, however I am using lxml and it doesn't seem to support that function.... more
# 's
1<xsl:value-of select="concat(translate(substring(../bar,1,1), 'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ'), substring(../bar,2))"/>

A somewhat hakish way of capitalizing the first character of a string inside an XSLT transform, that is turn 'foo' into 'Foo'. Supposedly XPath has a function fn:capitalize that can be used instead of the translate method above, however I am using lxml and it doesn't seem to support that function.

Some of the information was found here: http://www.stylusstudio.com/xsllist/200001/post40240.html

Comments

over 8 years ago (14 Jun 2008 at 05:12 PM) by David Isaacson
*somewhat* hackish?!?
over 8 years ago (14 Jun 2008 at 11:28 PM) by Stou S.
You are more then welcome to post your own, cleaner, better version =)