bea.com | products | dev2dev | support | askBEA
 Download Docs   Site Map   Glossary 
Search

Building Queries and Data Views

 Previous Next Contents Index View as PDF  

Functions Reference

The World Wide Web (W3C) specification for XQuery supports a discrete set of functions. BEA Liquid Data for WebLogicTM supports a subset of those functions as built-in functions. The Liquid Data built-in functions are accessible in the Data View Builder from Builder Toolbar—>Toolbox tab—>Functions panel. (See also Functions in Starting the Builder and Touring the GUI.)

For more information on the functions described here, see also:

This section provides a complete reference of the W3C functions supported in Liquid Data. This functions reference is organized by category as follows:

 


Data Types

Every data element or variable has a data type. Function parameters have data type requirements and the function result is returned as a data type. The following table describes other data types that conform to the XQuery specification. Current compliance with the W3C XQuery specification extends to XQuery 1.0 and XPath 2.0 Functions and Operators specification dated 30 April 2002. Another helpful reference is XML Schema Part 2: Datatypes.

Table A-1 Data Types

Data Type Name

Description

xs:anyType

Represents the most generic data type. All data types including anyAttribute, anyElement, anySimpleType, anyValue, as well as sequences, items, nodes, strings, decimals.

xsext:anyValue

A subset of xs:anyType including dateTime, boolean, string, numeric values, or any single value. Does not include anyAttribute, anyElement, item, node, sequence, or anySimpleType.

xs:boolean

A subset of xsext:anyValue. A value that supports the mathematical concept of binary-valued logic: true or false.

xs:byte

A subset of xs:short. A sequence of decimal digits (0-9) with a range of 127 to -128. If the sign is omitted, plus  (+) is assumed.

Examples: -1, 0, 126, +100

xs:date

A subset of xsext:anyValue. Represents the leftmost component of dateTime YYYY-MM-DD where:

May be preceded by a leading minus  (-) sign to indicate a negative number. If the sign is omitted, plus  (+) is assumed.

May be immediately followed by a Z to indicate Coordinated Universal Time (UTC) or, to indicate the time zone (the difference between the local time and Coordinated Universal Time), immediately followed by a sign, + or -, followed by the difference from UTC represented as hh:mm.

Example:

To specify 1:20 pm on May the 31st, 1999, write: 1999-05-31.

xs:dateTime

A subset of xsext:anyValue. Represents the format YYYY-MM-DDThh:mm:ss where:

May be preceded by a leading minus  (-) sign to indicate a negative number. If the sign is omitted, plus  (+) is assumed. Additional digits can be used to increase the precision of fractional seconds if desired (ss.ss...) with any number of digits after the decimal point is supported.

May be immediately followed by a Z to indicate Coordinated Universal Time (UTC) or, to indicate the time zone (the difference between the local time and Coordinated Universal Time), immediately followed by a sign, + or -, followed by the difference from UTC represented as hh:mm.

Example:

To specify 1:20 pm on May the 31st, 1999 EST, which is five hours behind Coordinated Universal Time (UTC), write: 1999-05-31T13:20:00-05:00.

xs:decimal

A subset of xsext:anyValue. Includes all integer types, such as xs:integer, xs:long, xs:short, xs:int, or xs:byte.

Represents a finite-length sequence of decimal digits (0-9) separated by an optional period as a decimal indicator. An optional leading sign is allowed. If the sign is omitted, plus  (+) is assumed. Leading and trailing zeroes are optional. If the fractional part is zero, the period and following zeroes can be omitted.

Examples: -1.23, 12678967.543233, +100000.00, 210

xs:double

A subset of xsext:anyValue. There are no subordinate data types; however, xs:float and xs:decimal, and all derived types, can be promoted to xs:double in certain cases, such as function calls.

Represents a double precision 64-bit floating point value. Supports the special values positive and negative zero, positive and negative infinity and not-a-number (0, -0, INF, -INF and NaN).

xs:float

A subset of xsext:anyValue. There are no subordinate data types; however, xs:decimal, and all derived types, can be promoted to xs:float in certain cases, such as function calls.

Represents a single-precision 32-bit floating point value. Supports the special values positive and negative zero, positive and negative infinity and not-a-number (0, -0, INF, -INF and NaN).

xsext:item

A subset of xs:anyType. Includes xsext:anyValue and xsext:node. Excludes any sequence. Represents a list element, individual value, or attribute.

xs:int

A subset of xs:long. Represents a finite-length sequence of decimal digits (0-9). An optional leading sign is allowed. If the sign is omitted, plus  (+) is assumed.

Examples: -1, 0, 12678967543233, +100000

xs:integer

A subset of xs:decimal. Represents a finite-length sequence of decimal digits (0-9). An optional leading sign is allowed. If the sign is omitted, plus  (+) is assumed.

Examples: -1, 0, 12678967543233, +100000

xs:long

A subset of xs:decimal. A sequence of decimal digits (0-9) with a range of 9223372036854775807 to -9223372036854775808. If the sign is omitted, plus  (+) is assumed.

