http://www.zorba-xquery.com/modules/excel/text ZC

Module Description
Before using any of the functions below please remember to import the module namespace:
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.

Author:

Sorin Nasoi

XQuery version and encoding for this module:

xquery version "3.0" encoding "utf-8";

Module Resources
  • the XQuery module can be found here.
Module Dependencies

Imported modules:

Related Documentation

For more details please also see:

Namespaces
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
Function Summary
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.
Functions
asc back to 'Function Summary'
declare function excel-text:asc (
            $text as xs:string 
 ) as xs:string

Returns the given $text unchanged.

Parameters:
  • $text the time
Returns:
  • The given $text unchanged.
See:

char back to 'Function Summary'
declare function excel-text:char (
            $number as xs:integer 
 ) as xs:string

Returns the character specified by a certain codepoint.

Parameters:
  • $number the codepoint.
Returns:
  • the character specified by a certain codepoint.
Errors:
  • excel-err:Value provided $number must be in range [1,255].
See:

clean back to 'Function Summary'
declare function excel-text:clean (
            $arg as xs:string? 
 ) as xs:string?

Removes all nonprintable characters from text.

Parameters:
  • $arg the string.
Returns:
  • 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.
See:

code back to 'Function Summary'
declare function excel-text:code (
            $arg as xs:string 
 ) as xs:integer

Returns a codepoint for the first character in a text string.

Parameters:
  • $arg the string.
Returns:
  • A codepoint for the first character in a text string.
Errors:
  • excel-err:Value Provided $arg was empty.
See:

concatenate back to 'Function Summary'
declare function excel-text:concatenate (
            $args as xs:anyAtomicType* 
 ) as xs:string

Joins several text strings into one text string.

Parameters:
  • $args a sequence of strings.
Returns:
  • Joins several text strings into one text string.
See:

concatenate back to 'Function Summary'
declare function excel-text:concatenate (
            $arg1 as xs:anyAtomicType?, 
            $arg2 as xs:anyAtomicType? 
 ) as xs:string

Joins two text strings into one text string.

Parameters:
  • $arg1 the first string.
  • $arg2 the second string.
Returns:
  • Joins two text strings into one text string.
See:

dollar back to 'Function Summary'
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.

Parameters:
  • $number is the number.
Returns:
  • Converts a number to text format and applies a currency symbol. The number of digits to the right of the decimal point is 2.
See:

dollar back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • Converts a number to text format and applies a currency symbol.
See:

exact back to 'Function Summary'
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.

Parameters:
  • $arg1 the first string.
  • $arg2 the second string.
Returns:
  • Compares two text strings and returns TRUE if they are exactly the same, FALSE otherwise. EXACT is case-sensitive but ignores formatting differences.
See:

find back to 'Function Summary'
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.

Parameters:
  • $find_text text you want to find.
  • $within_text text in which you want to search for $find_text.
Returns:
  • 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.
Errors:
  • 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.
See:

find back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • 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.
Errors:
  • 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.
See:

fixed back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • 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.
See:

fixed back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • 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.
See:

left back to 'Function Summary'
declare function excel-text:left (
            $arg as xs:string 
 ) as xs:string

Returns the first character in a text string.

Parameters:
  • $arg is the text string that contains the characters you want to extract.
Returns:
  • The first character in a text string.
See:

left back to 'Function Summary'
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.

Parameters:
  • $text is the text string that contains the characters you want to extract.
  • $num_chars specifies the number of characters you want to extract.
Returns:
  • The first character or characters in $text, based on the number of $num_chars you specify.
See:

len back to 'Function Summary'
declare function excel-text:len (
            $arg as xs:string? 
 ) as xs:integer

Returns the number of characters in a text string.

Parameters:
  • $arg the string.
Returns:
  • The number of characters in a text string.
See:

lower back to 'Function Summary'
declare function excel-text:lower (
            $arg as xs:string? 
 ) as xs:string?

Converts all uppercase letters in a text string to lowercase.

Parameters:
  • $arg the string.
Returns:
  • Converts all uppercase letters in a text string to lowercase.
See:

mid back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • A specific number of characters from a text string, starting at the position you specify, based on the number of characters you specify.
See:

pad-integer-to-length back to 'Function Summary'
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.

Parameters:
  • $toPad the value to be padded.
  • $padChar the character used for padding.
  • $length the desired length.
Returns:
  • $toPad appended with enough repetitions of $padChar to make its length $length, the characters are added before the string.
Errors:
  • excel-err:Value if the length of the $toPad is greater than the desired length.

replace back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • Replaces part of a text string, based on the number of characters you specify, with a different text string.
See:

right back to 'Function Summary'
declare function excel-text:right (
            $arg as xs:string 
 ) as xs:string

Returns the last character in a text string.

Parameters:
  • $arg the text string containing the characters you want to extract.
Returns:
  • The last character in a text string.
See:

right back to 'Function Summary'
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.

Parameters:
  • $text the text string containing the characters you want to extract.
  • $num_chars specifies the number of characters you want RIGHT to extract.
Returns:
  • The last character or characters in a text string, based on the number of characters you specify.
See:

search back to 'Function Summary'
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.

Parameters:
  • $find_text text you want to find.
  • $within_text text in which you want to search for $find_text.
Returns:
  • 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.
Errors:
  • 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.
See:

search back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • 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.
Errors:
  • 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.
See:

substitute back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • Substitutes new_text for old_text in a text string. Every occurrence of old_text in text is changed to new_text.
See:

substitute back to 'Function Summary'
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.

Parameters:
  • $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.
Returns:
  • 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.
See:

t back to 'Function Summary'
declare function excel-text:t (
            $value as xs:anyAtomicType? 
 ) as xs:string

Converts the $value to string.

Parameters:
  • $value the value
Returns:
  • Converts the $value to string.
See:

trim back to 'Function Summary'
declare function excel-text:trim (
            $text as xs:string? 
 ) as xs:string?

Removes all spaces from text except for single spaces between words.

Parameters:
  • $text from which you want spaces removed.
Returns:
  • Removes all spaces from text except for single spaces between words.
See:

upper back to 'Function Summary'
declare function excel-text:upper (
            $text as xs:string? 
 ) as xs:string?

Converts text to uppercase.

Parameters:
  • $text text you want converted to uppercase.
Returns:
  • Converts text to uppercase.
See:

value back to 'Function Summary'
declare function excel-text:value (
            $arg as xs:anyAtomicType? 
 ) as xs:anyAtomicType?

Converts a text string that represents a number to a number.

Parameters:
  • $arg the value.
Returns:
  • Converts a text string that represents a number to a number.
Errors:
  • excel-err:Value provided value is not a number.
See:

value-except back to 'Function Summary'
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.

Parameters:
  • $arg1 the first sequence.
  • $arg2 the second sequence.
Returns:
  • The values in one sequence that do not appear in the second sequence in an implementation-defined order.

blog comments powered by Disqus