XSLT and XPath function reference in alphabetical order
(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)
String functions – analysis and manipulation
A xs:string string; a copy of the input string within which originally included lower case letters are replaced by corresponding upper case letters.
A xs:string string in which the included lower case letters are replaced by corresponding upper case letters. If the empty sequence is passed on to the function, it returns an empty string.
Purpose of use:
The fn:upper-case() function completely converts all lower case letters in the input string to the corresponding upper case letters for the output string. The conversion is not reversible!
If a string is passed on to the function, the upper case letter corresponding to the lower case letter is determined for the character replacement according to the rules for Unicode case mapping. In case there is no corresponding upper case letter for a lower case letter (for example: the German letter ß), no replacement is made. Digits, punctuation marks and other non-letter characters are also not affected.
The appropriate rules can be found in the Unicode Standard. The mapping of the letters is performed by means of a table which contains the corresponding characters. Here an excerpt:
# preceding further mappings
005F;LOW LINE; Pc;0;ON;;;;;N;SPACING UNDERSCORE;;;;
0060;GRAVE ACCENT; Sk;0;ON;;;;;N;SPACING GRAVE;;;;
0061;LATIN SMALL LETTER A; Ll;0;L;;;;;N;;;0041;;0041
0062;LATIN SMALL LETTER B; Ll;0;L;;;;;N;;;0042;;0042
# further mappings
03C1;GREEK SMALL LETTER RHO; Ll;0;L;;;;;N;;;03A1;;03A1
03C2;GREEK SMALL LETTER FINAL SIGMA;Ll;0;L;;;;;N;;;03A3;;03A3
03C3;GREEK SMALL LETTER SIGMA; Ll;0;L;;;;;N;;;03A3;;03A3
03C4;GREEK SMALL LETTER TAU; Ll;0;L;;;;;N;;;03A4;;03A4
# in the following futher mappings
In Unicode, letters are classified in the category L (»Letter«) which is divided into different subgroups 'L&' (& is a placeholder). For all characters marked in the middle column with 'Ll' (»Letter, lowercase«) exists a corresponding character which represents its uppercased variant 'Lu' (Letter, uppercase). The single 'L' (column 5) marks the Bidi class (Bidirectional Behavior) »left-to-right«.
Attention: »titlecaps« are no upper case letters!
A further category 'Lt' (»Letter, titlecase«) provides for all alphabetical characters the same glyphs irrespective of their case sensitivity. This category should not be confused with upper case letters. The information on the notation is still included in a string converted to titlecaps. However, when converting upper case letters to lower case letters or vice versa, the information on the original notation gets lost.
The Greek lower case letter sigma, ς (U+03B2) and σ (U+03B3), existing in two variants (for the usage within or at the end of a word) is mapped each on the same upper case letter Σ (U+03A3).
A correct character replacement is language-dependent. Not all characters of all languages are assigned to the category L, which means they partially do not apply a priori the concept of upper case/lower case letters. But also in languages which (for the most part) are written with the normal Latin alphabet, the conversion is inconsistent in a cross-language way: So, the »normal« small i in Turkish corresponds to the capital dotted İ, in contrast the »normal« capital I corresponds to the undotted ı.
Alternative: conversion during the presentation
If the text shall be presented in upper case letters by using XSL-FO or CSS, the text-transform="uppercase" property can be applied. By using this method, the representation as upper case letters is achieved without any real conversion, which means without loss of information.
Example – converting lower case letters to upper case letters:
results in: ABCD0.
Characters already contained as upper case letters in the string (in this example the C) and non-alphabetic characters (like the 0) are not affected by the conversion. It is not possible to reverse the conversion since no information on the previous condition of the string is stored.
The function is not available.
fn:upper-case($arg as xs:string?) as xs:string
|<< back||next >>|
Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany