XSLT Stylesheet: Changing text to upper case

Charmiane picture Charmiane · Jul 30, 2009 · Viewed 60.1k times · Source

I am using an XSLT stylesheet to create an Excel document from an XML file. One of the values that I am pulling in I want to display as upper case. How is this possible?

Answer

David Christiansen picture David Christiansen · Jul 30, 2009

XSLT 2.0 has fn:upper-case() and fn:lower-case() functions. However in case you are using of XSLT 1.0, you can use translate():

<xsl:template match="/">
  <xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
  <xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
  <xsl:value-of select="translate(doc, $smallcase, $uppercase)" />
</xsl:template>