Advertisement

XPath, XQuery and XSLT functions

Access function

name Explanation
fn: node-name (node) Returns the node name parameter node.
fn: nilled (node) Returns whether to reject the argument node Boolean value.
fn: data (item.item, ...) Accept the project sequence and returns the sequence of atomic values.
  • fn: base-uri ()
  • fn: base-uri (node)
Returns the value of the current base-uri attribute specifies the node or nodes.
fn: document-uri (node) Returns the value of the specified node document-uri property.

Errors and tracking functions

name Explanation
  • fn: error ()
  • fn: error (error)
  • fn: error (error, description)
  • fn: error (error, description, error-object)

Examples: error (fn: QName ( 'http://example.com/test', 'err: toohigh'), 'Error: Price is too high')

Results: Returns http://example.com/test#toohigh and string to the external processing environment "Error: Price is too high".

fn: trace (value, label) It is used to query debug.

Functions related values

name Explanation
fn: number (arg)

Returns the value of the parameter. Parameter is a Boolean value, string, or node set.

Examples: number ( '100')

Results: 100

fn: abs (num)

Returns the absolute value of the parameter.

Examples: abs (3.14)

Results: 3.14

Examples: abs (-3.14)

Results: 3.14

fn: ceiling (num)

Returns the smallest integer greater than num parameter.

Examples: ceiling (3.14)

Results: 4

fn: floor (num)

Returns the largest integer not greater than num parameter.

Examples: floor (3.14)

Results: 3

fn: round (num)

The num argument rounded to the nearest integer.

Examples: round (3.14)

Results: 3

fn: round-half-to-even ()

Examples: round-half-to-even (0.5)

Results: 0

Examples: round-half-to-even (1.5)

Results: 2

Examples: round-half-to-even (2.5)

Results: 2

Functions about strings

name Explanation
fn: string (arg)

Returns the string value of the parameter. Arguments can be numbers, logical values, or set of nodes.

Examples: string (314)

Result: The "314"

fn: codepoints-to-string (int, int, ...)

According to the code point sequence returns a string.

Examples: codepoints-to-string (84, 104, 233, 114, 232, 115, 101)

Results: 'Therese'

fn: string-to-codepoints (string)

According to string return code point sequence.

Examples: string-to-codepoints ( "Therese")

Result: 84, 104, 233, 114, 232, 115, 101

