uppercase and lowercase functions XSLT/XPath

1,571 views
Skip to first unread message

R

unread,
Aug 4, 2005, 3:08:57 PM8/4/05
to xml and xslt
Hello everybody.

I've got a simple question.

I know that w3c recommendation does not support any functions for
dealing with uppercase and lowercase strings.

But maybe someone has a workaround for uppercase/lowercase functions?

thanks in advance for any help
cheers
R

Joris Gillis

unread,
Aug 4, 2005, 3:25:07 PM8/4/05
to xml-an...@googlegroups.com
Hi,
Tempore 21:08:57, die 08/04/2005 AD, hinc in xml-an...@googlegroups.com scripsit R <ruth...@poczta.onet.pl>:

> But maybe someone has a workaround for uppercase/lowercase functions?
When pure XSLT1.0 is the option, it is common to use the 'translate()' function:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:variable name="lower">abcdefghijklmnopqrstuvwxyz</xsl:variable>
<xsl:variable name="upper">ABCDEFGHIJKLMNOPQRSTUVWXYZ</xsl:variable>

<xsl:template match="/">
<xsl:value-of select="translate('foo',$lower,$upper)"/><!--FOO-->
<xsl:value-of select="translate('BAR',$upper,$lower)"/><!--bar-->
</xsl:template>

</xsl:stylesheet>

For real case-conversion, you should use an extension function. Check out exslt for example.

regards,
--
Joris Gillis (http://users.telenet.be/root-jg/me.html)
Spread the wiki (http://www.wikipedia.org)
Reply all
Reply to author
Forward
0 new messages