bea.com | products | dev2dev | support | askBEA

Download Docs | Site Map | Glossary
Search

Building Queries and Data Views

Sequence Functions

A sequence is an ordered collection of zero or more items. An item may be a node or a simple typed value. Therefore, a sequence can be an ordered collection of nodes, a collection of simple typed values, or any mix of nodes and simple typed values. Sequences may not contain other sequences but may contain duplicate items. There is no difference between a single item, such as a node or a simple typed value, and a sequence containing that single item.

- xf:distinct-values

- xf:empty

- xf:subsequence (format 1)

- xf:subsequence (format 2)

xf:distinct-values

If the source value contains only nodes, the function removes duplicates and returns a subset of unique values.

Data Types

- Input data type: xsext:item*

- Returned data type: xsext:anyValue*

Notes

The Liquid Data xf:distinct-values function varies from the standard XQuery function by removing duplicates from the result.

If the source value is an empty list, the function returns an empty list.

XQuery Specification Compliance

- Liquid Data does not support the distinct-values format that accepts collations.

- Liquid Data uses the eq operator instead of xf:deep-equal to identify duplicates.

- Liquid Data does not support duration values.

Examples

- xf:distinct-values(("a", "b", "c", "b")) returns the string sequence ("a", "b", "c").

- xf:distinct-values((<x>a</x>, <x>b</x>, <x>c</x>, <x>b</x>)) returns the string sequence (<x>a</x>, <x>b</x>, <x>c</x>).

- xf:distinct-values(("a", <x>b</x>, <x>c</x>, "b")) generates a compile-time error because the list contains mixed nodes and values.

xf:empty

Returns true if the specified list of items is empty; otherwise, returns false.

Data Types

- Input data type: xsext:item*

- Returned data type: xs:boolean?

XQuery Specification Compliance

Liquid Data supports an optional boolean returned value.

Examples

- xf:empty((1, 2, 3)) returns the boolean value false.

- xf:empty(1) returns the boolean value false.

- xf:empty(()) returns the boolean value true.

xf:subsequence (format 1)

Returns the contiguous sequence of items described by Parameter 1 beginning at the position indicated by the Parameter 2 and continuing until the end of the sequence.

Data Types

- Parameter1 data type: xsext:item*

- Parameter2 data type: xs:integer

- Returned data type: xsext:item*

Notes

The first item of a sequence is located at position 1, not position 0.

If you omit the length parameter, the function returns all items up to the end of the source sequence.

If the starting location is greater than the number of items in the sequence, the function returns an empty list.

If the item list is empty, Liquid Data returns an empty list.

XQuery Specification Compliance

- Liquid Data supports xs:integer instead of xs:decimal as the starting location and length parameters.

- If the starting location is greater than the length of the input sequence, Liquid Data returns an empty list instead of generating an error.

Examples

- xf:subsequence(("a", "b", "c", "d", "e"), 2) returns the sequence ("b", "c", "d", "e").

- xf:subsequence("abcde", 2) returns the string value "bcde."

- xf:subsequence("abcde", 6) returns the empty string "".

- xf:subsequence("abcde", 2, 3) returns the string value "bcd."

- xf:subsequence("abcde", 2, 10) returns the string value "bcde."

- xf:subsequence("abcde", ()) returns an empty list ().

xf:subsequence (format 2)

Returns the contiguous sequence of items described by Parameter 1 beginning at the position indicated by the Parameter 2 and continuing for the number of items indicated by the value of Parameter 3.

Data Types

- Parameter1 data type: xsext:item*

- Parameter2 data type: xs:integer

- Parameter3 data type: xs:integer

- Returned data type: xsext:item*

Notes

The value of Parameter 2 can be greater than the number of items in the value of Parameter 1, in which case the subsequence includes items to the end of Parameter 3.

If the sum of the starting location and the length parameter is greater than the length of the source sequence, the function returns all items up to the end of the sequence.

The first item of a sequence is located at position 1, not position 0.

If the starting location is greater than the number of items in the sequence, the function returns an empty list.

If the item list is an empty list, Liquid Data returns an empty list.

Liquid Data is able to process either format of xf:subsequence. Adding a third parameter automatically invokes Format 2.

XQuery Specification Compliance

- cimal as the starting location and length parameters.

- If the starting location is greater than the length of the input sequence, Liquid Data returns an empty list instead of generating an error.

Examples

- xf:subsequence(("a", "b", "c", "d", "e"), 2) returns the sequence ("b", "c", "d", "e").

- xf:subsequence("abcde", 2) returns the string value "bcde."

- xf:subsequence("abcde", 6) returns the empty string "".

- xf:subsequence("abcde", 2, 3) returns the string value "bcd."

- xf:subsequence("abcde", 2, 10) returns the string value "bcde."

- xf:subsequence("abcde", ()) returns an empty list ().