fn: codepoint-equal (comp1, comp2) According to the Unicode code point comparison, if the value is equal to the value comp1 comp2 Returns true. (Http://www.w3.org/2005/02/xpath-functions/collation/codepoint), otherwise it returns false.
  • fn: compare (comp1, comp2)
  • fn: compare (comp1, comp2, collation)

If comp1 less than comp2, -1 is returned. If comp1 equal comp2, 0 is returned. If comp1 greater than comp2, 1 is returned. (According to the rules used by the control).

Example: compare ( 'ghi', 'ghi')

Results: 0

fn: concat (string, string, ...)

Returns the string concatenation.

Examples: concat ( 'XPath', 'is', 'FUN!')

Results: 'XPath is FUN!'

fn: string-join ((string, string, ...), sep)

Use sep as the delimiter argument to return the string parameter string after stitching.

Examples: string-join (( 'We', 'are', 'having', 'fun!'), '')

Results: 'We are having fun!'

Examples: string-join (( 'We', 'are', 'having', 'fun!'))

Results: 'Wearehavingfun!'

Examples: string-join ((), 'sep')

result:''

  • fn: substring (string, start, len)
  • fn: substring (string, start)

Returns the substring from the start position of the beginning of the specified length. Index of the first character is 1. If you omit the len argument from the start position to the end of a string is returned.

Examples: substring ( 'Beatles', 1,4)

Results: 'Beat'

Examples: substring ( 'Beatles', 2)

Results: 'eatles'

  • fn: string-length (string)
  • fn: string-length ()

Returns the length of the string. If there is no string argument, the length of the string value of the current node is returned.

Examples: string-length ( 'Beatles')

Results: 7

  • fn: normalize-space (string)
  • fn: normalize-space ()

Remove the beginning and end of the specified string blank, blank and all replaced by a series of internal and returns the result. If there is no string argument, the process of the current node.

Examples: normalize-space ( 'The XML')

Results: 'The XML'

fn: normalize-unicode () Implementation of Unicode normalization.
fn: upper-case (string)

The string argument to uppercase.

Examples: upper-case ( 'The XML')

Results: 'THE XML'

fn: lower-case (string)

The string argument converted to lowercase.

Examples: lower-case ( 'The XML')

Results: 'the xml'

fn: translate (string1, string2, string3)

The string1 in string2 replaced string3.

Examples: translate ('12: 30 ',' 30 ',' 45 ')

Results: '12: 45 '

Examples: translate ('12: 30 ',' 03 ',' 54 ')

Results: '12: 45 '

Examples: translate ('12: 30 ',' 0123 ',' abcd ')

Results: 'bc: da'

fn: escape-uri (stringURI, esc-res)

Examples: escape-uri ( "http://example.com/test#car", true ())

Results: "http% 3A% 2F% 2Fexample.com% 2Ftest # car"

Examples: escape-uri ( "http://example.com/test#car", false ())

Results: "http://example.com/test#car"

Examples: escape-uri ( "http://example.com/~bebe", false ())

Results: "http://example.com/~b%C3%A9b%C3%A9"

fn: contains (string1, string2)

If string1 contains string2, it returns true, otherwise returns false.

Examples: contains ( 'XML', 'XM')

Results: true

fn: starts-with (string1, string2)

If string1 starts with string2, it returns true, otherwise returns false.

Examples: starts-with ( 'XML', 'X')

Results: true

fn: ends-with (string1, string2)

If string1 with string2 end returns true, otherwise it returns false.

Examples: ends-with ( 'XML', 'X')

Results: false

fn: substring-before (string1, string2)

Returns a substring of string1 string2 appear before.

Examples: substring-before ('12 / 10 ',' / ')

Results: '12 '

fn: substring-after (string1, string2)

Returns a substring of string1 string2 appear later.

Examples: substring-after ('12 / 10 ',' / ')

Results: '10 '

fn: matches (string, pattern)

If string matches the specified pattern, it returns true, otherwise returns false.

Examples: matches ( "Merano", "ran")

Results: true

fn: replace (string, pattern, replace)

The specified mode is replaced replace parameter and returns the result.

Examples: replace ( "Bella Italia", "l", "*")

Results: 'Be ** a Ita * ia'

Examples: replace ( "Bella Italia", "l", "")

Results: 'Bea Itaia'

fn: tokenize (string, pattern)

Examples: tokenize ( "XPath is fun", "\ s +")

Results :( "XPath", "is", "fun")

AnyURI function for

name Explanation
fn: resolve-uri (relative, base)

Functions of Boolean values

name Explanation
fn: boolean (arg) Returns a Boolean value numeric, string, or node set.
fn: not (arg)

Firstly, boolean () function to restore the parameters of a Boolean value. If the Boolean value is false, it returns true, otherwise it returns true.

Example: not (true ())

Results: false

fn: true ()

Returns a Boolean value true.

Examples: true ()

Results: true

fn: false ()

Returns a Boolean value false.

Examples: false ()

Results: false

Functions related to the duration, date and time

Date, time, duration of components extraction function

name Explanation
fn: dateTime (date, time) The arguments to date and time.
fn: years-from-duration (datetimedur) The integer part of the Year of the return value of a standard notation to represent words.
fn: months-from-duration (datetimedur) Returns the integer portion of the parameter values ​​of the month, a standard notation to represent words.
fn: days-from-duration (datetimedur) Returns the integer portion of the parameter values ​​of the day, a standard notation to represent words.
fn: hours-from-duration (datetimedur) Returns the integer portion of the parameter values ​​of the hour, the standard notation to represent words.
fn: minutes-from-duration (datetimedur) Returns the integer part of the minutes of the parameter values, the standard notation to represent words.
fn: seconds-from-duration (datetimedur) Returns the decimal part of the number of minutes of parameter values, a standard notation to represent words.
fn: year-from-dateTime (datetime)

Returns the integer parameter values ​​in the local section.

Examples: year-from-dateTime (xs: dateTime ( "2005-01-10T12: 30-04: 10"))

Results: 2005

fn: month-from-dateTime (datetime)

Returns the integer portion of the monthly local parameter values.

Examples: month-from-dateTime (xs: dateTime ( "2005-01-10T12: 30-04: 10"))

Results: 01

fn: day-from-dateTime (datetime)

Returns the integer portion of the day local parameter values.

Examples: day-from-dateTime (xs: dateTime ( "2005-01-10T12: 30-04: 10"))

Results: 10

fn: hours-from-dateTime (datetime)

Returns the integer portion of the parameter hours local values.

Examples: hours-from-dateTime (xs: dateTime ( "2005-01-10T12: 30-04: 10"))

Results: 12

fn: minutes-from-dateTime (datetime)

Returns the integer portion of the parameters of the local minute value.

Examples: minutes-from-dateTime (xs: dateTime ( "2005-01-10T12: 30-04: 10"))

Results: 30

fn: seconds-from-dateTime (datetime)

Returns the decimal part of the second local parameter values.

Examples: seconds-from-dateTime (xs: dateTime ( "2005-01-10T12: 30: 00-04: 10"))

Results: 0

fn: timezone-from-dateTime (datetime) Returns the region portion, if present.
fn: year-from-date (date)

In return integer values ​​that represent the local parameters.

Examples: year-from-date (xs: date ( "2005-04-23"))

Results: 2005

fn: month-from-date (date)

Integer month Returns the local value of the parameter indicated.

Examples: month-from-date (xs: date ( "2005-04-23"))

Results: 4

fn: day-from-date (date)

Day return an integer value represents the local parameter.

Examples: day-from-date (xs: date ( "2005-04-23"))

Results: 23

fn: timezone-from-date (date) Returns the region portion, if present.
fn: hours-from-time (time)

Returns the integer portion hours local parameter values ​​represented.

Examples: hours-from-time (xs: time ( "10:22:00"))

Results: 10

fn: minutes-from-time (time)

Returns the integer part of the parameters of the local minute value represents.

Examples: minutes-from-time (xs: time ( "10:22:00"))

Results: 22

fn: seconds-from-time (time)

The integer part of the second parameter return value indicates the local.

Examples: seconds-from-time (xs: time ( "10:22:00"))

Results: 0

fn: timezone-from-time (time) Returns the region portion, if present.
fn: adjust-dateTime-to-timezone (datetime, timezone) If the timezone argument is empty, it returns no dateTime time zone. Otherwise, it returns dateTime with time zone.
fn: adjust-date-to-timezone (date, timezone) If the timezone argument is empty, it returns no date time zone. Otherwise, it returns date with time zone.
fn: adjust-time-to-timezone (time, timezone) If the timezone argument is empty, it returns no time time zone. Otherwise time with time zone.

And QNames related functions

name Explanation
fn: QName ()
fn: local-name-from-QName ()
fn: namespace-uri-from-QName ()
fn: namespace-uri-for-prefix ()
fn: in-scope-prefixes ()
fn: resolve-QName ()

A function of the node

name Explanation
  • fn: name ()
  • fn: name (nodeset)
Returns the current node name or specify the first node of the cluster.
  • fn: local-name ()
  • fn: local-name (nodeset)
Returns the first of the current node name or specify a node in the cluster - with no namespace prefix.
  • fn: namespace-uri ()
  • fn: namespace-uri (nodeset)
Returns the specified node or nodes in the cluster current namespace URI of the first node.
fn: lang (lang)

If the language of the current node matches the specified language, it returns true.

Examples: Lang ( "en") is true for <p xml: lang = "en"> ... </ p>

Examples: Lang ( "de") is false for <p xml: lang = "en"> ... </ p>

  • fn: root ()
  • fn: root (node)
Returns the root node of the tree or the current node specified node belongs. Usually a document node.

Functions related sequences

General function

name Explanation
fn: index-of ((item, item, ...), searchitem)

Back in the project equal to the sequence position searchitem parameters.

Examples: index-of ((15, 40, 25, 40, 10), 40)

Results: (2, 4)

Examples: index-of (( "a", "dog", "and", "a", "duck"), "a")

Result (1, 4)

Examples: index-of ((15, 40, 25, 40, 10), 18)

result:()

fn: remove ((item, item, ...), position)

It returns a new sequence of item parameter configuration - delete position parameter specifies the project.

Examples: remove (( "ab", "cd", "ef"), 0)

Results :( "ab", "cd", "ef")

Examples: remove (( "ab", "cd", "ef"), 1)

Results :( "cd", "ef")

Examples: remove (( "ab", "cd", "ef"), 4)

Results :( "ab", "cd", "ef")

fn: empty (item, item, ...)

If the parameter value is an empty sequence, it returns true, otherwise returns false.

Examples: empty (remove (( "ab", "cd"), 1))

Results: false

fn: exists (item, item, ...)

If the parameter value is not an empty sequence, it returns true, otherwise returns false.

Examples: exists (remove (( "ab"), 1))

Results: false

fn: distinct-values ​​((item, item, ...), collation)

The only return different values.

Examples: distinct-values ​​((1, 2, 3, 1, 2))

Results: (1, 2, 3)

fn: insert-before ((item, item, ...), pos, inserts)

It returns a new sequence constructed by the item parameter - parameter specifying the location of the insertion inserts the value of the pos parameter.

Examples: insert-before (( "ab", "cd"), 0, "gh")

Results :( "gh", "ab", "cd")

Examples: insert-before (( "ab", "cd"), 1, "gh")

Results :( "gh", "ab", "cd")

Examples: insert-before (( "ab", "cd"), 2, "gh")

Results :( "ab", "gh", "cd")

Examples: insert-before (( "ab", "cd"), 5, "gh")

Results :( "ab", "cd", "gh")

fn: reverse ((item, item, ...))

Returns reverse the order of the specified items.

Examples: reverse (( "ab", "cd", "ef"))

Results :( "ef", "cd", "ab")

Examples: reverse (( "ab"))

Results :( "ab")

fn: subsequence ((item, item, ...), start, len)

Returns the start parameter specifies the location of the project to return the sequence, sequence length specified by len parameter. Location of the first project is 1.

Examples: subsequence (($ item1, $ item2, $ item3, ...), 3)

Results: ($ item3, ...)

Examples: subsequence (($ item1, $ item2, $ item3, ...), 2, 2)

Results: ($ item2, $ item3)

fn: unordered ((item, item, ...)) According to the order of implementation decisions to return to the project.

Capacity test sequence function

name Explanation
fn: zero-or-one (item, item, ...) If a parameter contains zero or one item, then return parameters, otherwise an error is generated.
fn: one-or-more (item, item, ...) If a parameter contains one or more items, then return parameters, otherwise an error is generated.
fn: exactly-one (item, item, ...) If a parameter contains an item, then return parameters, otherwise an error is generated.

Equals, Union, Intersection and Except

name Explanation
fn: deep-equal (param1, param2, collation) If param1 and param2 and equal to each other (deep-equal), returns true, otherwise returns false.

Aggregate function

name Explanation
fn: count ((item, item, ...)) Returns the number of nodes.
fn: avg ((arg, arg, ...)) The average return parameter values. Examples: avg ((1,2,3)) Result: 2
fn: max ((arg, arg, ...)) Returns the parameter is greater than the other parameters. Examples: max ((1,2,3)) Results: Examples 3: max (( 'a', 'k')) results: 'k'
fn: min ((arg, arg, ...)) Back smaller than the other parameters of the parameters. Examples: min ((1,2,3)) Results: Examples 1: min (( 'a', 'k')) Results: 'a'
fn: sum (arg, arg, ...) Returns the specified node set the sum value of each node.

Sequence generation function

name Explanation
fn: id ((string, string, ...), node) Returns a sequence of element nodes that have an ID value equal to the value of one or more of the values ​​specified in the string argument
fn: idref ((string, string, ...), node) Returns a sequence of element or attribute nodes that have an IDREF value equal to the value of one or more of the values ​​specified in the string argument
fn: doc (URI)
fn: doc-available (URI) If the doc () function returns the document node, it returns true, otherwise returns false.
  • fn: collection ()
  • fn: collection (string)

Context functions

name Explanation
fn: position ()

It returns the index position of the node being processed.

Examples: // book [position () <= 3]

Results: Select the first three elements of book

fn: last ()

It returns the number of items in the list of nodes being processed.

Examples: // book [last ()]

Results: Select the last element of a book

fn: current-dateTime () It returns the current dateTime (with time zone).
fn: current-date () Returns the current date (with time zone).
fn: current-time () It returns the current time (with time zone).
fn: implicit-timezone () Return value implicit time zone.
fn: default-collation () Control returns to the default value.
fn: static-base-uri () The return value of the base-uri.