Name

[2.0] upper-case()

Given a string, returns the uppercased version of that string.

Syntax

xs:string upper-case(xs:string?)

Inputs

An xs:string value.

Outputs

An xs:string in which all of the lowercase letters in the original string have been converted to uppercase. Any character that was originally in uppercase and any character that does not have an uppercase value is returned as is. If the value of the argument is the empty sequence, a zero-length string is returned.

Accented characters and other features of the world’s languages mean that changing the case of a string might change its length. Also be aware that upper-case() and lower-case() are not always the inverse of each other in some languages. All of the case-conversion rules are defined by the Unicode standard, and XSLT processors are expected to conform with those rules.

Defined in

XQuery 1.0 and XPath 2.0 Functions and Operators section 7.4, “Functions on String Values.”

Example

Here is a stylesheet that illustrates the upper-case() function. Notice that we’re using <xsl:output method="xml" encoding="UTF-8"/> to make sure the character set is handled properly:

<?xml version="1.0" encoding="UTF-8"?>
<!-- upper-case.xsl -->
<xsl:stylesheet version="2.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

  <xsl:template match="/">
    <testcase>
      <heading>Tests of the upper-case() function:</heading>
      <test>
        <label>upper-case('Lily') = </label>
 <result><xsl:value-of select="upper-case('Lily')"/></result> ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.