Examples: -1, 0, 12678967543233, +100000

xsext:node

A subset of xsext:anyValue. A component in a tree structure that represents a data element.

xs:short

A subset of xs:int. A sequence of decimal digits (0-9) with a range of 32767 to -32768. If the sign is omitted, plus  (+) is assumed.

Examples: -1, 0, 12678, +10000

xs:string

A subset of xsext:anyValue. A sequence that contains alphabetic, numeric, or special characters.

xs:time

A subset of xsext:anyValue. Represents the rightmost segment of the dateTime format where:

May contain an optional following time zone indicator.

Examples:


 

Naming Conventions

The xf: prefix is a W3C XML naming convention, also known as a namespace. Liquid Data supports extended functions that are enhancements to the XQuery specification, which you can recognize by their extended function prefix xfext:. For example, the full XQuery notation for an extended function is xfext:function_name. Extended functions accept standard input types, but they are limited to single values.

Liquid Data also supports extensions to XQuery data types that are designated with xsext:datatype notation. When you encounter the xsext: prefix, it means that the data type may have Liquid Data-imposed restrictions that are necessary to interface successfully with the Liquid Data Server.

The xfext: prefix identifies an extended function. The prefix identifies the type of function to you but the Data View Builder does not recognize or process the prefix.

 


Occurrence Indicators

An occurrence indicator indicates the number of items in a sequence. This notation usually appears on a parent node in a schema. Use these identifiers to determine the repeatability of a node.

These occurrence indicators also communicate information about the data type when they appear in a function signature. For example:

 


Accessor Functions

Accessor functions operate on different types of nodes. They accept single node input and return a value based on the node type.

Table A-2 Accessor Functions

Function Name

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

xf:data

Data Type:

Description: Returns the typed-value of each input node.

Examples:

Notes:

If the source value is not a node, the function returns an error.

XQuery Specification Compliance:


 

 


Aggregate Functions

Aggregate functions process a sequence as argument and return a single value computed from values in the sequence. Except for the Count function, if the sequence contains nodes, the function extracts the value from the node and uses it in the computation.

Note: In the Data View Builder, you cannot drag and drop aggregate functions to the work area. You must double-click on them to open them so that you can select input parameters.

Table A-3 Aggregate Functions

Name

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

xf:avg

Data Type:

Description: Returns the average of a sequence of numbers.

Examples:

Notes:

If the source value contains nodes, the value of each node is extracted using the xf:data function. If an empty list occurs, it is discarded.

If the source value contains only numbers, the Avg function returns the average of the numbers, which is the sum of the source sequence divided by the count of the source sequence.

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

If the source value contains non-numeric data, the function returns an error.

XQuery Specification Compliance:

Liquid Data requires a list of double precision values instead of a list of items.

xf:count

Data Type:

Description:

Returns the number of items in the sequence in an unsigned integer.

Examples:

Notes:

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

XQuery Specification Compliance:

Liquid Data returns an integer value (xs:integer) instead of an unsigned int (xs:unsignedInt) value.

xf:max

Data Type:

Description:

Returns the maximum value from a sequence. If there are two or more items with the same value, the specific item whose value is returned is implementation-dependent.

Examples:

xf:max((3, 10)) returns the value 10.

xf:max((<a>{4}</a>, 3, (), <b >{2}</b>)) returns <a>{4}</a>.

Notes:

If the source value contains nodes, the value of each node is extracted using the xf:data function. If an empty list occurs, it is discarded.

All values in the list must be instances of one of the following types:

For example, if the list contains items with typed values that represent both decimal values and dates, an error will occur.

The values in the sequence must have a total order:

Both of these conditions must be true; otherwise, the function returns an error.

XQuery Specification Compliance:

xf:min

Data Type:

Description:

Returns the minimum value from a sequence of numbers. If there are two or more items with the same value, the specific item whose value is returned is implementation-dependent.

Examples:

Notes:

If the source value contains nodes, the value of each node is extracted using the Data function. If an empty list occurs, it is discarded.

After extracting the values from nodes, the sequence must contain only values of a single type.

The values in the sequence must have a total order:

Both of these conditions must be true; otherwise, the function returns an error.

XQuery Specification Compliance:


xf:sum

Data Type:

Description:

Returns the sum of a sequence of numbers.

Examples:

Notes:

If the source value contains nodes, the value of each node is extracted using the Data function. If an empty list occurs, it is discarded.

If the source value contains only numbers, the Sum function returns the sum of the numbers.

If the source value contains non-numeric data, the function returns an error.

If the input sequence is empty, the function returns an empty list.

XQuery Specification Compliance:


 

 


Boolean Functions

Boolean functions return true or false values.

Table A-4 Boolean Functions

Function Name

Data Type, Description, and Examples

Notes and XQuery Compliance

xf:false

Data Types:

Description:

Returns the boolean value false.

Examples:

XQuery Specification Compliance:

