web analytics

XSLT String Functions

Options

codeling 1595 - 6639
@2016-01-03 12:29:26
Name Description
string(arg) Returns the string value of the argument. The argument could be a number, boolean, or node-set

Example: string(314)
Result: "314"

codepoints-to-string(int,int,...) Returns a string from a sequence of code points

Example: codepoints-to-string(84, 104, 233, 114, 232, 115, 101)
Result: 'Thérèse'

string-to-codepoints(string) Returns a sequence of code points from a string

Example: string-to-codepoints("Thérèse")
Result: 84, 104, 233, 114, 232, 115, 101

codepoint-equal(comp1,comp2) Returns true if the value of comp1 is equal to the value of comp2, according to the Unicode code point collation (http://www.w3.org/2005/02/xpath-functions/collation/codepoint), otherwise it returns false
compare(comp1,comp2)
compare(comp1,comp2,collation)
Returns -1 if comp1 is less than comp2, 0 if comp1 is equal to comp2, or 1 if comp1 is greater than comp2 (according to the rules of the collation that is used)

Example: compare('ghi', 'ghi')
Result: 0

concat(string,string,...) Returns the concatenation of the strings

Example: concat('XPath ','is ','FUN!')
Result: 'XPath is FUN!'

string-join((string,string,...),sep) Returns a string created by concatenating the string arguments and using the sep argument as the separator

Example: string-join(('We', 'are', 'having', 'fun!'), ' ')
Result: ' We are having fun! '

Example: string-join(('We', 'are', 'having', 'fun!'))
Result: 'Wearehavingfun!'

Example:string-join((), 'sep')
Result: ''

substring(string,start,len)
substring(string,start)
Returns the substring from the start position to the specified length. Index of the first character is 1. If length is omitted it returns the substring from the start position to the end

Example: substring('Beatles',1,4)
Result: 'Beat'

Example: substring('Beatles',2)
Result: 'eatles'

string-length(string)
string-length()
Returns the length of the specified string. If there is no string argument it returns the length of the string value of the current node

Example: string-length('Beatles')
Result: 7

normalize-space(string)
normalize-space()
Removes leading and trailing spaces from the specified string, and replaces all internal sequences of white space with one and returns the result. If there is no string argument it does the same on the current node

Example: normalize-space(' The   XML ')
Result: 'The XML'

normalize-unicode()  
upper-case(string) Converts the string argument to upper-case

Example: upper-case('The XML')
Result: 'THE XML'

lower-case(string) Converts the string argument to lower-case

Example: lower-case('The XML')
Result: 'the xml'

translate(string1,string2,string3) Converts string1 by replacing the characters in string2 with the characters in string3

Example: translate('12:30','30','45')
Result: '12:45'

Example: translate('12:30','03','54')
Result: '12:45'

Example: translate('12:30','0123','abcd')
Result: 'bc:da'

escape-uri(stringURI,esc-res) Example: escape-uri("http://example.com/test#car", true())
Result: "http%3A%2F%2Fexample.com%2Ftest#car"

Example: escape-uri("http://example.com/test#car", false())
Result: "http://example.com/test#car"

Example: escape-uri ("http://example.com/~bébé", false())
Result: "http://example.com/~b%C3%A9b%C3%A9"

contains(string1,string2) Returns true if string1 contains string2, otherwise it returns false

Example: contains('XML','XM')
Result: true

starts-with(string1,string2) Returns true if string1 starts with string2, otherwise it returns false

Example: starts-with('XML','X')
Result: true

ends-with(string1,string2) Returns true if string1 ends with string2, otherwise it returns false

Example: ends-with('XML','X')
Result: false

substring-before(string1,string2) Returns the start of string1 before string2 occurs in it

Example: substring-before('12/10','/')
Result: '12'

substring-after(string1,string2) Returns the remainder of string1 after string2 occurs in it

Example: substring-after('12/10','/')
Result: '10'

matches(string,pattern) Returns true if the string argument matches the pattern, otherwise, it returns false

Example: matches("Merano", "ran")
Result: true

replace(string,pattern,replace) Returns a string that is created by replacing the given pattern with the replace argument

Example: replace("Bella Italia", "l", "*")
Result: 'Be**a Ita*ia'

Example: replace("Bella Italia", "l", "")
Result: 'Bea Itaia'
tokenize(string,pattern) Example: tokenize("XPath is fun", "\s+")
Result: ("XPath", "is", "fun")
@2016-01-03 12:40:17

starts-with() Function

If an argument is not of type string, it is first converted to a string using the string() function and then the result of that conversion is evaluated.

This function is case-sensitive.

Comments

You must Sign In to comment on this topic.


© 2024 Digcode.com