xslt 1.0 and upper/lower case

by assbach from flickr

When you have to manage upper/lower case and you are in XSLT 1.0, you have no other comfortable choices than using the translate function, here’s an example.

<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('goldrake',$lower,$upper)"/><!--GOLDRAKE-->
 <xsl:value-of select="translate('MAZINGA',$upper,$lower)"/><!--mazinga-->
 </xsl:template>
</xsl:stylesheet>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s