Conforms to the current specification.

xf:not

Data Types:

Description:

Returns true if the value of the source value is false and false if the value of the source value is true.

Examples:


XQuery Specification Compliance:

xf:true

Data Types:

Description:

Returns the boolean value true.

Examples:

XQuery Specification Compliance:

Conforms to the current specification.


 

 


Constructor Functions

Constructor functions process a source value as the argument. Every data element or variable has a data type. The data type determines the value that any function parameter can contain and the operations that can be performed on it. The Liquid Data supports the following type casting functions.

Table A-5 Accessor Functions

Function Name

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

xf:boolean-from-string

Data Types:

Description:

Returns a boolean value of true or false from the string source value.

Examples:

Notes:

If the input parameter is empty, the function returns an empty list. Otherwise, Liquid Data generates an error.

XQuery Specification Compliance:

xf:byte

Data Types:

Description:

Constructs a byte integer value from the string source value.

Examples:

Notes:

An error occurs if the source value is greater than 127 or less than -128.

Liquid Data truncates the input if it is a non-integer number.

If the number falls outside of the range of byte values, the number wraps.

If the number is an integer that falls within the range, the value is unchanged.

If the input is a string, Liquid Data tries to parse it into a byte value.

If the input is the boolean value true, the function returns 1. If it is false, it returns 0.

XQuery Specification Compliance:

xf:decimal

Data Types:

Input data type: xsext:anyValue?

Returned data type: xs:decimal?

Description:

Constructs a decimal value from the source value.

Examples:

XQuery Specification Compliance:

xf:double

Data Types:

Description:

Constructs a double precision value from the source value.

Examples:

XQuery Specification Compliance:

xf:float

Data Types:

Input data type: xsext:anyValue?

Returned data type: xs:float?

Description:

Constructs a floating point value from the source value.

Examples:

XQuery Specification Compliance:

xf:int

Data Types:

Input data type: xsext:anyValue?

Returned data type: xs:integer?

Description:

Constructs an integer value from the source value. The largest integer value is limited to a 32-bit expression.

Examples:

Notes:

An error occurs if the source value is greater than 2,147,483,647 or less than -2,147,483,648. To the Liquid Data Server, the xf:int function is exactly the same as the xf:integer function.

XQuery Specification Compliance:

xf:integer

Data Types:

Input data type: xsext:anyValue?

Returned data type: xs:integer?

Description:

Constructs an integer value from the source value. The largest integer value is limited to a 32-bit expression.

Examples:

Notes:

An error occurs if the source value is greater than 2,147,483,647 or less than -2,147,483,648. To the Liquid Data Server, the xf:integer function is exactly the same as the xf:int function.

XQuery Specification Compliance:

xf:long

Data Types:

Description:

Constructs a four-byte integer value from the source value. Use a long integer data type when the value exceeds the limitations imposed by other integer data types.

Examples:

Notes:

An error occurs if the source value is greater than 9,223,372,036,854,775,807 or less than -9,223,372,036,854,775,808.

XQuery Specification Compliance:

xf:short

Data Types:

Input data type: xsext:anyValue?

Returned data type: xs:short?

Description:

Constructs a two-byte integer value from the source value. The largest short integer value is limited to a 16-bit expression.

Examples:

Notes:

An error occurs if the source value is greater than 32,767 or less than -32,768.

XQuery Specification Compliance:

xf:string

Data Types:

Description:

Constructs a string value from the source value. The source value can be a sequence, a node of any kind, or a simple value.

Examples:

Notes:

Liquid Data accepts any simple value, but supports no other accessor types, such as a sequence or other type of node.

XQuery Specification Compliance:


 

 


DateTime Functions

DateTime functions extract all or part of a dateTime expression and use it in a query.

xf:add-days

Data Types

Description

Adds the number of days specified by Parameter2 to the date specified by Parameter1. The value of Parameter2 may be negative.

Notes

If Parameter1 has a timezone, it remains unchanged. The returned value is always normalized into a correct Gregorian calendar date. If either parameter is an empty list, the function returns an empty list.

XQuery Specification Compliance

Conforms to the current specification.

Examples

xf:current-dateTime

Data Types

No parameters required.

Returned data type: xs:dateTime

Description

Returns the current date and time.

Notes

The function returns the current date and time in the current timezone.

If the function is called multiple times during the execution of a query, it returns the same value each time.

XQuery Specification Compliance

Liquid Data returns the time zone where the Liquid Data Server is running.

Example

xf:current-dateTime() can return a dateTime value such as 2002-07-25T01:00:38.812-08:00, which represents July 25th, 2002 at 1:00:38 and 812 thousandths of a second in a time zone that is offset by -8 hours from GMT (UTC).

xf:date

Data Types

Description

Returns a date from a source value, which must contain a date in one of these formats:

where the following is true:

Notes

The representation for date is the leftmost representation for dateTime: YYYY-MM-DD+hh:mm with an optional following time zone indicator (Z).

