XPath/XQuery Functions: String
Altova's string extension functions can be used in XPath and XQuery expressions and provide additional functionality for the processing of data.
Note about naming of functions and language applicability
Altova extension functions can be used in XPath/XQuery expressions. They provide additional functionality to the functionality that is available in the standard library of XPath, XQuery, and XSLT functions. •In order to distinguish Altova extension functions from functions in the standard library, Altova extension functions are named in this documentation with a suffix of [altova:]. For example: add-years-to-date [altova:]. •When using Altova extension functions in your XPath/XQuery expressions, however, you must use the function without any prefix or suffix, just as you would use any standard XPath/XQuery function. Use an Altova extension like this: add-years-to-date(xs:date("2014-01-15"), 10).
|
camel-case(InputString as xs:string) as xs:string XP3.1 XQ3.1 Returns the input string InputString in CamelCase. The string is analyzed using the regular expression '\s' (which is a shortcut for the whitespace character). The first non-whitespace character after a whitespace or sequence of consecutive whitespaces is capitalized. The first character in the output string is capitalized.
camel-case(InputString as xs:string, SplitChars as xs:string, IsRegex as xs:boolean) as xs:string XP3.1 XQ3.1 Converts the input string InputString to camel case by using SplitChars to determine the character/s that trigger the next capitalization. SplitChars is used as a regular expression when IsRegex = true(), or as plain characters when IsRegex = false(). The first character in the output string is capitalized.
|
char(Position as xs:integer) as xs:string XP3.1 XQ3.1 Returns a string containing the character at the position specified by the Position argument, in the string obtained by converting the value of the context item to xs:string. The result string will be empty if no character exists at the index submitted by the Position argument.
char(InputString as xs:string, Position as xs:integer) as xs:string XP3.1 XQ3.1 Returns a string containing the character at the position specified by the Position argument, in the string submitted as the InputString argument. The result string will be empty if no character exists at the index submitted by the Position argument.
|
create-hash-from-string(InputString as xs:string) as xs:string XP2 XQ1 XP3.1 XQ3.1 create-hash-from-string(InputString as xs:string, HashAlgo as xs:string) as xs:string XP2 XQ1 XP3.1 XQ3.1 Generates a hash string from InputString by using the hashing algorithm specified by the HashAlgo argument. The following hashing algorithms may be specified (in upper or lower case): MD5, SHA-1, SHA-224, SHA-256, SHA-384, SHA-512. If the second argument is not specified (see the first signature above), then the SHA-256 hashing algorithm is used. Note that Windows clients do not support SHA-256.
|
first-chars(X-Number as xs:integer) as xs:string XP3.1 XQ3.1 Returns a string containing the first X-Number of characters of the string obtained by converting the value of the context item to xs:string.
first-chars(InputString as xs:string, X-Number as xs:integer) as xs:string XP3.1 XQ3.1 Returns a string containing the first X-Number of characters of the string submitted as the InputString argument.
|
format-string(InputString as xs:string, FormatSequence as item()*) as xs:string XP3.1 XQ3.1 The input string (first argument) contains positional parameters (%1, %2, etc). Each parameter is replaced by the string item that is located at the corresponding position in the format sequence (submitted as the second argument). So the first item in the format sequence replaces the positional parameter %1, the second item replaces %2, and so on. The function returns this formatted string that contains the replacements. If no string exists for a positional parameter, then the positional parameter itself is returned. This happens when the index of a positional parameter is greater than the number of items in the format sequence.
|
last-chars(X-Number as xs:integer) as xs:string XP3.1 XQ3.1 Returns a string containing the last X-Number of characters of the string obtained by converting the value of the context item to xs:string.
last-chars(InputString as xs:string, X-Number as xs:integer) as xs:string XP3.1 XQ3.1 Returns a string containing the last X-Number of characters of the string submitted as the InputString argument.
|
pad-string-left(StringToPad as xs:string, StringLength as xs:integer, PadCharacter as xs:string) as xs:string XP3.1 XQ3.1 The PadCharacter argument is a single character. It is padded to the left of the string to increase the number of characters in StringToPad so that this number equals the integer value of the StringLength argument. The StringLength argument can have any integer value (positive or negative), but padding will occur only if the value of StringLength is greater than the number of characters in StringToPad. If StringToPad. has more characters than the value of StringLength, then StringToPad is left unchanged.
|
pad-string-right(StringToPad as xs:string, StringLength as xs:integer, PadCharacter as xs:string) as xs:string XP3.1 XQ3.1 The PadCharacter argument is a single character. It is padded to the right of the string to increase the number of characters in StringToPad so that this number equals the integer value of the StringLength argument. The StringLength argument can have any integer value (positive or negative), but padding will occur only if the value of StringLength is greater than the number of characters in StringToPad. If StringToPad has more characters than the value of StringLength, then StringToPad is left unchanged.
|
repeat-string(InputString as xs:string, Repeats as xs:integer) as xs:string XP2 XQ1 XP3.1 XQ3.1 Generates a string that is composed of the first InputString argument repeated Repeats number of times.
|
substring-after-last(MainString as xs:string, CheckString as xs:string) as xs:string XP3.1 XQ3.1 If CheckString is found in MainString, then the substring that occurs after CheckString in MainString is returned. If CheckString is not found in MainString, then the empty string is returned. If CheckString is an empty string, then MainString is returned in its entirety. If there is more than one occurrence of CheckString in MainString, then the substring after the last occurrence of CheckString is returned.
|
substring-before-last(MainString as xs:string, CheckString as xs:string) as xs:string XP3.1 XQ3.1 If CheckString is found in MainString, then the substring that occurs before CheckString in MainString is returned. If CheckString is not found in MainString, or if CheckString is an empty string, then the empty string is returned. If there is more than one occurrence of CheckString in MainString, then the substring before the last occurrence of CheckString is returned.
|
substring-pos(StringToCheck as xs:string, StringToFind as xs:string) as xs:integer XP3.1 XQ3.1 Returns the character position of the first occurrence of StringToFind in the string StringToCheck. The character position is returned as an integer. The first character of StringToCheck has the position 1. If StringToFind does not occur within StringToCheck, the integer 0 is returned. To check for the second or a later occurrence of StringToCheck, use the next signature of this function.
substring-pos(StringToCheck as xs:string, StringToFind as xs:string, Integer as xs:integer) as xs:integer XP3.1 XQ3.1 Returns the character position of StringToFind in the string, StringToCheck. The search for StringToFind starts from the character position given by the Integer argument; the character substring before this position is not searched. The returned integer, however, is the position of the found string within the entire string, StringToCheck. This signature is useful for finding the second or a later position of a string that occurs multiple times with the StringToCheck. If StringToFind does not occur within StringToCheck, the integer 0 is returned.
|
trim-string(InputString as xs:string) as xs:string XP3.1 XQ3.1 This function takes an xs:string argument, removes any leading and trailing whitespace, and returns a "trimmed" xs:string.
|
trim-string-left(InputString as xs:string) as xs:string XP3.1 XQ3.1 This function takes an xs:string argument, removes any leading whitespace, and returns a left-trimmed xs:string.
|
trim-string-right(InputString as xs:string) as xs:string XP3.1 XQ3.1 This function takes an xs:string argument, removes any trailing whitespace, and returns a right-trimmed xs:string.
|