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 – codepoint conversion
A string xs:string.
The input value is a sequence from any number of integer values which are interpreted separately as Unicode codepoints. The codepoints converted into Unicode characters are returned concatenated in the form of a xs:string character string. If the input sequence is empty, an empty string is returned. If the conversion of one of the codepoints passed on in the sequence results in a character not permitted in XML (see: W3C XML 1.0 Recommendation), the error message »Code point not valid« (err:FOCH0001) is outputted.
Purpose of use:
The fn:codepoints-to-string() function generates a Unicode character (abstract character) from the integer which corresponds to its codepoint. The principle equates to the one of a character reference – for example £, whereby the numeric part 163 corresponds to the Unicode codepoint. The codepoint may contain leading zeros which do not have to be passed on in this connection. £ is the £ character. The decimal codepoint 163 thus corresponds to the integer value 163 which could be, for example, an argument of the fn:codepoints-to-string function.
The counterpart to this function is fn:string-to-codepoints() which converts an input string into a sequence of codepoint integer values.
Example 1 - application to an individual codepoint:
results in the £ character. Since the input sequence only consists of one item, you can simply write 163 instead of (163) in this example. If the sequence consists of several items (example 2), this is not possible.
Example 2 - application to an input sequence of codepoints:
(72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33)
results in the string: Hello World!
Each integer value of the input sequence is interpreted as Unicode codepoint which is replaced by the appropriate character – for example the 72 (Unicode U+0072) is replaced by H. The resulting character string is concatenated to a single output string.
The function is not available.
fn:codepoints-to-string($arg as xs:integer*) 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