Liquid Data supports this year range: 0000-9999.

XQuery Specification Compliance

Conforms to the current specification.

Examples

xfext:date-from-dateTime

Data Types

Description

Returns the leftmost date portion of a dateTime value.

Notes

This is an extended function. It has an xfext: prefix identifier (namespace), which is the extension to the standard XQuery function namespace (xf:). For more information about extended functions, see Naming Conventions. For more information about valid formats for dateTime, see xf:dateTime.

XQuery Specification Compliance

Liquid Data supports date-from-dateTime as an extended function.

Examples

xfext:date-from-string-with-format

Data Types

Description

Returns the right-most date portion of a dateTime value according to the pattern specified by Parameter1. For more information, see Date and Time Patterns.

Notes

This is an extended function. It has an xfext: prefix identifier (namespace), which is the extension to the standard XQuery function namespace (xf:). For more information about extended functions, see Naming Conventions.

XQuery Specification Compliance

Liquid Data supports date-from-string-with-format as an extended function.

Examples

xf:dateTime

Data Types

Description

Returns a dateTime value from a source value, which must contain a date and time in one of these formats:

where the following is true:

Notes

Returns a date and time in YYYY-MM-DDT+hh:mm:ss format.

This expression can be preceded by an optional leading minus (-) sign to indicate a negative number. If the sign is omitted, positive (+) is assumed.

Use additional digits to increase the precision of fractional seconds if desired. The format ss.ss... with any number of digits after the decimal point is supported. Fractional seconds are optional.

Liquid Data supports this year range: 0000-9999.

XQuery Specification Compliance

Conforms to the current specification.

Examples

xfext:dateTime-from-string-with-format

Data Types

Description

Returns a new dateTime value from a string source value according to the pattern specified by Parameter1.

Notes

This is an extended function. It has an xfext: prefix identifier (namespace), which is the extension to the standard XQuery function namespace (xf:).

For more information about extended functions, see Naming Conventions, and see Date and Time Patterns.

XQuery Specification Compliance

Liquid Data supports dateTime-from-string-with-format as an extended function.

Examples

xf:get-hours-from-dateTime

Data Types

Description

Returns an integer value representing the hour identified in dateTime.

Notes

The hour value ranges from 0 to 23.

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

XQuery Specification Compliance

Conforms to the current specification.

Examples

xf:get-hours-from-time

Data Types

Description

Returns an integer representing the hour identified in time.

Notes

The hour value ranges from 0 to 23, inclusive.

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

XQuery Specification Compliance

Conforms to the current specification.

Examples

xf:get-minutes-from-dateTime

Data Types

Description

Returns an integer value representing the minutes identified in dateTime.

Notes

Returns an integer value representing the minute identified in the source value. The minute value ranges from 0 to 59, inclusive.

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

XQuery Specification Compliance

Conforms to the current specification.

Examples

xf:get-minutes-from-time

Data Types

Description

Returns an integer value representing the minutes identified in time.

Notes

The minute value ranges from 0 to 59.

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

XQuery Specification Compliance

Conforms to the current specification.

Examples

xf:get-seconds-from-dateTime

Data Types

Description

Returns an integer value representing the seconds identified in dateTime.

Notes

The seconds value ranges from 0 to 60.999. The precision (number of digits) of fractional seconds depends on the relevant facet of the argument.

The value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet.

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

XQuery Specification Compliance

Conforms to the current specification.

Examples

xf:get-seconds-from-time

Data Types:

Description

Returns an integer value representing the seconds identified in time.

Notes

The seconds value ranges from 0 to 60.999. The precision (number of digits) of fractional seconds depends on the relevant facet of the argument.

The value can be greater than 60 seconds to accommodate occasional leap seconds used to keep human time synchronized with the rotation of the planet.

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

XQuery Specification Compliance

Conforms to the current specification.

Examples

xf:time

Data Types

Description

Returns a tine from a source value, which must contain the time in one of these formats:

where the following is true:

Notes

Liquid Data generates an error if it cannot parse the string successfully.

XQuery Specification Compliance

Conforms to the current specification.

Examples

xfext:time-from-dateTime

Data Types

Description

Returns the time from dateTime.

Notes

This is an extended function. It has an xfext: prefix identifier (namespace), which is the extension to the standard XQuery function namespace (xf:). For more information about extended functions, see Naming Conventions. For more information about valid formats for dateTime, see xf:dateTime.

XQuery Specification Compliance

Liquid Data supports time-from-dateTime as an extended function.

Examples

xfext:time-from-string-with-format

Data Types

Description

Returns a new time value from a string source value according to the pattern specified by Parameter1.

Notes

This is an extended function. It has an xfext: prefix identifier (namespace), which is the extension to the standard XQuery function namespace (xf:).

For more information about extended functions, see Naming Conventions, and see Date and Time Patterns.

XQuery Specification Compliance

Liquid Data supports time-from-string-with-format as an extended function.

Examples

Date and Time Patterns

