http://www.zorba-xquery.com/modules/excel/text
import module namespace excel-text = "http://www.zorba-xquery.com/modules/excel/text";
This is a library module offering the same set of functions defined by Microsoft Excel, under Text and Data Functions.
Sorin Nasoi
xquery version "3.0" encoding "utf-8";
- the XQuery module can be found here.
Imported modules:
For more details please also see:
| excel-err | http://www.zorba-xquery.com/modules/excel/errors |
| excel-math | http://www.zorba-xquery.com/modules/excel/math |
| excel-text | http://www.zorba-xquery.com/modules/excel/text |
| ver | http://www.zorba-xquery.com/options/versioning |
|
asc
(
$text as xs:string
) as xs:string Returns the given $text unchanged. |
|
|
char
(
$number as xs:integer
) as xs:string Returns the character specified by a certain codepoint. |
|
|
clean
(
$arg as xs:string?
) as xs:string? Removes all nonprintable characters from text. |
|
|
code
(
$arg as xs:string
) as xs:integer Returns a codepoint for the first character in a text string. |
|
|
concatenate
(
$args as xs:anyAtomicType*
) as xs:string Joins several text strings into one text string. |
|
|
concatenate
(
$arg1 as xs:anyAtomicType?,
$arg2 as xs:anyAtomicType?
) as xs:string Joins two text strings into one text string. |
|
|
dollar
(
$number as xs:decimal
) as xs:string Converts a number to text format and applies a currency symbol. |
|
|
dollar
(
$number as xs:decimal,
$decimals as xs:decimal
) as xs:string Converts a number to text format and applies a currency symbol. |
|
|
exact
(
$arg1 as xs:string,
$arg2 as xs:string
) as xs:boolean Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise. |
|
|
find
(
$find_text as xs:string,
$within_text as xs:string
) as xs:integer? Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string. |
|
|
find
(
$find_text as xs:string,
$within_text as xs:string,
$start_num as xs:integer
) as xs:integer? Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string. |
|
|
fixed
(
$number as xs:decimal,
$decimals as xs:decimal
) as xs:string Rounds a number to the specified number of decimals, formats the number in decimal format using a period and commas, and returns the result as text. |
|
|
fixed
(
$number as xs:decimal,
$decimals as xs:decimal,
$no_commas as xs:boolean
) as xs:string Rounds a number to the specified number of decimals, formats the number in decimal format using a period and commas, and returns the result as text. |
|
|
left
(
$arg as xs:string
) as xs:string Returns the first character in a text string. |
|
|
left
(
$text as xs:string,
$num_chars as xs:integer
) as xs:string Returns the first character or characters in $text, based on the number of $num_chars you specify. |
|
|
len
(
$arg as xs:string?
) as xs:integer Returns the number of characters in a text string. |
|
|
lower
(
$arg as xs:string?
) as xs:string? Converts all uppercase letters in a text string to lowercase. |
|
|
mid
(
$text as xs:string?,
$start_num as xs:integer,
$num_chars as xs:integer
) as xs:string? Returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify. |
|
|
pad-integer-to-length
(
$toPad as xs:anyAtomicType?,
$padChar as xs:string,
$length as xs:integer
) as xs:string Returns $toPad appended with enough repetitions of $padChar to make its length $length, the characters are added before the string. |
|
|
replace
(
$old_text as xs:string?,
$start_num as xs:integer,
$num_chars as xs:integer,
$new_text as xs:string
) as xs:string Replaces part of a text string, based on the number of characters you specify, with a different text string. |
|
|
right
(
$arg as xs:string
) as xs:string Returns the last character in a text string. |
|
|
right
(
$text as xs:string,
$num_chars as xs:integer
) as xs:string Returns the last character or characters in a text string, based on the number of characters you specify. |
|
|
search
(
$find_text as xs:string,
$within_text as xs:string
) as xs:integer? Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string. |
|
|
search
(
$find_text as xs:string,
$within_text as xs:string,
$start_num as xs:integer
) as xs:integer? Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string. |
|
|
substitute
(
$text as xs:string,
$old_text as xs:string,
$new_text as xs:string
) as xs:string? Substitutes new_text for old_text in a text string. |
|
|
substitute
(
$text as xs:string,
$old_text as xs:string,
$new_text as xs:string,
$instance_num as xs:integer?
) as xs:string Substitutes new_text for old_text in a text string. |
|
|
t
(
$value as xs:anyAtomicType?
) as xs:string Converts the $value to string. |
|
|
trim
(
$text as xs:string?
) as xs:string? Removes all spaces from text except for single spaces between words. |
|
|
upper
(
$text as xs:string?
) as xs:string? Converts text to uppercase. |
|
|
value
(
$arg as xs:anyAtomicType?
) as xs:anyAtomicType? Converts a text string that represents a number to a number. |
|
|
value-except
(
$arg1 as xs:anyAtomicType*,
$arg2 as xs:anyAtomicType*
) as xs:anyAtomicType* Returns the values in one sequence that do not appear in the second sequence in an implementation-defined order. |
declare function excel-text:asc (
$text as xs:string
) as xs:string
Returns the given $text unchanged.
- $text the time
- The given $text unchanged.
declare function excel-text:char (
$number as xs:integer
) as xs:string
Returns the character specified by a certain codepoint.
- $number the codepoint.
- the character specified by a certain codepoint.
- excel-err:Value provided $number must be in range [1,255].
declare function excel-text:clean (
$arg as xs:string?
) as xs:string?
Removes all nonprintable characters from text.
- $arg the string.
- Removes all nonprintable characters from text. The CLEAN function was designed. to remove the first 32 nonprinting characters in the 7-bit ASCII code (values 0 through 31) from text.
In the Unicode character set, there are additional nonprinting characters (values 127, 129, 141, 143, 144, and 157).
By itself, the CLEAN function does not remove these additional nonprinting characters.
declare function excel-text:code (
$arg as xs:string
) as xs:integer
Returns a codepoint for the first character in a text string.
- $arg the string.
- A codepoint for the first character in a text string.
- excel-err:Value Provided $arg was empty.
declare function excel-text:concatenate (
$args as xs:anyAtomicType*
) as xs:string
Joins several text strings into one text string.
- $args a sequence of strings.
- Joins several text strings into one text string.
declare function excel-text:concatenate ( $arg1 as xs:anyAtomicType?, $arg2 as xs:anyAtomicType? ) as xs:string
Joins two text strings into one text string.
- $arg1 the first string.
- $arg2 the second string.
- Joins two text strings into one text string.
declare function excel-text:dollar (
$number as xs:decimal
) as xs:string
Converts a number to text format and applies a currency symbol. The number of digits to the right of the decimal point is 2.
- $number is the number.
- Converts a number to text format and applies a currency symbol. The number of digits to the right of the decimal point is 2.
declare function excel-text:dollar ( $number as xs:decimal, $decimals as xs:decimal ) as xs:string
Converts a number to text format and applies a currency symbol.
- $number is the number.
- $decimals is the number of digits to the right of the decimal point. If decimals is negative, number is rounded to the left of the decimal point.
- Converts a number to text format and applies a currency symbol.
declare function excel-text:exact ( $arg1 as xs:string, $arg2 as xs:string ) as xs:boolean
Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise. EXACT is case-sensitive but ignores formatting differences.
- $arg1 the first string.
- $arg2 the second string.
- Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise. EXACT is case-sensitive but ignores formatting differences.
declare function excel-text:find ( $find_text as xs:string, $within_text as xs:string ) as xs:integer?
Locate one text string within a second text string, and return the number of the
starting position of the first text string from the first character of the second text string.
The search is case sensitive.
- $find_text text you want to find.
- $within_text text in which you want to search for $find_text.
- Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.
The search is case sensitive.
- excel-err:Value the value is not greater than zero or is greater than the length of within_text.
- excel-err:Value value was not found.
declare function excel-text:find ( $find_text as xs:string, $within_text as xs:string, $start_num as xs:integer ) as xs:integer?
Locate one text string within a second text string, and return the number of the
starting position of the first text string from the first character of the second text string.
The search is case sensitive.
- $find_text text you want to find.
- $within_text text in which you want to search for $find_text.
- $start_num specifies the character at which to start the search.
- Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.
The search is case sensitive.
- excel-err:Value the value is not greater than zero or is greater than the length of within_text.
- excel-err:Value value was not found.
declare function excel-text:fixed ( $number as xs:decimal, $decimals as xs:decimal ) as xs:string
Rounds a number to the specified number of decimals, formats the number in decimal format using a period and commas, and returns the result as text.
- $number is the number you want to round and convert to text.
- $decimals is the number of digits to the right of the decimal point.
- Rounds a number to the specified number of decimals, formats the number in decimal format using a period and commas, and returns the result as text.
declare function excel-text:fixed ( $number as xs:decimal, $decimals as xs:decimal, $no_commas as xs:boolean ) as xs:string
Rounds a number to the specified number of decimals, formats the number in decimal format using a period and commas, and returns the result as text.
- $number is the number you want to round and convert to text.
- $decimals is the number of digits to the right of the decimal point.
- $no_commas is a logical value that, if TRUE, prevents FIXED from including commas in the returned text.
- Rounds a number to the specified number of decimals, formats the number in decimal format using a period and commas, and returns the result as text.
declare function excel-text:left (
$arg as xs:string
) as xs:string
Returns the first character in a text string.
- $arg is the text string that contains the characters you want to extract.
- The first character in a text string.
declare function excel-text:left ( $text as xs:string, $num_chars as xs:integer ) as xs:string
Returns the first character or characters in $text, based on the number of $num_chars you specify.
- $text is the text string that contains the characters you want to extract.
- $num_chars specifies the number of characters you want to extract.
- The first character or characters in $text, based on the number of $num_chars you specify.
declare function excel-text:len (
$arg as xs:string?
) as xs:integer
Returns the number of characters in a text string.
- $arg the string.
- The number of characters in a text string.
declare function excel-text:lower (
$arg as xs:string?
) as xs:string?
Converts all uppercase letters in a text string to lowercase.
- $arg the string.
- Converts all uppercase letters in a text string to lowercase.
declare function excel-text:mid ( $text as xs:string?, $start_num as xs:integer, $num_chars as xs:integer ) as xs:string?
Returns a specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.
- $text the text string containing the characters you want to extract.
- $start_num the position of the first character you want to extract in text. The first character in text has start_num 1, and so on.
- $num_chars the number of characters you want to return from text.
- A specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.
declare function excel-text:pad-integer-to-length ( $toPad as xs:anyAtomicType?, $padChar as xs:string, $length as xs:integer ) as xs:string
Returns $toPad appended with enough repetitions of $padChar to make its length $length, the characters are added before the string.
- $toPad the value to be padded.
- $padChar the character used for padding.
- $length the desired length.
- $toPad appended with enough repetitions of $padChar to make its length $length, the characters are added before the string.
- excel-err:Value if the length of the $toPad is greater than the desired length.
declare function excel-text:replace ( $old_text as xs:string?, $start_num as xs:integer, $num_chars as xs:integer, $new_text as xs:string ) as xs:string
Replaces part of a text string, based on the number of characters you specify, with a different text string.
- $old_text is text in which you want to replace some characters.
- $start_num the position of the character in old_text that you want to replace with new_text.
- $num_chars the number of characters in old_text that you want REPLACE to replace with new_text.
- $new_text the text that will replace characters in old_text.
- Replaces part of a text string, based on the number of characters you specify, with a different text string.
declare function excel-text:right (
$arg as xs:string
) as xs:string
Returns the last character in a text string.
- $arg the text string containing the characters you want to extract.
- The last character in a text string.
declare function excel-text:right ( $text as xs:string, $num_chars as xs:integer ) as xs:string
Returns the last character or characters in a text string, based on the number of characters you specify.
- $text the text string containing the characters you want to extract.
- $num_chars specifies the number of characters you want RIGHT to extract.
- The last character or characters in a text string, based on the number of characters you specify.
declare function excel-text:search ( $find_text as xs:string, $within_text as xs:string ) as xs:integer?
Locate one text string within a second text string, and return the number of
the starting position of the first text string from the first character of the
second text string.
The search starts at position 1, and it is not case sensitive.
- $find_text text you want to find.
- $within_text text in which you want to search for $find_text.
- Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.
The search starts at position 1, and it is not case sensitive.
- excel-err:Value the value is not greater than zero or is greater than the length of within_text.
- excel-err:Value value was not found.
declare function excel-text:search ( $find_text as xs:string, $within_text as xs:string, $start_num as xs:integer ) as xs:integer?
Locate one text string within a second text string, and return the number of
the starting position of the first text string from the first character of the
second text string.
The search starts at $start_num, and it is not case sensitive.
- $find_text text you want to find.
- $within_text text in which you want to search for $find_text.
- $start_num the character number in within_text at which you want to start searching.
- Locate one text string within a second text string, and return the number of the starting position of the first text string from the first character of the second text string.
The search starts at $start_num, and it is not case sensitive.
- excel-err:Value the value is not greater than zero or is greater than the length of within_text.
- excel-err:Value value was not found.
declare function excel-text:substitute ( $text as xs:string, $old_text as xs:string, $new_text as xs:string ) as xs:string?
Substitutes new_text for old_text in a text string. Every occurrence of old_text in text is changed to new_text.
- $text the text or the reference to a cell containing text for which you want to substitute characters.
- $old_text text you want to replace.
- $new_text text you want to replace old_text with.
- Substitutes new_text for old_text in a text string. Every occurrence of old_text in text is changed to new_text.
declare function excel-text:substitute ( $text as xs:string, $old_text as xs:string, $new_text as xs:string, $instance_num as xs:integer? ) as xs:string
Substitutes new_text for old_text in a text string.
- $text the text or the reference to a cell containing text for which you want to substitute characters.
- $old_text text you want to replace.
- $new_text text you want to replace old_text with.
- $instance_num specifies which occurrence of old_text you want to replace with new_text. Only that instance of old_text is replaced.
- Substitutes new_text for old_text in a text string.
Use SUBSTITUTE when you want to replace specific text in a text string; use REPLACE when you want to replace any text that occurs in a specific location in a text string.
declare function excel-text:t (
$value as xs:anyAtomicType?
) as xs:string
Converts the $value to string.
- $value the value
- Converts the $value to string.
declare function excel-text:trim (
$text as xs:string?
) as xs:string?
Removes all spaces from text except for single spaces between words.
- $text from which you want spaces removed.
- Removes all spaces from text except for single spaces between words.
declare function excel-text:upper (
$text as xs:string?
) as xs:string?
Converts text to uppercase.
- $text text you want converted to uppercase.
- Converts text to uppercase.
declare function excel-text:value (
$arg as xs:anyAtomicType?
) as xs:anyAtomicType?
Converts a text string that represents a number to a number.
- $arg the value.
- Converts a text string that represents a number to a number.
- excel-err:Value provided value is not a number.
declare function excel-text:value-except ( $arg1 as xs:anyAtomicType*, $arg2 as xs:anyAtomicType* ) as xs:anyAtomicType*
Returns the values in one sequence that do not appear in the second sequence in an implementation-defined order.
- $arg1 the first sequence.
- $arg2 the second sequence.
- The values in one sequence that do not appear in the second sequence in an implementation-defined order.