This section describes the XQuery functions provided by HiRDB.
Arguments are described in the format of each XQuery function. They are passed as parameters to that XQuery function according to the XQuery function invocation rules. For details about the rules of XQuery function invocation, see 1.15.6(15)(g) XQuery function invocation.
XQuery functions include functions defined in XQuery and functions defined in HiRDB.
Functions defined in XQuery use the XML namespace that is bound to the prefix xs (http://www.w3.org/2001/XMLSchema) or the XML namespace that is bound to the prefix fn (http://www.w3.org/2006/xpath-functions).
Functions defined in HiRDB use the XML namespace that is bound to the prefix hi-fn (http://www.hitachi.co.jp/Prod/comp/soft1/hirdb/xquery-functions). When functions defined in HiRDB are called, unless the default XML namespace for XQuery function names is declared as http://www.hitachi.co.jp/Prod/comp/soft1/hirdb/xquery-functions, the prefix must be specified.
For details about the constructor function, see 1.15.2(3)(b) Constructor function.
The following table lists the XQuery functions available in HiRDB.
Table 1-98 XQuery functions provided in HiRDB
Classification | Function | Purpose | XQuery function category |
---|---|---|---|
Constructor function | xs:string | Generate a value of type xs:string. | XQuery |
xs:decimal | Generate a value of type xs:decimal. | XQuery | |
xs:int | Generate a value of type xs:int. | XQuery | |
xs:double | Generate a value of type xs:double. | XQuery | |
xs:dateTime | Generate a value of type xs:dateTime. | XQuery | |
xs:date | Generate a value of type xs:date. | XQuery | |
xs:time | Generate a value of type xs:time. | XQuery | |
xs:hexBinary | Generate a value of type xs:hexBinary. | XQuery | |
xs:boolean | Generate a value of type xs:boolean. | XQuery | |
xs:untypedAtomic | Generate a value of type xs:untypedAtomic. | XQuery | |
Conversion functions | fn:boolean | Return the result of evaluating the XQuery sequence as a value of the xs:boolean type. | XQuery |
fn:data | Atomize an XQuery sequence and return an XQuery sequence consisting of atomic values. | XQuery | |
fn:number | Return the result of converting the value specified in the argument to xs:double type. | XQuery | |
fn:string | Return the character string representation of the value of the XQuery item as an xs:string type value. | XQuery | |
Character string operation functions | fn:compare | Compare two character strings. | XQuery |
fn:concat | Return the result of concatenating two or more atomic values that have been converted to an xs:string type value. | XQuery | |
fn:contains(function defined in XQuery) | Return whether or not the character string specified in argument-2 is part of the character string specified in argument-1. | XQuery | |
hi-fn:contains(function defined in HiRDB) | Return whether or not the character string value of the node specified in argument-1 satisfies the full-text search conditions specified in argument-2. | HiRDB | |
fn:ends-with | Return whether or not the character string specified in argument-1 ends with the character string specified in argument-2. | XQuery | |
fn:normalize-space | Return the result of normalizing whitespace in a character string. | XQuery | |
fn:starts-with | Return whether or not the character string specified in argument-1 starts with the character string specified in argument-2. | XQuery | |
fn:string-length | Return the length (in number of characters) of the character string. | XQuery | |
fn:substring | Return a substring of a character string. | XQuery | |
fn:substring-after | Return a substring of the character string specified in argument-1 that begins immediately after the position of the first occurrence of the character string specified in argument-2. | XQuery | |
fn:substring-before | Return a substring of the character string specified in argument-1 that ends immediately before the position of the first occurrence of the character string specified in argument-2. | XQuery | |
fn:translate | Return the result of replacing the characters specified in argument-2 with the characters specified in argument-3 in the character string specified in argument-1. | XQuery | |
Math functions | fn:abs | Return the absolute value of a numeric data type value. | XQuery |
fn:ceiling | Return the smallest integer value that is greater than or equal to an argument. | XQuery | |
fn:floor | Return the greatest integer value that is less than or equal to an argument. | XQuery | |
fn:round | Return the integer value closest to the value of an argument. | XQuery | |
Date extraction functions | fn:year-from-dateTime | Return only the year part extracted from the time stamp. | XQuery |
fn:month-from-dateTime | Return only the month part extracted from the time stamp. | XQuery | |
fn:day-from-dateTime | Return only the day part extracted from the time stamp. | XQuery | |
fn:hours-from-dateTime | Return only the hours part extracted from the time stamp. | XQuery | |
fn:minutes-from-dateTime | Return only the minutes part extracted from the time stamp. | XQuery | |
fn:seconds-from-dateTime | Return only the seconds part extracted from the time stamp. | XQuery | |
fn:year-from-date | Return only the year part extracted from the date. | XQuery | |
fn:month-from-date | Return only the month part extracted from the date. | XQuery | |
fn:day-from-date | Return only the day part extracted from the date. | XQuery | |
fn:hours-from-time | Return only the hours part extracted from the time. | XQuery | |
fn:minutes-from-time | Return only the minutes part extracted from the time. | XQuery | |
fn:seconds-from-time | Return only the seconds part extracted from the time. | XQuery | |
Boolean functions | fn:false | Return FALSE. | XQuery |
fn:not | Convert an argument to the xs:boolean type and return the negation of its value. | XQuery | |
fn:true | Return TRUE. | XQuery | |
XQuery sequence aggregation functions | fn:count | Return the number of XQuery items in an XQuery sequence. | XQuery |
fn:distinct-values | Return an XQuery sequence consisting of atomic values with duplicates removed. | XQuery | |
fn:max | Return the largest value of the atomic values that make up an XQuery sequence. | XQuery | |
fn:min | Return the smallest value of the atomic values that make up an XQuery sequence. | XQuery | |
fn:sum | Return the sum of the atomic values that make up an XQuery sequence. | XQuery | |
XQuery sequence operation functions | fn:deep-equal | Determine whether two XQuery sequences are deep-equal. | XQuery |
fn:index-of | Return the positions in the specified XQuery sequence of all occurrences of the XQuery items that match the specified atomic value. | XQuery | |
fn:insert-before | Return the XQuery sequence that results from inserting an XQuery item before the specified position in an XQuery sequence. | XQuery | |
fn:remove | Return the XQuery sequence that results from removing the XQuery item at the specified position in the XQuery sequence. | XQuery | |
fn:reverse | Return the XQuery sequence that results from sorting the XQuery items in an XQuery sequence in reverse order. | XQuery | |
fn:subsequence | Return an XQuery subsequence of an XQuery sequence. | XQuery | |
Context item functions | fn:last | Return the context size. | XQuery |
fn:position | Return the context position. | XQuery | |
Node functions | fn:local-name | Return the local name of a node. | XQuery |
fn:name | Return the qualified name of a node. | XQuery | |
fn:namespace-uri | Return the XML namespace URI of the qualified name of a node. | XQuery |
Returns the absolute value of a numeric data type value.
fn:abs ( argument ) |
Table 1-99 fn:abs function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | num | Numeric data type (including empty XQuery sequences) | Input numeric value |
Table 1-100 XQuery data type of the result of the fn:abs function
No. | XQuery data type of the value of the parameter num | XQuery data type of the result |
---|---|---|
1 | xs:double | xs:double |
2 | xs:decimal | xs:decimal |
3 | xs:int | xs:int |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (XQuery data type in parentheses) | Explanation |
---|---|---|---|
1 | fn:abs(10.5) | 10.5 (xs:decimal) | Returns 10.5, the absolute value of 10.5. |
2 | fn:abs(-10.5) | 10.5 (xs:decimal) | Returns 10.5, the absolute value of -10.5. |
Returns the result of evaluating an XQuery sequence as an xs:boolean type value.
fn:boolean ( argument ) |
Table 1-101 fn:boolean function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence of zero or more arbitrary XQuery items | Input XQuery sequence |
Table 1-102 Results of the fn:boolean function
No. | Value of the parameter seq | Result (xs:boolean type) |
---|---|---|
1 | Empty XQuery sequence | FALSE |
2 | XQuery sequence in which the first XQuery item is a node | TRUE |
3 | XQuery sequence consisting of one xs:boolean type atomic value | Atomic value of the XQuery sequence argument |
4 | XQuery sequence consisting of one xs:string type or xs:untypedAtomic type atomic value | FALSE if the atomic value of the XQuery sequence argument has length 0, otherwise TRUE. |
5 | XQuery sequence consisting of one numeric data type atomic value | FALSE if the atomic value of the XQuery sequence argument is 0 or NaN (not a number), otherwise TRUE. |
6 | Other than the above | Error |
Below are examples of function invocations and their results when the XQuery variable book indicates the node representing the elements shown below.
Element represented by the XQuery variable book:
<bookinfo book_id="452469630"> |
Examples of function invocations and their results:
No. | Function invocation | Result (xs:boolean type) | Explanation |
---|---|---|---|
1 | $book/fn:boolean(author[text() = "Mark Davis"]) | FALSE | Returns FALSE because the value of the parameter seq is an empty XQuery sequence. |
2 | fn:boolean($book) | TRUE | Returns TRUE because the value of the parameter seq is an XQuery sequence consisting of one element node bookinfo. |
3 | $book/fn:boolean(@book_id = 452469630) | TRUE | Returns TRUE because the value of the parameter seq is an XQuery sequence consisting of one xs:boolean type value. |
4 | $book/fn:boolean(title/fn:string(text())) | TRUE | Returns TRUE because the value of the parameter seq is an XQuery sequence consisting of one xs:string type value of length 1 or greater. |
5 | $book/fn:boolean(@book_id) | TRUE | Returns TRUE because the value of the parameter seq is an XQuery sequence consisting of one numeric data value. |
6 | $book/fn:boolean(author/fn:string(text())) | Error | Error because the value of the parameter seq is an XQuery sequence consisting of two xs:string type values. |
Returns the smallest integer value that is greater than or equal to an argument.
fn:ceiling ( argument ) |
Table 1-103 fn:ceiling function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | num | Numeric data type (including empty XQuery sequences) | Input numeric value |
Table 1-104 XQuery data type of the result of the fn:ceiling function
No. | XQuery data type of the value of the parameter num | XQuery data type of the result |
---|---|---|
1 | xs:double | xs:double |
2 | xs:decimal | xs:decimal |
3 | xs:int | xs:int |
Table 1-105 fn:ceiling function special values result
No. | Value of the parameter num | Result value |
---|---|---|
1 | Positive 0 | Positive 0 |
2 | Negative 0 | Negative 0 |
3 | Greater than -1 and less than 0 | Negative 0 |
4 | Positive infinity | Positive infinity |
5 | Negative infinity | Negative infinity |
6 | NaN (not a number) | NaN (not a number) |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (XQuery data type in parentheses) | Explanation |
---|---|---|---|
1 | fn:ceiling(10.5) | 11. (xs:decimal) | Returns 11, which is the integer value that is greater than or equal to 10.5. |
2 | fn:ceiling(-10.5) | -10. (xs:decimal) | Returns -10, which is the integer value that is greater than or equal to -10.5. |
Returns the result of comparing two character strings.
fn:compare ( argument-1, argument-2 ) |
Table 1-106 fn:compare function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | str1 | xs:string type (including empty XQuery sequences) | Character string to compare |
2 | argument-2 | str2 | xs:string type (including empty XQuery sequences) | Character string to compare |
Table 1-107 Results of the fn:compare function
No. | Relationship between the values of parameters str1 and str2 | Result (xs:int type) |
---|---|---|
1 | Value of parameter str1 is less than the value of parameter str2 (str1 lt str2 is TRUE) | -1 |
2 | Value of parameter str1 is equal to the value of parameter str2 (str1 eq str2 is TRUE) | 0 |
3 | Value of parameter str1 is greater than the value of parameter str2 (str1 gt str2 is TRUE) | 1 |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:compare("abcde", "abcdef") | -1 | Returns -1 because "abcde" is less than "abcdef". |
2 | fn:compare("abcde", "abcde") | 0 | Returns 0 because the values of parameters str1 and str2 are both "abcde". |
3 | fn:compare("abcde", "abade") | 1 | Returns 1 because "abcde" is greater than "abade". |
Returns the result of concatenating two or more atomic values that have been converted to an xs:string type value.
fn:concat ( argument, argument [, argument]... ) |
Table 1-108 fn:concat function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | val | Any atomic type (including empty XQuery sequences) | Atomic value to concatenate |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | fn:concat("abc","defg") | "abcdefg" | Returns the character string "abcdefg", which is the concatenation of "abc" and "defg". |
2 | fn:concat("hijk", (), "lmn") | "hijklmn" | Returns the character string "hijklmn", which is the concatenation of "hijk", "", and "lmn", because an empty XQuery sequence is treated as a character string of length zero. |
3 | fn:concat((),(),()) | Empty XQuery sequence | Returns an empty XQuery sequence because the value of every parameter is an empty XQuery sequence. |
Returns a value indicating whether the character string specified in argument-2 is part of the character string specified in argument-1.
fn:contains ( argument-1, argument-2 ) |
Table 1-109 fn:contains function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | str1 | xs:string type (including empty XQuery sequences) | Character string in which to find the substring |
2 | argument-2 | str2 | xs:string type (including empty XQuery sequences) | Substring to find within the character string in parameter str1 |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:boolean type) | Explanation |
---|---|---|---|
1 | fn:contains("abcdefg", "cde") | TRUE | Returns TRUE because "cde" is part of "abcdefg". |
2 | fn:contains("abcdefg", "cdf") | FALSE | Returns FALSE because "cdf" is not part of "abcdefg". |
3 | fn:contains((), "") | TRUE | Returns TRUE because the value of parameter str2 is a character string of length zero. |
4 | fn:contains((), "a") | FALSE | Returns FALSE because the value of parameter str1 is an empty XQuery sequence, and the value of parameter str2 is a character string of length 1 or greater. |
5 | fn:contains("abcdefg", ()) | TRUE | Returns TRUE because the value of parameter str2 is an empty XQuery sequence. |
Returns a value indicating whether the character string value of the node specified in argument-1 satisfies the full-text search conditions specified in argument-2.
hi-fn:contains ( argument-1, argument-2 ) |
Table 1-110 hi-fn:contains function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | seq | XQuery sequence with zero or more nodes | Nodes to search |
2 | argument-2 | str | xs:string type | Full-text search conditions character string |
Table 1-111 Search conditions that can be specified as text search conditions
No. | Search conditions | Summary | Example |
---|---|---|---|
1 | Simple character string conditions | Search for character strings that match a search string that contains special characters, or any of the following wildcards:
|
|
2 | Excluded character search conditions | Search while excluding a particular character in the middle or at the ends of the search string from simple character string conditions. A ^ is specified before the character to exclude. |
|
3 | NOT conditions | Search for character strings that do not contain the search string. |
|
4 | AND/OR conditions | Specify multiple search conditions linked with AND or OR. |
|
5 | Proximity conditions | Specify the number of characters (distance) between two character strings matching two search conditions. |
|
6 | Synonym expansion conditions | Automatically expand the search string to include synonyms based on the definitions in a synonym dictionary. For details about how to create and register a synonym dictionary, see the manual HiRDB Version 9 XML Extension. | Character strings that contain a synonym of COMPUTER (including different alphabetical and one- and two-byte representations) SYNONYM(USR01#4, "COMPUTER", "AE#5") |
7 | Representation expansion conditions | Automatically expand the search string to include different representations based on rules. |
|
In the examples of function invocations and their results given below, the XML document shown below is represented by values in columns (on which an XML type full-text search index is defined) specified in XML query context items.
XML document represented by the values stored in the columns specified in XML query context items:
<bookinfo book_id="452469630"> |
Examples of function invocations and their results:
No. | Function invocation | Result (xs:boolean type) | Explanation |
---|---|---|---|
1 | /bookinfo/title[ hi-fn:contains(text(), "SYNONYM(USR01, "DB")")] | TRUE | Suppose "database" and "DB" are registered as synonyms in synonym dictionary USR01. Returns TRUE because in the value of the parameter seq there is a node containing "database", which is a synonym of "DB". |
2 | /bookinfo/description[ hi-fn:contains(text(), "SOUNDEX_EXP("DATABASE", "AE") AND "Explain"")] | TRUE | Returns TRUE because the value of the parameter seq includes a node that contains both "Explain" and "Database", which is an alphabetic variant of "DATABASE". |
3 | /bookinfo/author[ hi-fn:contains(text(), ""Smith"")] | FALSE | Returns FALSE because there is no node containing "Smith" in the value of the parameter seq. |
4 | /bookinfo/contents[ hi-fn:contains(text(), "SYNONYM(USR01, "DB")")] | FALSE | Returns FALSE because the parameter seq is an empty XQuery sequence. |
Returns the number of XQuery items in an XQuery sequence.
fn:count ( argument ) |
Table 1-112 fn:count function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence of zero or more arbitrary XQuery items | Input XQuery sequence |
In the examples of function invocations and their results given below, the XQuery variable book indicates the node representing the elements shown below.
Element represented by the XQuery variable book:
<bookinfo book_id="452469630"> |
Examples of function invocations and their results:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:count($book) | 1 | Returns 1 because the value of the parameter seq is an XQuery sequence consisting of one bookinfo element node. |
2 | fn:count($book/author) | 2 | Returns 2 because the value of the parameter seq is an XQuery sequence consisting of two author element nodes that are children of the bookinfo element node. |
3 | fn:count($book/author[.="Mark Davis"]) | 0 | Returns 0 because the value of the parameter seq is an empty XQuery sequence. |
Atomizes an XQuery sequence and returns an XQuery sequence consisting of atomic values.
fn:data ( argument ) |
Table 1-113 fn:data function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence of zero or more arbitrary XQuery items | Input XQuery sequence |
Table 1-114 Results when the XQuery item is a node
No. | Kind of node | Result |
---|---|---|
1 | Document node | Value of the typed-value property |
2 | Element node | Value of the typed-value property |
3 | Attribute node | Value of the typed-value property |
4 | Processing instruction node | Empty XQuery sequence |
5 | Comment node | Empty XQuery sequence |
6 | Text node | Value of converting the value of the content property to xs:untypedAtomic type |
In the examples of function invocations and their results given below, the XQuery variable book indicates the node representing the elements shown below.
Element represented by the XQuery variable book:
<bookinfo book_id="452469630"> |
Examples of function invocations and their results:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | fn:data($book/price) | Empty XQuery sequence | Returns an empty XQuery sequence because the value of the parameter seq is an empty XQuery sequence. |
2 | fn:data($book/author) | ("Jeff Jones","Bob Adams") | Returns the XQuery sequence consisting of the two typed-value property values because the parameter seq is an XQuery sequence consisting of two author element nodes. |
Returns only the day part extracted from the date.
fn:day-from-date ( argument ) |
Table 1-115 fn:day-from-date function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dat | xs:date type (including empty XQuery sequences) | Date to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:day-from-date (xs:date("2006-09-26")) | 26 | Returns 26, which is the day part of the value of the parameter dat. |
Returns only the day part extracted from the time stamp.
fn:day-from-dateTime ( argument ) |
Table 1-116 fn:day-from-dateTime function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dtm | xs:dateTime type (including empty XQuery sequences) | Time stamp to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:day-from-dateTime(xs:dateTime("2006-09-26T18:44:58.153")) | 26 | Returns 26, which is the day part of the value of the parameter dtm. |
Determines whether two XQuery sequences are deep-equal (have the same structure and the same values).
fn:deep-equal ( argument-1, argument-2 ) |
Table 1-117 fn:deep-equal function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | seq1 | XQuery sequence of zero or more arbitrary XQuery items | XQuery sequence to compare |
2 | argument-2 | seq2 | XQuery sequence of zero or more arbitrary XQuery items | XQuery sequence to compare |
Table 1-118 XQuery item deep-equal rules
No. | Category of item1 | Category of item2 | Rules |
---|---|---|---|
1 | Atomic value | Atomic value | TRUE only if all of the following conditions are met:
|
2 | Other than the above | FALSE | |
3 | Document node | Document node | TRUE only if the fn:deep-equal function is TRUE for the XQuery sequence of element and text nodes that are children of item1 and the XQuery sequence of element and text nodes that are children of item2. |
4 | Other than the above | FALSE | |
5 | Element node | Element node | TRUE only if all of the following conditions are met:
|
6 | Other than the above | FALSE | |
7 | Attribute node | Attribute node | TRUE only if all of the following conditions are met:
|
8 | Other than the above | FALSE | |
9 | Processing instruction node | Processing instruction node | TRUE only if all of the following conditions are met:
|
10 | Other than the above | FALSE | |
11 | Text node | Text node | TRUE only if the character string values of the two text nodes are deep-equal. |
12 | Other than the above | FALSE. | |
13 | Comment node | Comment node | TRUE only if the character string values of the two comment nodes are deep-equal. |
14 | Other than the above | FALSE |
In the examples of function invocations and their results given below, the XQuery variable books indicates the node representing the elements shown below.
Element represented by the XQuery variable books:
<booklist> |
Examples of function invocations and their results:
No. | Function invocation | Result (xs:boolean type) | Explanation |
---|---|---|---|
1 | fn:deep-equal( $books/bookinfo[1]/title, "Relational Databases Explained") | FALSE | FALSE because the parameter seq1 is an XQuery sequence of one element node, and parameter seq2 is an XQuery sequence of a single atomic value. |
2 | fn:deep-equal($books/bookinfo[1], $books/bookinfo[2]) | FALSE | FALSE because although parameters seq1 and seq2 are both XQuery sequences of one bookinfo element node, their book_id attribute nodes are not deep-equal and their child title elements are not deep-equal. |
3 | fn:deep-equal($books/bookinfo[1]/author, $books/bookinfo[2]/author) | TRUE | TRUE because parameters seq1 and seq2 are both XQuery sequences with two author element nodes, and those author element nodes are deep-equal. |
Returns an XQuery sequence consisting of atomic values with duplicates removed.
fn:distinct-values ( argument ) |
Table 1-119 fn:distinct-values function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence of zero or more values of any atomic type | Input XQuery sequence |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | fn:distinct-values(("a", 1, "A", 0, 1)) | ("a", 1, "A", 0) Order may vary. | The duplicate 1 is removed from the XQuery sequence that is the value of the parameter seq. |
Returns a value indicating whether the character string specified in argument-1 ends with the character string specified in argument-2.
fn:ends-with ( argument-1, argument-2 ) |
Table 1-120 fn:ends-with function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | str1 | xs:string type (including empty XQuery sequences) | Character string to be checked to see whether it ends with the substring |
2 | argument-2 | str2 | xs:string type (including empty XQuery sequences) | Substring to check against the end of the character string in parameter str1 |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:boolean type) | Explanation |
---|---|---|---|
1 | fn:ends-with("abcdefg", "efg") | TRUE | Returns TRUE because "abcdefg" ends with "efg". |
2 | fn:ends-with("abcdefg", "abc") | FALSE | Returns FALSE because "abcdefg" does not end with "abc". |
3 | fn:ends-with((), "") | TRUE | Returns TRUE because the value of parameter str2 is a character string of length zero. |
4 | fn:ends-with((), "a") | FALSE | Returns FALSE because the value of parameter str1 is an empty XQuery sequence, and the value of parameter str2 is a character string of length 1 or greater. |
5 | fn:ends-with("abcdefg", ()) | TRUE | Returns TRUE because the value of parameter str2 is an empty XQuery sequence. |
Returns FALSE.
fn:false ( ) |
Returns the largest integer value that is less than or equal to an argument.
fn:floor ( argument ) |
Table 1-121 fn:floor function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | num | Numeric data type (including empty XQuery sequences) | Input numeric value |
Table 1-122 XQuery data type of the result of the fn:floor function
No. | XQuery data type of the value of the parameter num | XQuery data type of the result |
---|---|---|
1 | xs:double | xs:double |
2 | xs:decimal | xs:decimal |
3 | xs:int | xs:int |
Table 1-123 fn:floor function special value results
No. | Value of the parameter num | Result value |
---|---|---|
1 | Positive 0 | Positive 0 |
2 | Negative 0 | Negative 0 |
3 | Positive infinity | Positive infinity |
4 | Negative infinity | Negative infinity |
5 | NaN (not a number) | NaN (not a number) |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (XQuery data type in parentheses) | Explanation |
---|---|---|---|
1 | fn:floor(10.5) | 10. (xs:decimal) | Returns 10, which is the largest integer value that is less than or equal to 10.5. |
2 | fn:floor(-10.5) | -11. (xs:decimal) | Returns -11, which is the largest integer value that is less than or equal to -10.5. |
Returns only the hours part extracted from the time stamp.
fn:hours-from-dateTime ( argument ) |
Table 1-124 fn:hours-from-dateTime function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dtm | xs:dateTime type (including empty XQuery sequences) | Time stamp to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:hours-from-dateTime(xs:dateTime("2006-09-26T18:44:58.153")) | 18 | Returns 18, which is the value of the hours part of parameter dtm. |
Returns only the hours part extracted from the time.
fn:hours-from-time ( argument ) |
Table 1-125 fn:hours-from-time function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | tim | xs:time type (including empty XQuery sequences) | Time to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:hours-from-time(xs:time("18:44:58")) | 18 | Returns 18, which is the hours part of the value of parameter tim. |
Returns the positions in the specified XQuery sequence of all occurrences of the XQuery items that match the specified atomic value.
fn:index-of ( argument-1, argument-2 ) |
Table 1-126 fn:index-of function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | seq | XQuery sequence of zero or more values of any atomic type | XQuery sequence to be searched |
2 | argument-2 | val | Any atomic type | Atomic value to search for |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | fn:index-of((10, 20, 30, 40), 35) | Empty XQuery sequence | Returns an empty XQuery sequence because there is no matching XQuery item in the XQuery sequence in parameter seq. |
2 | fn:index-of((10, 20, 30, 40), 30) | (3) | Returns the XQuery sequence consisting of the xs:int type value 3, because the third XQuery item in the XQuery sequence in parameter seq is a match. |
3 | fn:index-of((10, 20, 30, 40,30,50), 30) | (3,5) | Returns the XQuery sequence consisting of the xs:int type values 3 and 5, because the third and fifth XQuery items in the XQuery sequence in parameter seq are matches. |
Returns the XQuery sequence that results from inserting an XQuery item before the specified position in an XQuery sequence.
fn:insert-before ( argument-1, argument-2, argument-3 ) |
Table 1-127 fn:insert-before function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | seq1 | XQuery sequence of zero or more arbitrary XQuery items | XQuery sequence into which you are inserting |
2 | argument-2 | pos | xs:int | Insertion position |
3 | argument-3 | seq2 | XQuery sequence of zero or more arbitrary XQuery items | XQuery sequence containing the XQuery items to be insert |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | fn:insert-before(("a", "b", "c"), 0, "z") | ("z", "a", "b", "c") | Inserts "z" at the beginning because the value of parameter pos is 0. |
2 | fn:insert-before(("a", "b", "c"), 1, "z") | ("z", "a", "b", "c") | Inserts "z" at the beginning because the value of parameter pos is 1. |
3 | fn:insert-before(("a", "b", "c"), 3, "z") | ("a", "b", "z", "c") | Inserts "z" before the third XQuery item "c" because the value of parameter pos is 3. |
4 | fn:insert-before(("a", "b", "c"), 4, "z") | ("a", "b", "c", "z") | Inserts "z" at the end because the value of parameter pos is 4. |
Returns the context size.
fn:last ( ) |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | ("a", "b", "c")[fn:last() ] | "c" (xs:string) Result of fn:last function is 3 | fn:last function returns 3 because the number of context items is 3. Therefore, the third context item "c" will be the result. |
Returns the local name of a node.
fn:local-name ( [argument] ) |
Table 1-128 fn:local-name function parameter
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | node | Any node (including empty XQuery sequences) | Node whose local name is to be obtained |
In the examples of function invocations and their results given below, the XQuery variable book indicates the node representing the elements shown below.
Element represented by the XQuery variable book:
<bookinfo:bookinfo book_id="452469630"> |
Examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | $book/fn:local-name() | "bookinfo" | Returns the local name of the context item, which is the bookinfo:bookinfo element node, because no argument is specified. |
2 | $book/fn:local-name(./title) | "title" | Returns the local name title because the value of the parameter node is the title element node. |
3 | $book/title/fn:local-name(./text()) | "" (a character string of length zero) | Returns a character string of length zero because the value of the parameter node is a text node. |
Returns the largest value of the atomic values that make up an XQuery sequence.
fn:max ( argument ) |
Table 1-129 fn:max function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence of zero or more values of any atomic type | Input XQuery sequence |
Table 1-130 XQuery data type of the result of the fn:max function
No. | XQuery data type of the values in the XQuery sequence that is the value of the parameter seq | XQuery data type of the result | ||
---|---|---|---|---|
xs:double | xs:decimal | xs:int | ||
1 | Y | -- | -- | xs:double |
2 | N | Y | -- | xs:decimal |
3 | N | N | -- | xs:int |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (XQuery data type in parentheses) | Explanation |
---|---|---|---|
1 | fn:max((3,4.0,5)) | 5. (xs:decimal) | Returns 5, which is the largest value among 3, 4.0, 5, as an xs:decimal type value. |
2 | fn:max(()) | Empty XQuery sequence | Returns an empty XQuery sequence because the value of the parameter seq is an empty XQuery sequence. |
3 | fn:max((1.0E2, 2.0E-3, 100)) | 1.0E2 (xs:double) | Returns 1.0E2, which is the largest value among 1.0E2, 2.0E-3, 100, as an xs:double type value. |
Returns the smallest value of the atomic values that make up an XQuery sequence.
fn:min ( argument ) |
Table 1-131 fn:min function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence of zero or more values of any atomic type | Input XQuery sequence |
Table 1-132 XQuery data type of the result of the fn:min function
No. | XQuery data type of the values in the XQuery sequence that is the value of the parameter seq | XQuery data type of the result | ||
---|---|---|---|---|
xs:double | xs:decimal | xs:int | ||
1 | Y | -- | -- | xs:double |
2 | N | Y | -- | xs:decimal |
3 | N | N | -- | xs:int |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (XQuery data type in parentheses) | Explanation |
---|---|---|---|
1 | fn:min((3,4.0,5)) | 3. (xs:decimal) | Returns 3, which is the smallest value among 3, 4.0, 5, as an xs:decimal type value. |
2 | fn:min(()) | Empty XQuery sequence | Returns an empty XQuery sequence because the value of the parameter seq is an empty XQuery sequence. |
3 | fn:min((1.0E2, 2.0E3, 100)) | 1.0E2 (xs:double) | Returns 1.0E2, which is the smallest value among 1.0E2, 2.0E3, 100, as an xs:double type value. |
Returns only the minutes part extracted from the time stamp.
fn:minutes-from-dateTime ( argument ) |
Table 1-133 fn:minutes-from-dateTime function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dtm | xs:dateTime type (including empty XQuery sequences) | Time stamp to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:minutes-from-dateTime(xs:dateTime("2006-09-26T18:44:58.153")) | 44 | Returns 44, which is the minutes part of the value of the parameter dtm. |
Returns only the minutes part extracted from the time.
fn:minutes-from-time ( argument ) |
Table 1-134 fn:minutes-from-time function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | tim | xs:time type (including empty XQuery sequences) | Time to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:minutes-from-time(xs:time("18:44:58")) | 44 | Returns 44, which is the minutes part of the value of the parameter tim. |
Returns only the month part extracted from the date.
fn:month-from-date ( argument ) |
Table 1-135 fn:month-from-date function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dat | xs:date type (including empty XQuery sequences) | Date to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:month-from-date(xs:date("2006-09-26")) | 9 | Returns 9, which is the month part of the value of the parameter dat. |
Returns only the month part extracted from the time stamp.
fn:month-from-dateTime ( argument ) |
Table 1-136 fn:month-from-dateTime function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dtm | xs:dateTime type (including empty XQuery sequences) | Time stamp to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:month-from-dateTime(xs:dateTime("2006-09-26T18:44:58.153")) | 9 | Returns 9, which is the month part of the value of the parameter dtm. |
Returns the qualified name of a node.
fn:name ( [argument] ) |
Table 1-137 fn:name function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | node | Any node (including empty XQuery sequences) | Node whose qualified name is to be obtained. |
In the examples of function invocations and their results given below, the XQuery variable book indicates the node representing the elements shown below.
Element represented by the XQuery variable book:
<bookinfo:bookinfo book_id="452469630"> |
Examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | $book/fn:name() | "bookinfo:bookinfo" | Returns the qualified name of the context item, which is the bookinfo:bookinfo element node, because no argument is specified. |
2 | $book/fn:name(./title) | "title" | Returns the qualified name title because the value of the parameter node is the title element node. |
3 | $book/title /fn:name(./text()) | "" (a character string of length zero) | Returns a character string of length zero because the value of the parameter node is a text node. |
Returns the XML namespace URI of the qualified name of a node.
fn:namespace-uri ( [argument] ) |
Table 1-138 fn:namespace-uri function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | node | Any node (including empty XQuery sequences) | Node for which the XML namespace URI is to be obtained from the qualified name |
In the examples of function invocations and their results given below, the XQuery variable book indicates the node representing the elements shown below. The example assumes that the XML namespace URI corresponding to the prefix bookinfo is http://www.hirdb-example.com/bookinfo, and the default XML namespace URI corresponding to the element and attribute names is http://www.hirdb-example.com/default.
Element represented by the XQuery variable book:
<bookinfo:bookinfo book_id="452469630"> |
Examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | $book/fn:namespace-uri() | " http://www.hirdb-example.com/bookinfo" | Returns the XML namespace URI of the context item's qualified name, which is the bookinfo:bookinfo element node because no argument is specified. |
2 | $book/fn:namespace-uri(./title) | " http://www. hirdb-example.com/default" | Returns the XML namespace URI of that qualified name because the value of the parameter node is the title element node. |
3 | $book/title /fn:namespace-uri(./text()) | "" (a character string of length zero) | Returns a character string of length zero because the value of the parameter node is a text node. |
Returns the result of normalizing whitespace in a character string.
Normalizing whitespace in a character string means removing leading and trailing whitespace (one-byte space (X'20'), TAB (X'09'), NL (X'0A'), and CR (X'0D')), and replacing contiguous whitespace with a single one-byte space.
fn:normalize-space ( [argument] ) |
Table 1-139 fn:normalize-space function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | str | xs:string type (including empty XQuery sequences) | Input character string |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | fn:normalize-space(()) | "" (a character string of length zero) | Returns a character string of length zero because the value of the parameter str is an empty XQuery sequence. |
2 | fn:normalize-space(" a b c d ") | "a b c d" | Returns the result of normalizing whitespace of "a b c d ". |
Converts the value specified in an argument to the xs:boolean type and returns the negation of its value.
fn:not ( argument ) |
Table 1-140 fn:not function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence with zero or more XQuery items | Input XQuery sequence |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:boolean type) | Explanation |
---|---|---|---|
1 | fn:not(fn:true()) | FALSE | Returns FALSE because the value of the parameter seq is TRUE. |
2 | fn:not(0) | TRUE | Returns TRUE because 0 evaluates to the Boolean value FALSE. |
3 | fn:not("ABC") | FALSE | Returns FALSE because "ABC" evaluates to the Boolean value TRUE. |
Returns the result of converting the value specified in the argument to the xs:double type.
fn:number ( [argument] ) |
Table 1-141 fn:number function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | item | Any XQuery item (including empty XQuery sequences) | Input XQuery item |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:double type) | Explanation |
---|---|---|---|
1 | fn:number(()) | NaN (not a number) | Returns NaN because the value of the parameter item is an empty XQuery sequence. |
2 | fn:number("abcde") | NaN (not a number) | Returns NaN because "abcde" cannot be converted to xs:double type. |
3 | fn:number(fn:false()) | 0.0E0 | Returns 0.0E0 because the xs:boolean type TRUE converts to the xs:double type value 0.0E0. |
4 | fn:number(" 15000000 ") | 1.5E7 | Returns 1.5E7 because " 15000000 " converts to the xs:double type value 1.5E7. |
5 | fn:number("INF") | Positive infinity | Returns positive infinity because "INF" converts to the xs:double type value positive infinity. |
Returns the context position.
fn:position ( ) |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | ("a", "b", "c")[fn:position() ge 2] | ("b", "c") The results of the fn:position function on the context items "a", "b", "c" are 1, 2, 3 respectively. | The result is the XQuery sequence consisting of "b", "c", which are the context items whose context position is greater than or equal to 2. |
Returns the result of removing the XQuery item at the specified position in the XQuery sequence.
fn:remove ( argument-1, argument-2 ) |
Table 1-142 fn:remove function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | seq | XQuery sequence containing zero or more XQuery items | Input XQuery sequence |
2 | argument-2 | pos | xs:int | Position of the context item to be removed |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | fn:remove(("a", "b", "c"), 0) | ("a", "b", "c") | Returns the value of parameter seq unchanged, because the value of parameter pos is less than 1. |
2 | fn:remove(("a", "b", "c"), 1) | ("b", "c") | Returns the XQuery sequence with the first XQuery item removed. |
3 | fn:remove(("a", "b", "c"), 4) | ("a", "b", "c") | Returns the value of parameter seq unchanged, because the value of parameter pos (4) is greater than the number of XQuery items in the XQuery sequence that is the value of the parameter seq. |
Returns the XQuery sequence that results from sorting the XQuery items in an XQuery sequence in reverse order.
fn:reverse ( argument ) |
Table 1-143 fn:reverse function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence consisting of zero or more arbitrary XQuery items | Input XQuery sequence |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | fn:reverse((10, 20, 30, 40)) | (40,30,20,10) | Returns an XQuery sequence in which the XQuery items in the XQuery sequence in parameter seq have been sorted in reverse order. |
2 | fn:reverse(("abcde")) | ("abcde") | Returns the XQuery sequence in parameter seq unchanged, because there is only one XQuery item in the XQuery sequence in parameter seq. |
3 | fn:reverse(()) | Empty XQuery sequence | Returns an empty XQuery sequence because the XQuery sequence in parameter seq is an empty XQuery sequence. |
Returns the integer value closest to the value of an argument.
fn:round ( argument ) |
Table 1-144 fn:round function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | num | Numeric data type (including empty XQuery sequences) | Input numeric value |
Table 1-145 XQuery data type of the result of the fn:round function
No. | XQuery data type of the value of the parameter num | XQuery data type of the result |
---|---|---|
1 | xs:double | xs:double |
2 | xs:decimal | xs:decimal |
3 | xs:int | xs:int |
Table 1-146 fn:round function special value results
No. | Value of the parameter num | Result value |
---|---|---|
1 | Positive 0 | Positive 0 |
2 | Negative 0 | Negative 0 |
3 | At least -0.5 but less than 0 | Negative 0 |
4 | Positive infinity | Positive infinity |
5 | Negative infinity | Negative infinity |
6 | NaN (not a number) | NaN (not a number) |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (XQuery data type in parentheses) | Explanation |
---|---|---|---|
1 | fn:round(2.5) | 3. (xs:decimal) | Returns 3, the larger of 2 and 3, which are the integers closest to 2.5. |
2 | fn:round(2.4999) | 2. (xs:decimal) | Returns 2, the integer closest to 2.4999. |
3 | fn:round(-2.5) | -2. (xs:decimal) | Returns -2, the larger of -2 and -3, which are the integers closest to -2.5. |
4 | fn:round(-4.5E-1) | Negative 0 (xs:double) | Returns -0, because -4.5E-1 is less than 0 but greater than -0.5. |
Returns only the seconds part extracted from the time stamp.
fn:seconds-from-dateTime ( argument ) |
Table 1-147 fn:seconds-from-dateTime function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dtm | xs:dateTime type (including empty XQuery sequences) | Time stamp to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:decimal type) | Explanation |
---|---|---|---|
1 | fn:seconds-from-dateTime(xs:dateTime("2006-09-26T18:44:58.153")) | 58.153 | Returns 58.153, which is the seconds part of the value of the parameter dtm. |
Returns only the seconds part extracted from the time.
fn:seconds-from-time ( argument ) |
Table 1-148 fn:seconds-from-time function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | tim | xs:time type (including empty XQuery sequences) | Time to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:decimal type) | Explanation |
---|---|---|---|
1 | fn:seconds-from-time(xs:time("18:44:58")) | 58 | Returns 58, which is the seconds part of the value of the parameter tim. |
Returns a value indicating whether the character string specified in argument-1 starts with the character string specified in argument-2.
fn:starts-with ( argument-1, argument-2 ) |
Table 1-149 fn:starts-with function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | str1 | xs:string type (including empty XQuery sequences) | Character string to be checked to determine if it starts with the substring |
2 | argument-2 | str2 | xs:string type (including empty XQuery sequences) | Substring to check against the start of the character string in parameter str1 |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:boolean type) | Explanation |
---|---|---|---|
1 | fn:starts-with("abcdefg", "abc") | TRUE | Returns TRUE because "abcdefg" starts with "abc". |
2 | fn:starts-with("abcdefg", "cde") | FALSE | Returns FALSE because "abcdefg" does not start with "cde". |
3 | fn:starts-with((), "") | TRUE | Returns TRUE because the value of parameter str2 is a character string of length zero. |
4 | fn:starts-with((), "a") | FALSE | Returns FALSE because the value of parameter str1 is an empty XQuery sequence, and the value of parameter str2 is a character string of length 1 or greater. |
5 | fn:starts-with("abcdefg", ()) | TRUE | Returns TRUE because the value of parameter str2 is an empty XQuery sequence. |
Returns the character string representation of the value of an XQuery item as an xs:string type value.
fn:string ( [argument] ) |
Table 1-150 fn:string function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | item | Any XQuery item (including empty XQuery sequences) | Input XQuery item |
Table 1-151 Results when the parameter item is a node
No. | Kind of node | Value returned by the fn:string function |
---|---|---|
1 | Document node | Value of the string-value property |
2 | Element node | Value of the string-value property |
3 | Attribute node | Value of the string-value property |
4 | Processing instruction node | Value of the content property |
5 | Comment node | Value of the content property |
6 | Text node | Value of the content property |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | fn:string(()) | "" (a character string of length zero) | Returns a character string of length zero because the value of the parameter item is an empty XQuery sequence. |
2 | fn:string("abcde") | "abcde" | Returns the character string "abcde" unchanged. |
3 | fn:string(1.234E4) | "12340" | Returns the result of converting the xs:decimal type value 1.234E4 to the xs:string type value "12340". |
4 | fn:string(0.1234E10) | "1.234E9" | Returns the result of converting the xs:decimal type value 0.1234E10 to the xs:string type value "1.234E9". |
5 | fn:string(fn:true()) | "true" | Returns the result of converting the xs:boolean type value TRUE to the xs:string type value "true". |
Returns the length (in number of characters) of a character string.
fn:string-length ( [argument] ) |
Table 1-152 fn:string-length function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | str | xs:string type (including empty XQuery sequences) | Input character string |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:string-length(()) | 0 | Returns 0, because the value of parameter str is an empty XQuery sequence. |
2 | fn:string-length("abcde") | 5 | Returns 5, which is the length of "abcde". |
3 | fn:string-length("![]() | 5 | Returns 5, which is the length of "![]() |
Returns an XQuery subsequence of an XQuery sequence.
fn:subsequence ( argument-1, argument-2[, argument-3] ) |
Table 1-153 fn:subsequence function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | seq | XQuery sequence consisting of zero or more XQuery items | XQuery sequence from which to extract the XQuery subsequence |
2 | argument-2 | pos | xs:double type | Starting position from which to extract the XQuery subsequence |
3 | argument-3 | len | xs:double type | Number of XQuery items to extract |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result | Explanation |
---|---|---|---|
1 | fn:subsequence( ("a","b","c","d","e","f","g"), 5) | ("e","f","g") | Returns the XQuery sequence consisting of XQuery items from the fifth position until the end of the XQuery sequence in parameter seq. |
2 | fn:subsequence( ("a","b","c","d","e","f","g"), 2, 2.5) | ("b","c","d") | Returns the XQuery sequence consisting of three XQuery items starting from the second position of the XQuery sequence in parameter seq because the result of evaluating the fn:round function on 2.5 is 3. |
3 | fn:subsequence((), 10) | Empty XQuery sequence | Returns an empty XQuery sequence because parameter seq is an empty XQuery sequence. |
4 | fn:subsequence (("a","b","c","d","e","f","g"), -10, 10) | ("a","b","c","d", "e","f","g") | Extraction starts from the first position because parameter pos is negative. Extraction continues to the end because the value of parameter len is greater than the number of XQuery items from the starting position until the end of parameter seq. |
Returns a substring of a character string.
fn:substring ( argument-1, argument-2[, argument-3] ) |
Table 1-154 fn:substring function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | str | xs:string type (including empty XQuery sequences) | Character string from which to extract a substring |
2 | argument-2 | pos | xs:double type | Starting position of the substring to be extracted |
3 | argument-3 | len | xs:double type | Length (in number of characters) of the substring to be extracted |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | fn:substring ("abcdefg", 5) | "efg" | Returns the substring from the fifth character until the end of "abcdefg". |
2 | fn:substring("abcdefg", 2, 2.5) | "bcd" | Returns the three-character substring starting from the second character of "abcdefg", because the result of using the fn:round function to evaluate 2.5 is 3. |
3 | fn:substring((), 10) | "" (a character string of length zero) | Returns a character string of length zero because the value of the parameter str is an empty XQuery sequence. |
4 | fn:substring ("abcdefg",-10, 10) | "abcdefg" | Extraction starts from the first position because the value of parameter pos is negative. Extraction continues to the end because the value of parameter len is greater than the length from the starting position to the end of "abcdefg". |
Returns a substring of the character string specified in argument-1 that begins immediately after the position of the first occurrence of the character string specified in argument-2.
fn:substring-after ( argument-1, argument-2 ) |
Table 1-155 fn:substring-after function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | str1 | xs:string type (including empty XQuery sequences) | Character string in which to find the substring |
2 | argument-2 | str2 | xs:string type (including empty XQuery sequences) | Substring to find in the character string in parameter str1 |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | fn:substring-after("abcdefg", "efg") | "" (a character string of length zero) | Returns the substring after the position of the first occurrence of "eft" in "abcdefg". |
2 | fn:substring-after("abcdefgcde", "cde") | "fgcde" | Returns the substring after the position of the first occurrence of "cde" in "abcdefgcde". |
3 | fn:substring-after((), "abc") | "" (a character string of length zero) | Returns a character string of length zero because the value of parameter str1 is an empty XQuery sequence. |
4 | fn:substring-after("abcdefg", ()) | "abcdefg" | Returns "abcdefg" unchanged, because the value of parameter str2 is an empty XQuery sequence. |
Returns a substring of the character string specified in argument-1 that ends immediately before the position of the first occurrence of the character string specified in argument-2.
fn:substring-before ( argument-1, argument-2 ) |
Table 1-156 fn:substring-before function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | str1 | xs:string type (including empty XQuery sequences) | Character string in which to find the substring |
2 | argument-2 | str2 | xs:string type (including empty XQuery sequences) | Substring to find in the character string in parameter str1 |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | fn:substring-before("abcdefg", "abc") | "" (a character string of length zero) | Returns the substring before the position where "abc" occurs in "abcdefg". |
2 | fn:substring-before("abcdefgdef", "def") | "abc" | Returns the substring before the position where "def" occurs in "abcdefgdef". |
3 | fn:substring-before((), "abc") | "" (a character string of length zero) | Returns a character string of length zero because the value of parameter str1 is an empty XQuery sequence. |
4 | fn:substring-before("abcdefg", ()) | "abcdefg" | Returns "abcdefg" unchanged, because the value of parameter str2 is an empty XQuery sequence. |
Returns the sum of the atomic values that make up an XQuery sequence.
fn:sum ( argument ) |
Table 1-157 fn:sum function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | seq | XQuery sequence with zero or more numeric data type values | Input XQuery sequence |
Table 1-158 XQuery data type of the result of the fn:sum function
No. | XQuery data type of the value of the XQuery sequence that is the value of the parameter seq | XQuery data type of the result | ||
---|---|---|---|---|
xs:double | xs:decimal | xs:int | ||
1 | N | N | N | xs:int |
2 | Y | -- | -- | xs:double |
3 | N | Y | -- | xs:decimal |
4 | N | Y | xs:int |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (XQuery data type in parentheses) | Explanation |
---|---|---|---|
1 | fn:sum((3,4,5)) | 12 (xs:int) | Returns 12, which is the value of the sum of 3, 4, and 5. |
2 | fn:sum(()) | 0 (xs:int) | Returns 0, because the parameter seq is an empty XQuery sequence. |
3 | fn:sum((1.0E2, 2.0E3)) | 2.1E3 (xs:double) | Returns 2.1E3, which is the value of the sum of 1.0E2 and 2.0E3. |
Returns the result of replacing the characters specified in argument-2 with the characters specified in argument-3 in the character string specified in argument-1.
fn:translate ( argument-1, argument-2, argument-3 ) |
Table 1-159 fn:translate function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument-1 | str | xs:string type (including empty XQuery sequences) | Input character string |
2 | argument-2 | from | xs:string type | Character string consisting of characters to be replaced |
3 | argument-3 | to | xs:string type | Character string consisting of replacement characters |
The following table provides examples of function invocations and their results:
No. | Function invocation | Result (xs:string type) | Explanation |
---|---|---|---|
1 | fn:translate("abcdef", "ace", "ACE") | "AbCdEf" | Returns the character string in which each of a, c, e in "abcdef" is replaced with A, C, E, respectively. |
2 | fn:translate("abcdefg", "aceg", "ACE") | "AbCdEf" | Returns the character string in which each of a, c, e in "abcdefg" is replaced with A, C, E, respectively, and g is removed. |
3 | fn:translate("abcdef", "acea", "ACEB") | "AbCdEf" | Returns the character string in which each of a, c, e in "abcdef" is replaced with A, C, E, respectively. |
Returns TRUE.
fn:true ( ) |
Returns only the year part extracted from the date.
fn:year-from-date ( argument ) |
Table 1-160 fn:year-from-date function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dat | xs:date type (including empty XQuery sequences) | Date to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:year-from-date(xs:date("2006-09-26")) | 2006 | Returns 2006, the year part of the value of parameter dat. |
Returns only the year part extracted from the time stamp.
fn:year-from-dateTime ( argument ) |
Table 1-161 fn:year-from-dateTime function parameters
No. | Corresponding argument | Parameter | XQuery data type | Explanation |
---|---|---|---|---|
1 | argument | dtm | xs:dateTime type (including empty XQuery sequences) | Time stamp to extract from |
The following table provides an example of a function invocation and its result:
No. | Function invocation | Result (xs:int type) | Explanation |
---|---|---|---|
1 | fn:year-from-dateTime(xs:dateTime("2006-09-26T18:44:58.153")) | 2006 | Returns 2006, which is the year part of the value of the parameter dtm. |