You can construct date and time patterns using standard Java class symbols. The following table shows the pattern symbols you can use.

Table 7-1 Date and Time Patterns

This Symbol

Represents This Data

Produces This Result

G

Era

AD

y

Year

1996

M

Month of year

July, 07

d

Day of the month

19

h

Hour of the day (1-12)

10

H

Hour of the day (0-23)

22

m

Minute of the hour

30

s

Second of the minute

55

S

Millisecond

978

E

Day of the week

Tuesday

D

Day of the year

27

w

Week in the year

27

W

Week in the month

2

a

am/pm marker

AM, PM

k

Hour of the day (1-24)

24

K

Hour of the day (0-11)

0

z

Time zone

Pacific Standard Time

Pacific Daylight Time


 

Repeat each symbol to match the maximum number of characters required to represent the actual value. For example, to represent 4 July 2002, the pattern is d MMMM yyyy. To represent 12:43 PM, the pattern is hh:mm a.

 


Node Functions

Node functions are operations on nodes and node values.

Table A-6 Node Functions

Function Name

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

xf:local-name

Data Types:

Description:

Returns a string value that corresponds to the local name of the specified node.

Examples:

XQuery Specification Compliance:


 

 


Numeric Functions

Numeric functions operate on numeric data types.

Table A-7 Numeric Functions

Function Name

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

xf:ceiling

Data Types:

Description:

Returns the smallest (closest to negative infinity) integer that is not smaller than the source value.

Examples:

Notes:

If the argument is an empty list, the function returns an empty list.

XQuery Specification Compliance:

Conforms to the current specification.

xf:floor

Data Types:

Description:

Returns the largest (closest to positive infinity) integer that is not greater than the source value.

Examples:

Notes:

If the argument is an empty list, the function returns an empty list.

XQuery Specification Compliance:

Conforms to the current specification.

xf:round

Data Types:

Description:

Returns the integer that is closest to the source value.

Examples:

Notes:

Round(x) produces the same result as the Floor function(x+0.5). If there are two such numbers, returns the one that is closest to +INF.

If the argument is +INF, returns +INF.

If the argument is -INF, returns -INF.

If the argument is +0, returns +0.

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

XQuery Specification Compliance:

Liquid Data does not support not-a-number (NaN) or -0.


 

 


Comparison and Numeric Operators

XQuery has operators that are specific to types of operations, such as comparisons or numeric operations.

Table A-8 Comparison and Numeric Operators

Name

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

* (Multiply)

Data Types:

Description:

Returns the arithmetic product of the operands: ($operand1*$operand2).

Examples:

Notes:

This is a numeric operator that you can use as if it were a function to compute numeric results.

The operator accepts two numeric values as parameters, computes their product, and returns the result.

Liquid Data applies the following rules:

XQuery Specification Compliance:

+ (Add)

Data Types:

Description:

Returns the arithmetic sum of the operands: ($operand1+$operand2).

Examples:

Notes:

This is a numeric operator that you can use as if it were a function to compute numeric results.

The operator accepts two numeric values as parameters, computes their sum, and returns the result.

Liquid Data applies the following rules:

XQuery Specification Compliance:

-(Subtract)

Data Types:

Description:

Returns the arithmetic difference of the operands: ($operand1-$operand2).

Examples:

Notes:

This is a numeric operator that you can use as if it were a function to compute numeric results.

Liquid Data applies the following rules:

XQuery Specification Compliance:


and

Data Types:

Description:

The result is true if both values are true, and false if one of the values is false.

Examples:

Notes:

This is a boolean operator that you can use as a function to return a true or false result.

The arguments and return type are all boolean.

The following table shows how Liquid Data determines the result. The leftmost column contains the possible values of the first parameter; the top row contains the possible values of the second parameter.



 

XQuery Specification Compliance:

div(ide)

Data Types:

Description:

Returns the arithmetic quotient of the operands ($operand1/$operand2).

Examples:

Notes:

This is a numeric operator that you can use as if it were a function to compute numeric results.

Liquid Data applies the following rules:

XQuery Specification Compliance:

eq

Data Types:

Description:

Returns true if Parameter1 is exactly equal to Parameter2.

Examples:

Notes:

This is a comparison operator that you can use as a function to compare operands.

If either operand is a node, Liquid Data extracts its typed value first, then performs a type check to ensure that the type of one operand is promotable to the other type; otherwise Liquid Data generates an error.

If either operand is an empty list, the function returns an empty list.

XQuery Specification Compliance:

ge

Data Types:

Description:

Returns true if Parameter1 is greater than or equal to Parameter2.

Examples:

See the examples for "eq" operator (previous entry in this table).

Notes:

This is a comparison operator that you can use as a function to compare operands.

If either operand is a node, Liquid Data extracts its typed value first, then performs a type check to ensure that the type of one operand is promotable to the other type; otherwise Liquid Data generates an error.

If either operand is an empty list, the function returns an empty list.

XQuery Specification Compliance:

gt

