Show TOC

Background documentationFunctions: String Locate this document in the navigation structure

 

Functions with “*” are extended functions for the Electronic File Manager: Format Definition add-on.

Parameters suffixed with a question mark “?” have a default value and can be omitted.

string-length(string?)

Description: Returns the number of characters in the string.

Sample:

string-length("abcd") returns 4

local-name(node-set?)

Description: Returns the local part of the expanded name of the node in the node-set argument that is first in the document order.

Sample:

<?xml version = 1.0”?>

<Text>

<Persons>

<Person>A</Person>

<Person>B</Person>

<Person>C</Person>

</Persons>

</Text>

If the context node is Person A, local-name() would be “Person”.

namespace-uri(node-set?)

Description: Returns the namespace Uniform Resource Identifier (URI) of the expanded name of the node in the node-set argument that is first in the document order.

Sample:

<?xml version = 1.0”?>

<T: Text xmlns: T=x-schema:Text.xml”>

<Text>

<Persons>

<Person>A</Person>

<Person>B</Person>

<Person>C</Person>

</Persons>

</Text>

namespace-uri() would be “x-schema:Test.xml”.

name(node-set?)

Description: Returns a string containing a QName representing the expanded name of the node in the node-set argument that is first in the document order.

Sample:

<?xml version = 1.0”?>

<Text>

<Persons>

<Person>A</Person>

<Person>B</Person>

<Person>C</Person>

</Persons>

</Text>

If the context node is Person A, name() would be “Person”.

string(object?)

Description: Returns the string value of the argument, which could be a number, boolean, or node-set.

Sample:

string(314) returns “314”

concat(string, string, string?)

Description: Returns the concatenation of the strings.

Sample:

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

starts-with(string, string)

Description: Returns true if the first argument string starts with the second argument string; otherwise returns false.

Sample:

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

contains(string, string)

Description: Checks whether the first argument string contains the second argument string.

Sample:

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

substring-before(string, string)

Description: Returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string.

Sample:

substring-before("1999/04/01","/") returns “1999”.

substring-after(string, string)

Description: Returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string.

Sample:

substring-after("1999/04/01","/") returns “04/01”.

substring(string, number, number?)

Description: Returns the substring of the first argument starting at the position specified in the second argument and having the length specified in the third argument. Index begins from 1.

Sample:

substring("12345",2,3) returns “234”

substring("12345",2) returns “2345”

normalize-space(string?)

Description: Returns the argument string with the leading, trailing, and repeating white spaces stripped.

Sample:

normalize-space(" abc def ") returns “abc def”

translate(string, string, string)

Description: Returns the first argument string with occurrences of characters in the second argument string replaced by the character at the corresponding position in the third argument string.

Sample:

translate("bar","abc","ABC") returns “BAr”

*replace (string input, string from, string to)

Description: Returns a string that replaces argument 2 with argument 3 in argument 1.

Sample:

replace("hello", "h", "H") = “Hello”

*padding (number length, string padding)

Description: Returns a string filled with argument 2 and with length as argument 1. Sample: padding(10, “abc”) = “abcabcabca”

*align (string target, string padding, bool alignToLeft)

Description: Returns a string that aligns argument 1 within argument 2.

Sample: align(“abc”, ‘dddd’, true) = “abcd”

*padding-align(string target, number length, string padding, boolean alignToLeft, boolean allowTruncate?)

Description: Padding the target string with the specified padding character and also aligning and truncating as specified. Default value of allowTruncate is true.

Sample:

padding-align("hello", 10, "a", true, true) = “helloaaaaa”

*split-by-length(string input, int unitLength)

Description: Returns the node set that is separated by unit length.

Sample:split-by-length('abcdefg', 3) returns {'abc', 'def', 'g'}

*split(string input, string separator)

Description: Returns the node set that is separated by a separator.

Sample:

split('a, b, c', ',') returns {'a', 'b', 'c'}

*find(string input, string target, number startat?)

Description: Reports the index of the first occurrence of a String. Index begins at 1. If not found, returns 0.

Sample:

find('ab cd', ' ') returns 3 find('ab cd ef', ' ', 4) returns 6

*left(string input, number length)

Description: Returns the first length chars in input.

Sample:

left('abcdefg', 5) returns 'abcde'

*right(string input, number length)

Description: Returns the last length chars in input.

Sample:

right('abcdefg',3) returns 'efg'

*repeat(string input, number frequency)

Description: Repeats an input several times.

Sample:

repeat('+',10) returns '++++++++++'

*lower(string input)

Description: Returns a string that is lowercase.

Sample:

lower('abC') returns 'abc'

*upper(string input)

Description: Returns a string that is uppercase.

Sample:

upper('ABc') returns 'ABC'

*regex-find(string input, string pattern, number startat?)

Description: Finds the position of the sub-string matching the pattern. Index begins at 1. If not found, returns 0

Sample:

regex-find(“hello2345”, “\d+”, 1) = 6

*regex-match(string input, string pattern, number startat?)

Description: Returns true if input matches the regex pattern

Sample:

regex-match(“2345”, “\d+”, 1) returns true

*regex-replace(string input, string pattern, string replacement, number startat?)

Description: Replaces all the matches in the input with a replacement string

Sample:

regex-replace(“hello 2345”, “\d+”, “sunshine”) = “hello sunshine”

*regex-split(string input, string pattern)

Description: Returns the node set that is generated by a separator pattern.

Sample:

regex-split('a, b, c','[, ]') returns {'a', 'b', 'c'}

*format (string format, object obj1?, object obj2?, object obj3?, object obj4?, object obj5?)

Description: Replaces the format item in a specified string with the text equivalent of the value of a specified object instance.

Sample:

format(“My name is {0}”, “Ray”) = “My name is Ray”