Home >>XQuery Tutorial >XQuery Functions
XQuery 1.0, XPath 2.0, and XSLT 2.0 use one and the same library features.
Different types of XQuery Functions are :
Functions are defined by fn: prefix. For example: fn: string). But fn: is the default namespace prefix, so when calling a feature you don't need to be prefix fn.
Sr No | Name | Description |
---|---|---|
1. | fn:node-name(node) | This is used to return argument node-name. |
2. | fn:nilled(node) | It is used to return a Boolean value which indicates whether the argument node is nil. |
3. | fn:data(item.item,...) | A series of objects is taken and a set of atomic values released. |
4. | fn:base-uri() fn:base-uri(node) | It returns the value of current or defined node base-uri property. |
5. | fn:document-uri(node) | It returns the document-uri property value for the node you specify. |
Sr No | Name | Description |
---|---|---|
1. | fn:error() fn:error(error) fn:error(error,description) fn:error(error,description,error-object) | Example: error(fn:qname('http://example.com/test', 'err:toohigh'), 'error: price is too high')result: returns http://example.com/test#toohigh and the string "error: price is too high" to the external processing environment. |
2. | fn:trace(value,label) | it is used to debug queries. |
Sr No | Name | Description |
---|---|---|
1. | fn:abs(num) | It is used to returns the absolute value of the argument. For example: abs(2.05) Result: 2.05 |
2. | fn:abs(num) | It is used to returns the absolute value of the argument For example: abs(2.05) Result: 2.05 Example: abs(-2.05) Result: 2.05 |
3. | fn:ceiling(num) | It is used to returns the smallest integer that is greater than the number argument For example: ceiling(2.05) Result: 3 |
4. | fn:floor(num) | It returns the largest integer that is not greater than the number argument For example: floor(2.05) Result: 2 |
5. | fn:round(num) | It is used to round of the number argument to the nearest integer For example: round(2.05) Result: 2 |
6. | fn:round-half-to-even() | Example: round-half-to-even(0.5) Result: 0 Example: round-half-to-even(1.5) Result: 2 Example: round-half-to-even(2.5) Result: 2 |
There are a number of string functions used in XQuery but we use the chosen one here.
A list of widely used XQuery string manipulation functions:
Sr No | Name | Description |
---|---|---|
1. | string-length($string as xs:string) as xs:integer | It is used to returns the length of the string. |
2. | concat($input as xs:anyatomictype?) as xs:string | It is used to returns the concatenated string as output. |
3. | string-join($sequence as xs:string*, $delimiter as xs:string) as xs:string | It is used to returns the combination of items in a sequence separated by a delimiter. |
Sr No | Name | Description |
---|---|---|
1. | fn:boolean(arg) | It is used to return a number, string, or node-set ,Boolean value. |
2. | fn:not(arg) | This specifies that, by implementing the function Boolean(),the statement is first reduced to a Boolean value. If the Boolean value is null, it returns true, and false if the Boolean value is valid. For example: not(true()) Result: false |
3. | fn:true() | It is used to returns the Boolean value true Example: true() Result: true |
4. | fn:false() | It is used to returns the Boolean value false For example: false() Result: false |
XQuery supports a lot of time and date feature, but here we have the chosen one.
XQuery includes a list of several widely used date and time functions:
Sr No | Name | Description |
---|---|---|
1. | current-date() | It is used to return the current date. |
2. | current-time() | It is used to return the current time. |
3. | current-datetime() | It is used to return both the current date and the current time. |