Data Types:

Description:

Returns true if Parameter1 is greater than Parameter2.

Examples:

See the examples for the "eq" operator (previous entry in this table).

Notes:

This is a comparison operator that you can use as a function to compare operands.

If either operand is a node, Liquid Data extracts its typed value first, then performs a type check to ensure that the type of one operand is promotable to the other type; otherwise Liquid Data generates an error.

If either operand is an empty list, the function returns an empty list.

XQuery Specification Compliance:

Liquid Data does not cast xs:anySimpleType to any other supported type.

Liquid Data does not support these data types: xs:yearMonthDuration, xs:dayTimeDuration, gregorian, xs:hexBinary, xs:base64Binary, xs:anyURI, xs:QName, or xs:NOTATION values.

le

Data Types:

Description:

Returns true if Parameter1 is less than or equal to Parameter2.

Examples:

See the examples for the "eq" operator (previous entry in this table).

Notes:

This is a comparison operator that you can use as a function to compare operands.

If either operand is a node, Liquid Data extracts its typed value first, then performs a type check to ensure that the type of one operand is promotable to the other type; otherwise Liquid Data generates an error.

If either operand is an empty list, the function returns an empty list.

XQuery Specification Compliance:

Liquid Data does not cast xs:anySimpleType to any other supported type.

Liquid Data does not support these data types: xs:yearMonthDuration, xs:dayTimeDuration, gregorian, xs:hexBinary, xs:base64Binary, xs:anyURI, xs:QName, or xs:NOTATION values.

lt

Data Types:

Description:

Returns true if Parameter1 is less than or equal to Parameter2.

Examples:

See the examples for the "eq" operator (previous entry in this table).

Notes:

This is a comparison operator that you can use as a function to compare operands.

If either operand is a node, Liquid Data extracts its typed value first, then performs a type check to ensure that the type of one operand is promotable to the other type; otherwise Liquid Data generates an error.

If either operand is an empty list, the function returns an empty list.

XQuery Specification Compliance:

Liquid Data does not cast xs:anySimpleType to any other supported type.

Liquid Data does not support these data types: xs:yearMonthDuration, xs:dayTimeDuration, gregorian, xs:hexBinary, xs:base64Binary, xs:anyURI, xs:QName, or xs:NOTATION values.

mod

Data Types:

Description:

Returns the remainder after dividing the first operand by the second operand:
($operand1 mod $operand2).

Examples:

Notes:

This is a numeric operator that you can use as if it were a function to compute numeric results.

Liquid Data applies the following rules:

XQuery Specification Compliance:

Liquid Data does not support not-a-number (NaN), -0, or the negative and positive infinity values -INF and INF.

ne

Data Types:

Description:

The result is false if both values are false and true if at least one of the values is true. Parameter2 is not evaluated if Parameter1 evaluates to true.

Examples:

See the examples for the "eq" operator (previous entry in this table).

Notes:

This is a boolean operator that you can use as a function to return a true or false result. It is not a standard XQuery operator, but necessary to complete certain comparative expressions in Liquid Data.

The arguments and return type are all boolean.

If either operand is a node, Liquid Data extracts its typed value first, then performs a type check to ensure that the type of one operand is promotable to the other type; otherwise Liquid Data generates an error.

If either operand is an empty list, the function returns an empty list.

XQuery Specification Compliance:

Liquid Data does not support these data types: xs:yearMonthDuration, xs:dayTimeDuration, gregorian, xs:hexBinary, xs:base64Binary, xs:anyURI, xs:QName, or xs:NOTATION values.

or

Data Types:

Description:

The result is false if both values are false and true if at least one of the values is true. Parameter2 is not evaluated if Parameter1 is true.

Examples:

Notes:

This is a boolean operator that you can use as a function to return a true or false result.

The arguments and return type are all boolean.

The following table shows how Liquid Data determines the result. The leftmost column contains the possible values of the first parameter; the top row contains the possible values of the second parameter


XQuery Specification Compliance:


 

 


Other Functions

Table A-9 Other Functions

Function Name

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

xfext:if-then-else

Data Types:

Description:

The xfext:if-then-else function accepts the value of a boolean parameter to select one of two other input parameters.

Examples:

Notes:

The If-then-else function is an extended function. For more information about extended functions, see Naming Conventions.

Liquid Data examines the value of the first parameter. If the condition is true, Liquid Data returns the value of the second parameter (then). If the condition is false, Liquid Data returns the value of the third parameter (else). If the returned condition is not a boolean value, Liquid Data generates an error.

XQuery Specification Compliance:

This is an extended function. Liquid Data converts it to an XQuery if-then-else expression.


 

 


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.

Table A-10 Sequence Functions

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

Function: xf:distinct-values

Data Types:

Description:

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

Examples:

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:

Function: xf:empty

Data Types:

Description:

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

Examples:

XQuery Specification Compliance:

Liquid Data supports an optional boolean returned value.

Function: xfext:subsequence

Format  1 Data Types:

Parameter1 data type: xsext:item*

Parameter2 data type: xs:integer

Returned data type: xsext:item*

Format  2 Data Types:

Parameter1 data type: xsext:item*

Parameter2 data type: xs:integer

Parameter3 data type: xs:integer

Returned data type: xsext:item*

Description:

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.

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.

Examples:

Notes:

Format 1: 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.

Format 2: 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:


 

String Functions

Strings from a character set may need to be sorted differently for different applications. You must consider the sort order when you invoke string comparisons. Some string functions will require understanding of the default sort order and any other special collation. For more information, see the Character Model for the World Wide Web 1.0.

Table A-11 String Functions

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

Function: xf:compare

Data Types:

Description:

Returns -1, 0, or 1, depending on whether the value of Parameter1 is less than (-1), equal to (0), or greater than (1)the value of Parameter2.

Examples:

Notes:

If either argument is an empty list, the result is an empty list.

Liquid Data generates an error if either parameter is not a string.

XQuery Specification Compliance:

Liquid Data does not support the xf:compare format that accepts collations.

Function: xf:concat

Data Types:

Parameter1 data type: xs:string?

Parameter2 data type: xs:string?

Returned data type: xs:string?

Description:

Returns a string that concatenates Parameter1 with Parameter2.

Examples:

Notes:

The result string may not reflect Unicode or other W3C normalization.

Returns an empty string if the function has no arguments. If any argument is an empty list, it is treated as an empty string.

Liquid Data generates an error if either parameter is not a string.

XQuery Specification Compliance:

Liquid Data does not support a variable number of parameters to be concatenated. Choose only two strings to concatenate with each operation.

Function: xf:contains

Data Types:

Parameter1 data type: xs:string?

Parameter2 data type: xs:string?

Returned data type: xs:boolean?

Description:

Returns a boolean value of true or false indicating whether Parameter1 contains a string that is equal to Parameter2 at the beginning, at the end, or anywhere within Parameter1.

Examples:

Notes:

If the value of Parameter2 is a zero-length string, the function returns true. If the value of Parameter1 is a zero-length string and the value of Parameter2 is not a zero-length string, the function returns false.

If the value of Parameter1 or Parameter2 is an empty list, the function returns an empty list.

Liquid Data generates an error if either parameter is not a string.

XQuery Specification Compliance:

Liquid Data does not support the xf:contains format that accepts collations.

Function: xf:ends-with

Data Types:

Description:

Returns a boolean value or true or false indicating whether Parameter1 ends with a string that is equal to Parameter2.

Examples:

Notes:

If Parameter2 is a zero-length string, then the function returns true. If Parameter1 is a zero-length string and Parameter2 is not a zero-length string, the function returns false.

If Parameter1 or Parameter2 is an empty list, the function returns an empty list.

Liquid Data generates an error if either parameter is not a string.

XQuery Specification Compliance:

Liquid Data does not support the xf:ends-with format that accepts collations.

Function: xf:lower-case

Data Types:

Description:

Returns the value of the input string after translating every uppercase letter to its corresponding lower-case value.

Examples:

Notes:

Every uppercase letter that does not have a lower-case corresponding value and every character that is not an uppercase letter appears in the output in its original form.

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

XQuery Specification Compliance:

Conforms to the current specification.

Function: xf:starts-with

Data Types:

Description:

Returns a boolean value or true or false indicating whether Parameter1 starts with a string that is equal to Parameter2.

Examples:

Notes:

If Parameter2 is a zero-length string, then the function returns true. If Parameter1 is a zero-length string and tParameter2 is not a zero-length string, the function returns false.

If Parameter1 or Parameter2 is an empty list, the function returns an empty list.

Liquid Data generates an error if either parameter is not a string.

XQuery Specification Compliance:

Liquid Data does not support the xf:ends-with format that accepts collations.

Function: xf:string-length

Data Types:

Description:

Returns an integer equal to the number of characters in the input source string.

Examples:

Notes:

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

Liquid Data generates an error if either parameter is not a string.

XQuery Specification Compliance:


Function: xf:substring

Format 1 Data Types:

Format 2 Data Types:

Description:

Format 1: Returns that part of the Parameter1 source string from the starting location specified by Parameter2.

Format 2: Returns that part of the Parameter1 source string from the starting location specified by Parameter2 and continuing for the number of characters equal to the length specified by Parameter3.

Notes:

Format 1

If the starting location is a negative value, or greater than the length of source string, an error occurs.

The first character of a string is located at position 1 (not position 0).

If Parameter1 or Parameter2 is an empty list, the function returns an empty list.

If you omit Parameter3, the function returns characters up to the end of the source string.

Liquid Data generates an error if Parameter1 is not a string or if the starting location is less than 1.

Format 2

If the starting location is a negative value, or greater than the length of the source string, an error occurs.

The first character of a string is located at position 1 (not position 0).

If you omit length, the substring identifies characters to the end of the source string.

If length exceeds the number of characters in the source string, the function identifies only characters until the end of the source string.

If Parameter1, Parameter2, or Parameter3 is an empty list, the function returns an empty list.

Liquid Data generates an error if Parameter1 is not a string or if the starting location is less than 1.

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

XQuery Specification Compliance:

Function: xf:substring-after

Data Types:

Description:

Returns that part of the Parameter1 source string that follows the first occurrence of those characters specified in Parameter2.

Examples:

Notes:

If Parameter2 is a zero-length string, the function returns the value of Parameter1. If Parameter1 is a zero-length string and Parameter2 is a zero-length string, the function returns a zero-length string.

If Parameter1 does not contain a string that is equal to Parameter2, the function returns a zero-length string.

If Parameter1 or Parameter2 is an empty list, the function returns an empty list.

XQuery Specification Compliance:

Liquid Data does not support the xf:substring-after format that accepts collations.

Function: xf:substring-before

Data Types:

Description:

Returns that part of the Parameter1 source string that precedes the first occurrence of those characters specified in Parameter2.

Examples:

Notes:

If Parameter2 is a zero-length string, the function returns the value of Parameter1. If Parameter1 is a zero-length string and Parameter2 is a zero-length string, the function returns a zero-length string.

If Parameter1 does not contain a string that is equal to Parameter2, the function returns a zero-length string.

If Parameter1 or Parameter2 is an empty list, the function returns an empty list.

XQuery Specification Compliance:

Liquid Data does not support the xf:substring-before format that accepts collations.

Function: xf:extrim

Data Types:

Description:

Returns the value of the input string with leading and trailing white space removed from the string.

Examples:

Notes:

If the input string is an empty list, the function returns an empty list.

Liquid Data generates an error if the parameter is not a string.

XQuery Specification Compliance:

The xfext:trim function is an extended function. For more information about extended functions, see Naming Conventions.

Function: xf:upper-case

Data Types:

Description:

Returns the value of the input string after translating every lower-case letter to its uppercase correspondent.

Notes:

Every lower-case letter that does not have an uppercase corresponding value and every character that is not a lower-case letter appears in the output in its original form.

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

Liquid Data generates an error if the parameter is not a string.

XQuery Specification Compliance:

Conforms to the current specification.

Examples:


 

 


Type Casting Functions

Type cast functions process a source value as the argument. Type casting will typically fail if applied to more than one element. An empty list is allowed, but the result of the type casting will consist of an empty list. Type casting functions are more likely to generate exceptions at run time if the parameter cannot be converted to the corresponding type.

The following table describes Liquid Data data types that conform to the XQuery specification that you can use in type casting functions. For more information about data types, see the XQuery 1.0 and XPath 2.0 Functions and Operators specification.

Table A-12 Type Casting Functions

Function Name

Data Type, Description, and Examples

Notes and XQuery Specification Compliance

xs:boolean

Data Types:

Converts the input to a boolean value (true or false).

If the input parameter is empty, the function returns an empty list. Otherwise, Liquid Data generates an error.

Examples:

Notes:

This function uses the xf:boolean-from-string function.

XQuery Specification Compliance:

Conforms to the current specification; however, Liquid Data does not accept the values "1" and "0" to represent true and false, as described in the W3C XML Schem document.

xs:date

Data Types:

Description:

Converts the input to a date value.

Examples:

Notes:

This function uses the xf:date function.

The string must contain a date in one of these formats:

where YYYY represents the year, MM represents the month (as a number), DD represents the day, hh and mm represents the number of hours and minutes that the timezone differs from GMT (UTC). Z indicates that the date is in the GMT timezone.

If the string cannot be parsed into a date value, Liquid Data generates an error.

XQuery Specification Compliance:

Conforms to the current specification.

xs:dateTime

Data Types:

Description:

Converts the input to a dateTime value.

Examples:

Notes:

This function uses the xf:date function.

XQuery Specification Compliance:

Conforms to the current specification.

xs:decimal

Data Types:

Description:

Converts the input to a decimal value.

Examples:

Notes:

This function uses the xf:decimal function.

XQuery Specification Compliance:

xs:double

Data Types:

Description:

Converts the input to a double precision value.

Examples:

Notes:

This function uses the xf:double function.

XQuery Specification Compliance:

xs:float

Data Types:

Description:

Converts the input to a floating point value.

Examples:

Notes:

This function uses the xf:float function.

XQuery Specification Compliance:

Liquid Data does not support not-a-number (NaN), -0, or the negative and positive infinity values -INF and INF.

Liquid Data attempts to support any input value, instead of just string literals, and convert it at run time.

xs:string

Data Types:

Description:

Converts the input to a string value.

Examples:

Notes:

This function uses the xf:string function.

XQuery Specification Compliance:

xs:time

Data Types:

Description:

Converts the input to a time value.

Examples:

Notes:

This function uses the xf:time function.

XQuery Specification Compliance:

Conforms to the current specification.


 

 

Back to Top Previous Next