Design > Understanding Data Types and Field Properties > Using Functions
  

Using Functions

You can use the following functions when working with XQuery in Process Designer or in any field that uses a formula to set a value.
For information about XQuery functions that are available in the Expression Editor but are not described below, see http://www.xqueryfunctions.com/xq/alpha.html. Note that Application Integration doesn't support all functions documented in the URL.
For information about using the Expression Editor to work with functions, see Using the Expression Editor.
Note: Application Integration does not support inline functions in the Expression Editor. The Expression Editor comes with powerful functions that can invoke operating system features. You must review the contents passed into the functions before using them.

Atomic Values of All Types

You can use the following functions in processes and service connectors:

Attachments for Processes

The functions described in the following table are available for handling attachments in processes.
In case of a process, the $cid value in the attachment functions refers to the process field (Input, Output or Temp). For example, if the input parameter is called customerPhoto (of type attachment), to get the attachment size, use:
sff:GetAttachmentSize($input.customerPhoto)
Note: Be sure that your field names do not have spaces so they can be easily referenced in XQuery.
For more examples of using the attachment functions, see Attachments.
Function
Syntax
Description
createAttachmentFromBase64
sff:createAttachmentFromBase64($contentName as xs:string, $encodedContent as xs:string, $mimeType as xs:string)
Creates an attachment from the base64-encoded content.
getAttachmentContentType
sff:getAttachmentContentType($cid as xs:string?)
Returns the content-type.
getAttachmentCount
sff:getAttachmentCount($cid as xs:long)
Returns the number of attachments.
getAttachmentName
sff:getAttachmentName($cid as xs:string?)
Returns the attachment (file) name if available.
getAttachmentProperty
sff:getAttachmentProperty($cid as xs:string?, $attribute as xs:string)
Returns the attachment attribute, given the mime header name such as 'content-type'.
getAttachmentSize
sff:getAttachmentSize($cid as xs:long)
Returns the attachment size in bytes.
getBase64FromAttachment
sff:getBase64FromAttachment($cid as xs:string)
Returns base64-encoded attachment content from the variable, which has the attachment type.
hasAttachment
sff:hasAttachment($cid as xs:boolean)
Checks if an attachment exists.
setAttachmentContentType
sff:setAttachmentContentType($cid as xs:string, $val as xs:string)
Sets the attachment content-type.
setAttachmentName
sff:setAttachmentName($cid as xs:string, $val as xs:string)
Sets the attachment name.
setAttachmentProperty
sff:setAttachmentProperty($cid as xs:string, $attribute as xs:string, $val as xs:string)
Sets the attachment mime header attribute value.

Dates and Times

Process Designer supports most built-in XQuery date and time functions described at http://www.xqueryfunctions.com/xq/alpha.html, in addition to the following functions:
Function Name
Syntax
Description
addToDate
date:addToDate(date, format, amount)
Adds a specified amount to one part of a datetime value, and returns a date in the same format as the date you pass to the function. For more information, see addToDate.
adjust-date-to-timezone
fn:adjust-date-to-timezone(arg, timezone)
Adjusts a date value to a specific time zone, or removes the time zone component from the date value. For more information, see adjust-date-to-timezone.
adjust-dateTime-to-timezone
fn:adjust-dateTime-to-timezone(arg, timezone)
Adjusts a dateTime value to a specific time zone, or removes the time zone component from the dateTime value. For more information, see adjust-dateTime-to-timezone.
adjust-time-to-timezone
fn:adjust-time-to-timezone(arg, timezone)
Adjusts a time value to a specific time zone, or removes the time zone component from the date value. For more information, see adjust-time-to-timezone.
current-date
fn:current-date()
Returns the current date. For more information, see current-date.
current-dateTime
fn:current-dateTime()
Returns the current dateTime with time zone. For more information, see current-dateTime.
current-time
fn:current-time()
Returns the current time. For more information, see current-time.
dateDiff
date:dateDiff(date, date, format)
Returns the length of time between two dates in the format specified. For more information, see dateDiff.
dateTime
fn:dateTime(arg1, arg2)
Constructs a dateTime from a date and time. For more information, see dateTime.
dateToMillis
date:dateToMillis($date)
Converts the time to milliseconds.
day-from-date
fn:day-from-date(arg)
Returns the day portion of a date. For more information, see day-from-date.
day-from-dateTime
fn:day-from-dateTime(arg)
Returns the day portion of a date/time. For more information, see day-from-dateTime.
days-from-duration
fn:days-from-duration(arg)
Returns the number of days in a duration. For more information, see days-from-duration.
getDatePart
date:getDatePart(date, format)
Returns the specified part of a date as an integer value. For more information, see getDatePart.
getLocale
date:getLocale()
Returns a string representing the current locale the process is running in. For more information, see getLocale.
getTimeZone
date:getTimeZone()
Returns a string that specifies the timezone ID where the process is running or where the user is running it. For more information, see getTimeZone.
hours-from-dateTime
fn:hours-from-dateTime(arg)
Returns the hour portion of a date/time. For more information, see hours-from-dateTime.
hours-from-duration
fn:hours-from-duration(arg)
Returns the hours in a duration. For more information, see hours-from-duration.
hours-from-time
fn:hours-from-time(arg)
Returns the hour portion of a time. For more information, see hours-from-time.
implicit-timezone
fn:implicit-timezone()
Returns the value of the implicit timezone property. For more information, see implicit-timezone.
lastDay
date:lastDay(date)
Passes the date for which you want to return the last day of the month. You can enter any valid expression that evaluates to a date. For more information, see lastDay.
toDate
date:toDate(date, format)
Converts a character string to a Date data type. You use the toDate format strings to specify the format of the source strings. For more information, see toDate.
millisToDate
date:millisToDate($millis)
Converts the current time from milliseconds. For more information, see millisToDate.
minutes-from-dateTime
fn:minutes-from-dateTime(arg)
Returns an xs:integer value between 0 and 59, both inclusive, representing the minute component in the localized value of $arg. For more information, see minutes-from-dateTime.
minutes-from-duration
fn:minutes-from-duration(arg)
Returns an xs:integer representing the minutes component in the value of $arg. For more information, see minutes-from-duration.
minutes-from-time
fn:minutes-from-time(arg)
Returns an xs:integer value between 0 and 59, both inclusive, representing the minute component in the localized value of $arg. For more information, see minutes-from-time.
month-from-date
fn:month-from-date(arg)
Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of $arg. For more information, see month-from-date.
month-from-dateTime
fn:month-from-dateTime(arg)
Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of $arg. For more information, see month-from-dateTime.
months-from-duration
fn:months-from-duration(arg)
Returns an xs:integer representing the minutes component in the value of $arg. The result is obtained by casting $arg to an xs:dayTimeDuration. For more information, see months-from-duration.
now
date:now()
Returns the current time in milliseconds.
seconds-from-duration
fn:seconds-from-duration(arg)
Returns an xs:decimal representing the seconds component in the value of $arg. The result is obtained by casting $arg to an xs:dayTimeDuration. For more information, see seconds-from-duration.
seconds-from-dateTime
fn:seconds-from-dateTime(arg)
Returns an xs:decimal value greater than or equal to 0 and less than 60, representing the seconds and fractional seconds in the localized value of $arg. For more information, see seconds-from-dateTime.
seconds-from-time
fn:seconds-from-time(arg)
Returns an xs:decimal value greater than or equal to 0 and less than 60, representing the seconds and fractional seconds in the localized value of $arg. For more information, see seconds-from-time.
timezone-from-date
fn:timezone-from-date(arg)
Returns the timezone component of $arg, if any. For more information, see timezone-from-date .
timezone-from-dateTime
fn:timezone-from-dateTime(arg)
Returns the timezone component of an xs:dateTime. For more information, see timezone-from-dateTime.
timezone-from-time
fn:timezone-from-time(arg)
Returns the timezone component of an xs:time. For more information, see timezone-from-time.
toChar
date:toChar(date, format)
Converts the date passed to a string based on the specified format string. For more information, see toChar.
trunc
date:trunc(xs:dateTime('date'), 'format')
Truncates dates to a specific year, month, day, hour, minute, second, or millisecond. For more information, see trunc (Dates).
year-from-date
fn:year-from-date(arg)
Returns an xs:integer representing the year in the localized value of $arg. The value might be negative. For more information, see year-from-date.
year-from-dateTime
fn:year-from-dateTime(arg)
Returns an xs:integer representing the year component in the localized value of $arg. For more information see year-from-dateTime.
years-from-duration
fn:years-from-duration(arg)
Returns an xs:integer representing the years component in the value of $arg. The result is obtained by casting $arg to an xs:yearMonthDuration. For more information, see years-from-duration.

Digital Signatures

The functions described in the following sections are available for use in digital signatures.
HMAC Functions
The following functions enable you to generate a digital signature by calculating a keyed-hash message authentication code (HMAC):
Function
Syntax
Description
hmacSignature
dsig:hmacSignature($data as xs:string, $key as xs:string, $algorithm as xs:string, $encoding as xs:string, $keyCharset as xs:string?) as xs:string
Generates an HMAC signature using the specified algorithm such as HMACSHA256 or HMACSHA512 and the optional encoding where $encoding is one of the following values:
  • - Base64 (default)
  • - Base64Url
  • - Hex
  • - Hex64
You can use the optional keyCharset parameter to specify the character set of the secret key that you pass as an argument in the function. The keyCharset is set to UTF-8 by default.
hmacSHA1signature
dsig:hmacSHA1signature($data as xs:string, $key as xs:string, $encoding as xs:string, $keyCharset as xs:string?) as xs:string
Calculates an HMAC using the SHA1 algorithm and the optional encoding where$encoding is one of the following values:
  • - Base64 (default)
  • - Base64Url
  • - Hex
  • - Hex64
$data consist of four parts, including a JSON string in base64 encoding.
To ensure that you get hex binary and not base64 when you use the hash:hash function on the payload, use the following expression:
let $md5hex := hash:hash($jsonPayload,"MD5")
return xs:base64Binary(xs:hexBinary($md5hex))
You can use the optional keyCharset parameter to specify the character set of the secret key that you pass as an argument in the function. The keyCharset is set to UTF-8 by default.
hmacSHA256signature
dsig:hmacSHA256signature($data as xs:string, $key as xs:string, $encoding as xs:string, $keyCharset as xs:string?) as xs:string
Calculates an HMAC using the SHA256 algorithm and the optional encoding where $encoding is one of the following values:
  • - Base64 (default)
  • - Base64Url
  • - Hex
  • - Hex64
You can use the optional keyCharset parameter to specify the character set of the secret key that you pass as an argument in the function. The keyCharset is set to UTF-8 by default.
hmacSHA512signature
dsig:hmacSHA512signature($data as xs:string, $key as xs:string, $encoding as xs:string, $keyCharset as xs:string?) as xs:string
Generates an HMAC SHA512 signature using the optional encoding where $encoding is one of the following values:
  • - Base64 (default)
  • - Base64Url
  • - Hex
  • - Hex64
You can use the optional keyCharset parameter to specify the character set of the secret key that you pass as an argument in the function. The keyCharset is set to UTF-8 by default.
hmacSHA256signatureForList
dsig:hmacSHA256signatureForList($data as xs:string, @delimiter as xs:string, $key as xs:string, $encoding as xs:string, $keyCharset as xs:string?) as xs:string
Generates an HMAC SHA512 signature using the optional encoding where $encoding is one of the following values:
  • - Base64 (default)
  • - Base64Url
  • - Hex
  • - Hex64
For more information, see hmacSHA256signatureForList.
Key Signing Functions
The following functions enable you to generate digital signatures based on private keys:
Function
Syntax
Description
signWithKeyFile
dsig:signWithKeyFile($messageToSign as xs:string, $pathToKey as xs:string, $encryptionAlgorithm as xs:string, $digestAlgorithm as xs:string, $encoding as xs:string) as xs:string
Generates a signature using an asymmetric algorithm and a private key, specified in a PKCS8 file.
Arguments:
  • - $digestAlgorithm: SHA1 or SHA256
  • - $encryptionAlgorithm: RSA (common) or DSA (if using SHA1 for $digestAlgorithm).
  • - $pathToKey: The PKCS8 certificate as a Base64-encoded string (-----BEGIN PRIVATE KEY----- ..... n-----END PRIVATE KEY-----\n) or a binary private key file.
  • - $encoding (optional), which may be:
  • - Base64 (default)
  • - Hex64
  • - Base64Url
signWithKeyString
dsig:signWithKeyString($messageToSign as xs:string, $key as xs:string, $encryptionAlgorithm as xs:string, $digestAlgorithm as xs:string, $encoding as xs:string) as xs:string
Generates a signature using an asymmetric algorithm and a private key, specified in a PKCS8 certificate encoded string.
Arguments:
  • - $digestAlgorithm: SHA1 or SHA256
  • - $encryptionAlgorithm: RSA (common) or ECDSA.
  • - $key: The PKCS8 certificate as a Base64-encoded string (-----BEGIN PRIVATE KEY----- ..... n-----END PRIVATE KEY-----\n) or a binary private key.
  • - $encoding (optional), which can be one of the following values:
    • - Base64 (default)
    • - Hex64
    • - Base64Url
Note: When you use Base64Url encoding to sign any data, you receive extra periods at the end. You must replace the period (.) with an empty string (“) using the replace function:
fn:replace(input, pattern, replacement, flags)
signWithCertificate
dsig:signWithCertificate($messageToSign as xs:string, $pathToCertificate as xs:string, $keyRecoveryPassword as xs:string, $encryptionAlgorithm as xs:string, $digestAlgorithm as xs:string, $encoding as xs:string $keyStorePassword as xs:string, $aliasName as xs:string, $keyStoreType as xs:string) as xs:string
Generates a signature using a PKCS12 certificate.
Arguments:
  • - $pathToCertificate: File location on the agent that contains either a PKCS12 or JKS (Java keystore) certificate.
  • - $keyRecoveryPassword: Password to access the key in the certificate.
  • - $keyStorePassword: Password to open the key store. If empty, assumes the keystore is not password-protected.
  • - $aliasName: Optional. Alias of entry in the keystore on the Secure Agent which contains the key. If the alias is not supplied (or empty), the first entry is used.
  • - $keyStoreType: Type of keystore, which may be:
    • - PKCS12 (default)
    • - JKS (Java keystore)
Hashing Functions
The following functions enable you to generate a message hash string:
Function
Syntax
Description
hash
hash:hash($string, $alg)
Generates a hash string for a message using the specified algorithm (optional), where $alg is one of the following:
  • - MD5 (default)
  • - SHA1
  • - SHA256

List Functions

The list functions support only the native Saxon functions. The following functions allow you to work with lists:
Function
Syntax
Description
append
list:append($objectlist, $newItem)
Appends a new item to a list.
count
list:count($objectlist)
Counts the items in a list.
head
list:head($objectlist)
Returns the first item in a list.
list
list:list($sequence)
Converts a sequence of IDs into a semicolon-separated list of IDs for an object list.
remove
list:remove($objectlist, $position)
Removes the item at the specified position from the list.
replace
list:replace($objectlist, $position, $newItem)
Replaces an existing item in a list with a new value.
sequence
list:sequence($objectlistFieldName)
Converts a semicolon-separated list to a sequence.
When an object list field is inserted into formula and content, the field is wrapped in the list:sequence(object_field_name) XQuery function. For object lists in hosted objects, this converts the semicolon-separated list of IDs in the object list into a sequence. For object lists for process objects, the value is already a sequence and the function returns the list unchanged.
tail
list:tail($objectlist)
Return all items from the list with the exception of the first item.
List Function Examples
Perhaps the most common example of using the list functions is to get an object from a list each time a step is invoked, possibly from within a repeated Process or Service step. For example:
let mylist.Current:=list:head(mylist.List)
let mylist.List:=list:tail(mylist.List)
The following example converts an object list in a semicolon-separated list, then iterates over each item:
for $objectid in list:sequence($objectlist)
...
The following example converts a sequence of IDs into a semicolon-separated list of IDs for an object list for hosted objects. For an object list for process objects, it returns a sequence of values:
let $mergedObjectLists :=
( as:sequence($objectlist1), as:sequence($objectlist2) )
return list:list($mergedObjectLists)

Math

In processes and service connectors, you can use the math functions described at http://www.w3.org/2005/xpath-functions/math.

Miscellaneous

The following miscellaneous functions are available:
Function
Syntax
Description
aesEncryption
util:aesEncryption(key, dataToEncrypt)
Encrypts the specified data with the provided key using the Advanced Encryption Standard (AES) algorithm. For more information about the function, see aesEncryption.
aesDecryption
util:aesDecryption(key, dataToDecrypt)
Decrypts the specified data with the provided key using the Advanced Encryption Standard (AES) algorithm. You must use the same key that you had used for encrypting the data in the aesEncryption function. For more information about the function, see aesDecryption.
base64Decode
util:base64Decode(data, charSet)
Returns the base64-decoded version of the input string provided based on the character set specified in the charSet argument. This function is typically used for attachments.
Application Integration supports the character sets that Azul JDK supports for encoding. For example, US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, and UTF-16.
Default for the charSet argument is UTF-8.
base64Encode
util:base64Encode(data, charSet)
Returns the base64-encoded version of the input string provided based on the character set specified in the charSet argument.
Application Integration supports the character sets that Azul JDK supports for encoding. For example, US-ASCII, ISO-8859-1, UTF-8, UTF-16BE, UTF-16LE, and UTF-16.
Default for the charSet argument is UTF-8.
base64EncodeURL
util:base64EncodeUrl(str, charSet)
Returns a base64-encoded version of the string provided, safe to use in a URL.
Any "+" and "/" characters are replaced with "-" and "_". Any "=" characters are removed.
Default for the charSet argument is UTF-8.
decode
util:decode(value, search1, result1, args, default)
Searches a field for the specified value. For more information, see decode.
error
fn:error(error, description, error-object)
Raises a custom error.
escapeJsonString
util:escapeJsonString(str)
Escapes special characters in the provided string to make it valid for usage in JSON. See JSON standard for details. For more information about the function, see escape-Json-String  .
exactly-one
fn:exactly-one(arg)
Returns a sequence if it contains exactly one item, otherwise returns errors.
format
util:format(value, pattern, timezoneId, locale)
Formats string content.
Use the following arguments:
  • - value: The string being formatted.
  • - pattern: A pattern describing how the value must be formatted. See Formatting Dates, Times, and Numbers.
  • - timezoneId: Optional. The time zone ID. If you do not use a stored value (typically returned by a call to date:getTimeZone()), you can omit this argument as Process Designer will call date:getTimeZone().
  • - locale: Optional. The locale. If you do not use a stored value (typically returned by a call to date:getLocale()), you can omit this argument as Process Designer will call date:getLocale().
If you use a locale argument but do not use a timezoneId argument, you must add the comma that would follow timezoneId. For example:
util:format("789","##00.00","",date:getLocale())
If the pattern argument contains a date, use lowercase letters to denote the year format yyyy. For example, use util:format("2024-12-29T06:16:02.536Z", "yyyy-MM-dd HH:mm:ss"). If you use uppercase letters, you might receive an incorrect year or errors might occur.
generate-random-string
util:generate-random-string(length as xs:integer)
Generates a random string of the specified length.
generateUUID
util:generateUUID()
Generates a universally unique identifier.
getAssetLocation
util:getAssetLocation()
Returns the location where the process or the guide that uses the function is stored. For more information, see getAssetLocation.
getAssetName
util:getAssetName()
Returns the name of the process or the guide that uses the function. For more information, see getAssetName.
getCatalogResource
util:getCatalogResource()
Returns the resource based on a catalog location URL within the organization. Takes any catalog resource in the Informatica Cloud organization as its parameter and returns an element node.
To display the element data, add a wrapper function. For example:
serialize(util:getCatalogResource("project:/spi.ipd/services.xml"))
getInstanceStartTime
util:getInstanceStartTime()
Returns the start time of the running instance of the specified process or guide. For more information, see getInstanceStartTime.
getOrganizationId
util:getOrganizationId()
Returns a string that is the organization Id of the context of the currently executing process. For more information, see getOrganizationId.
getOrganizationName
util:getOrganizationName()
Returns the organization name in the context of the executing process, guide, service connector, or data access service connector. For more information, see getOrganizationName.
getProcessId
util:getProcessId()
Returns the process Id of the currently executing or completed process.
getUserName
util:getUserName()
Returns a string that is the login name or ID of the authenticated User running the process .
getUserSystem
util:getUserSystem()
Returns a string that is the name of the system that authenticated the user running the process.
iif
util:iif(condition, val1, val2)
Returns val1 if the condition is true. Else, returns val2. For more information, see iif.
in
util:in(valueToSearch, values, caseFlag)
Matches input data with a list of values. By default, the match is case sensitive. For more information, see in.
isNull
util:isNull(value)
Checks whether the input passed is empty. For more information, see isNull.
one-or-more
fn:one-or-more
Returns a sequence if it contains one or more items, otherwise returns errors.
parseJSON
util:parseJSON(jsonStr)
Parses the provided JSON string and converts it to XML elements.
parseXML
util:parseXML(xmlStr)
Parses the provided XML string and converts it to an XML element.
random
util:random()
Returns a random number from 0 to 1.
resolveURN
util:resolveURN()
Retrieves the URN mapping for an organization.
safeNumber
util:safeNumber()
Holds a number value safely so it cannot be changed.
toDecimal
util:toDecimal(value, scale)
Converts a string or numeric value to a decimal value. For more information, see toDecimal.
toInteger
util:toInteger(value, flag)
Converts a string or numeric value to a decimal value. For more information, see toInteger.
setProcessTitle
ipd:setProcessTitle()
Sets the title of the process.
Note: Use this function only in Informatica Process Designer.
simplifyXml
util:simplifyXml(undefined)
Utility function that is used to remove all namespaces and convert attributes into child elements. For more information, see simplifyXml.
toJSON
util:toJSON(elements)
Converts the provided list of XML elements to a JSON string.
toXML
util:toXML(element)
Converts the provided XML element to an XML string.
trace
util:trunc(arg, precision)
Provides an execution trace to be used in debugging queries. For more information, see trace.
trunc
util:trunc(arg, precision)
Truncates numbers to a specific digit based on the number of decimal places specified by the precision. For more information, see trunc (Numbers).
zero-or-one
fn:zero-or-one(arg)
Returns a sequence if it contains zero or one items, otherwise returns an error.

Numbers

The following number functions are available in the Expression Editor:

Sequences

The following sequences functions are available in the Expression Editor:

String

The following string functions are available in the Expression Editor:

XML

You can add common XML functions as you build expressions. From the Expression Editor, a list of common XML functions displays in these categories:
The following XML Nodes functions are available in the Expression Editor:
Function
Syntax
Description
data
fn:data(arg)
Returns the atomic value of a node.
The function takes a sequence of items and returns a sequence of atomic values. For more information, see data.
deep-equal
fn:deep-equal(parameter1, parameter2, collation)
Assesses whether two nodes have the same content and attributes. For more information, see deep-equal.
root
fn:root(arg)
Returns the root of the tree that contains the argument. For more information, see root.

Atomic Values of All Types functions

The following functions are available in the Atomic Values of All Types section of the Expression Editor:

boolean

The boolean function in XQuery is used to convert its argument to a boolean value according to specific rules.

Syntax

fn:boolean(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The sequence to be converted into a boolean. It can be an atomic value, a sequence of nodes, or an empty sequence. It can contain zero or more items.

Return Value

Examples

The following table lists some sample values and return values:
Input
Return Value
fn:boolean( () )
false
fn:boolean('')
false
fn:boolean(0)
false
fn:boolean('0')
true
fn:boolean('false')
true
fn:boolean(("Hello"))
true
fn:boolean(xs:float('NaN'))
false
fn:boolean($ordDoc/order[1])
true
fn:boolean($ordDoc/noSuchChild)
false
fn:boolean(<a>false</a>)
true

empty

The empty function in XQuery is used to determine whether a sequence is empty. It is useful in various conditional checks and scenarios where determining the presence of data is necessary.

Syntax

fn:empty(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
This is the sequence that you want to test for emptiness. It can contain zero or more items.

Return Value

If the value of $arg is the empty sequence, the function returns true. Otherwise, the function returns false .

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:empty( ('a', 'b', 'c') )
false
fn:empty( () )
true
fn:empty(0)
false
fn:empty((1, 2, 3))
false
fn:empty(("apple", "orange"))
false

exists

The exists function in XQuery is used to determine whether a sequence contains one or more items.

Syntax

fn:exists(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The sequence to check for existence. It can be a node, an atomic value, or a sequence of items. It can contain zero or more items.

Return Value

If the value of $arg is not the empty sequence, the function returns true. Otherwise, the function returns false .

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:exists( ('a', 'b', 'c') )
true
fn:exists( '' )
true
fn:exists( () )
false
fn:exists( false() )
true
fn:exists( (1, 2, 3) )
true

false

The false function in XQuery is a function that always returns the boolean value false. It's part of the XQuery standard functions for working with boolean values.

Syntax

fn:false()
The false function does not take any parameters.

Return Value

Returns the xs:boolean value false . Equivalent to xs:boolean("0") .

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:false()
false()
fn:not(fn:false())
true

nilled

The nilled function in XQuery is used to check whether a given node is nilled. A nilled element is where the xsi:nil attribute is set to true in an XML document that supports XML Schema.

Syntax

fn:nilled(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The node to be checked for the nilled status. This can be an element node or none.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:nilled(())
None
let $textNode := text{"example"}
return fn:nilled($textNode)
None

not

The not function accepts a sequence of items, from which it calculates the effective boolean value of the sequence as a whole before negating it.

Syntax

fn:not(arg)
The following table describes the argument for this command:
Argument
Required/ Optional
Description
arg
Required
The boolean expression you want to negate. This can be a boolean value or None.

Return Value

The $arg is first reduced to an effective boolean value by applying the fn:boolean() function. Returns true if the effective boolean value is false or None, and false if the effective boolean value is true.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:not(true())
false
fn:not(false())
true
fn:not(())
true
fn:not('')
true
fn:not(0)
true
fn:not(<e>false</e>)
false

number

The number function constructs an xs:double value either from a node that contains a number, or from an atomic value. This function is useful for telling the processor to treat a node or value as a number, irrespective of its declared type, if any.

Syntax

fn:number(arg)
The following table describes the argument for this command:
Argument
Required/ Optional
Description
arg
Required
The atomic value you want to convert to a number. This can be a string representing a number, a numeric type, or None.

Return Value

Returns the value indicated by $arg or, if $arg is not specified, the context item after atomization, converted to an xs:double.
The difference between using the fn:number function and the xs:double constructor is that the fn:number function returns the value NaN in the case that the argument cannot be cast to a numeric value, whereas the xs:double constructor will raise an error.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:number('29.99')
29.99
fn:number('ABC')
NaN
fn:number(42)
42.0
fn:number( () )
NaN
fn:number(true())
1

string

The string function in XQuery is used to convert an argument to its string representation. It is commonly used to ensure that a given value is treated as a string.

Syntax

fn:string(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The item you want to convert to a string. This can be any atomic type, node, or sequence. The sequences with more than one item will return an error.

Return Value

Returns the value of $arg represented as a xs:string. If no argument is supplied, the context item ( . ) is used as the default argument. The behavior of the function if the argument is omitted exactly the same as if the context item had been passed as the argument.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:string(123)
"123"
fn:string("Hello, World!")
"Hello, World!"
fn:string(true())
"true"

true

The true function in XQuery is a simple function that returns the boolean value true.

Syntax

fn:true()
The true function does not take any parameters.

Return Value

Returns the xs:boolean value true. Equivalent to xs:boolean("1") .

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:true()
true
fn:not(fn:true())
false

Date and time functions

The following date functions are available in the Dates and Times section of the Expression Editor:

addToDate

Adds a specified amount to one part of a datetime value, and returns a date in the same format as the date you pass to the function. The addToDate function accepts positive and negative integer values. Use addToDate to change the following parts of a date:

Syntax

date:addToDate(xs:dateTime('date'), 'format', amount)
Note: You must manually add the xs:dateTime phrase and enclose the date values within single quotation marks.
The following table describes the arguments:
Argument
Required/ Optional
Description
date
Required
Date/Time data type. Passes the values that you want to change.
You can enter any valid transformation expression.
format
Required
A format string that specifies the portion of the date value that you want to change. Enclose the format string within single quotation marks, for example, 'mm'. The format string is not case sensitive.
amount
Required
An integer value that specifies the amount of years, months, days, hours, and so on by which you want to change the date value. You can enter any valid transformation expression that evaluates to an integer.

Return Value

Date in the same format as the date you pass to this function.
NULL if a null value is passed as an argument to the function.

Examples

The following expressions all add one month to each date in the DATE_SHIPPED column. If you pass a value that creates a day that does not exist in a particular month, addToDate returns the last day of the month. For example, if you add one month to Jan 31 1998, addToDate returns Feb 28 1998.
Also, addToDate recognizes leap years and adds one month to Jan 29 2000:
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'MM', 1)
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'MON', 1)
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'MONTH', 1)
The following table shows some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Jan 12 1998 12:00:30AM
Feb 12 1998 12:00:30AM
Jan 31 1998 6:24:45PM
Feb 28 1998 6:24:45PM
Jan 29 2000 5:32:12AM
Feb 29 2000 5:32:12AM  (Leap Year)
Oct 9 1998 2:30:12PM
Nov 9 1998 2:30:12PM
NULL
NULL
The following expressions subtract 10 days from each date in the DATE_SHIPPED column:
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'D', -10)
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'DD', -10)
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'DDD', -10)
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'DY', -10)
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'DAY', -10)
The following table shows some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Jan 1 1997 12:00:30AM
Dec 22 1996 12:00AM
Jan 31 1997 6:24:45PM
Jan 21 1997 6:24:45PM
Mar 9 1996 5:32:12AM
Feb 29 1996 5:32:12AM  (Leap Year)
Oct 9 1997 2:30:12PM
Sep 30 1997 2:30:12PM
Mar 3 1996 5:12:20AM
Feb 22 1996 5:12:20AM
NULL
NULL
The following expressions subtract 15 hours from each date in the DATE_SHIPPED column:
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'HH', -15)
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'HH12', -15)
date:addToDate(xs:dateTime('DATE_SHIPPED'), 'HH24', -15)
The following table shows some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Jan 1 1997 12:00:30AM
Dec 31 1996 9:00:30AM
Jan 31 1997 6:24:45PM
Jan 31 1997 3:24:45AM
Oct 9 1997 2:30:12PM
Oct 8 1997 11:30:12PM
Mar 3 1996 5:12:20AM
Mar 2 1996 2:12:20PM
Mar 1 1996 5:32:12AM
Feb 29 1996 2:32:12PM  (Leap Year)
NULL
NULL

adjust-date-to-timezone

Adjusts a date value to a specific time zone, or removes the time zone component from the date value.

Syntax

fn:adjust-date-to-timezone(arg, timezone)
The following table describes the arguments:
Argument
Required/
Optional
Description
arg
Required
The date value that is to be adjusted.
The date-value is of type xs:date or is an empty sequence.
timezone
Optional
A duration that represents the time zone to which date-value is to be adjusted.

Return Value

The fn:adjust-date-to-timezone function behaves differently depending on whether the $arg date value already has a time zone, and on the value of the time zone provided as given below:

Examples

The following table contains examples and return values for the adjust-date-to-timezone function:
Examples
Return Values
adjust-date-to-timezone(
xs:date('2023-02-15'),
xs:dayTimeDuration('-PT8H'))
2023-02-15-08:00
adjust-date-to-timezone(
xs:date('2023-02-15-03:00'),
xs:dayTimeDuration('-PT8H'))
2023-02-14-08:00
adjust-date-to-timezone(
xs:date('2023-02-15'), ())
2023-02-15
adjust-date-to-timezone(
xs:date('2023-02-15-03:00'), ())
2023-02-15
The following table contains examples and return values assuming an implicit time zone of -05:00:
Examples
Return Values
adjust-date-to-timezone(
xs:date('2023-02-15'))
2023-02-15-05:00
adjust-date-to-timezone(
xs:date('2023-02-15-03:00'))
2023-02-14-05:00

adjust-dateTime-to-timezone

Adjusts a dateTime value to a specific time zone, or removes the time zone component from the dateTime value.

Syntax

fn:adjust-dateTime-to-timezone(arg, timezone)
The following table describes the arguments:
Argument
Required/
Optional
Description
arg
Required
The dateTime value that is to be adjusted.
The dateTime-value is of type xs:dateTime or is an empty sequence.
timezone
Optional
A duration that represents the time zone to which dateTime-value is to be adjusted.

Return Value

The fn:adjust-dateTime-to-timezone function behaves differently depending on whether the $arg date value already has a time zone, and on the value of the time zone provided as given below:

Examples

The following table contains examples and return values for the adjust-date-to-timezone function:
Examples
Return Values
adjust-dateTime-to-timezone(
xs:dateTime('2023-02-15T17:00:00'),
xs:dayTimeDuration('-PT7H'))
2023-02-15T17:00:00-07:00
adjust-dateTime-to-timezone(
xs:dateTime('2023-02-15T17:00:00-03:00'),
xs:dayTimeDuration('-PT7H'))
2023-02-15T13:00:00-07:00
adjust-dateTime-to-timezone(
xs:dateTime('2023-02-15T17:00:00'),
())
2023-02-15T17:00:00
adjust-dateTime-to-timezone(
xs:dateTime('2023-02-15T17:00:00-03:00'),
())
2023-02-15T17:00:00
adjust-dateTime-to-timezone(
xs:dateTime('2023-02-15T01:00:00-03:00'),
xs:dayTimeDuration('-PT7H'))
2023-02-14T21:00:00-07:00
The following table contains examples and return values assuming an implicit time zone of -05:00:
Examples
Return Values
adjust-dateTime-to-timezone(
xs:dateTime('2023-02-15T17:00:00'))
2023-02-15T17:00:00-05:00
adjust-dateTime-to-timezone(
xs:dateTime('2023-02-15T17:00:00-03:00'))
2023-02-15T15:00:00-05:00

adjust-time-to-timezone

Adjusts a time value to a specific time zone, or removes the time zone component from the date value.

Syntax

fn:adjust-time-to-timezone(arg, timezone)
The following table describes the arguments:
Argument
Required/
Optional
Description
arg
Required
The time value that is to be adjusted.
The time-value is of type xs:time or is an empty sequence.
timezone
Optional
A duration that represents the time zone to which time-value is to be adjusted.

Return Value

The fn:adjust-time-to-timezone function behaves differently depending on whether the $arg date value already has a time zone, and on the value of the time zone provided as given below:

Examples

The following table contains examples and return values for the adjust-date-to-timezone function:
Examples
Return Values
adjust-time-to-timezone(
xs:time('17:00:00'),
xs:dayTimeDuration('-PT7H'))
17:00:00-07:00
adjust-time-to-timezone(
xs:time('17:00:00-03:00'),
xs:dayTimeDuration('-PT7H'))
13:00:00-07:00
adjust-time-to-timezone(
xs:time('17:00:00'), ())
17:00:00
adjust-time-to-timezone(
xs:time('17:00:00-03:00'), ())
17:00:00
adjust-time-to-timezone(
xs:time('17:00:00'))
17:00:00-05:00
adjust-time-to-timezone(
xs:time('17:00:00'),
xs:dayTimeDuration('-PT20H'))
Error FODT0003
The following table contains examples and return values assuming an implicit time zone of -05:00:
Examples
Return Values
adjust-time-to-timezone(
xs:time('17:00:00-03:00'))
15:00:00-05:00
adjust-time-to-timezone(
xs:time('22:00:00-08:00'))
01:00:00-05:00
adjust-time-to-timezone(
xs:time('01:00:00-02:00'))
22:00:00-05:00

current-date

Returns the current date.

Syntax

fn:current-date()

Return Value

The fn:current-date function takes no parameters, and returns the current date with the time zone. The time zone is implementation-dependent.

Example

If this function was invoked on January 12, 2023, the returned value would be 2023-01-12Z.

current-dateTime

Returns the current dateTime with time zone.

Syntax

fn:current-dateTime()

Return Value

The fn:current-dateTime function takes no parameters, and returns the current date and time with the time zone. If the function is called multiple times within the same query, it returns the same value every time. The time zone is implementation-dependent.

Example

If this function was invoked on January 12, 2023 in time zone Z, the returned value would be 2023-01-12T11:25:30.125Z.

current-time

Returns the current time.

Syntax

fn:current-time()

Return Value

The fn:current-time function takes no parameters, and returns the current time with the time zone. If the function is called multiple times within the same query, it returns the same value every time. The time zone is implementation-dependent.

Example

The following expression will return 23:17:00.000-05:00 as the result:
fn:current-time()

dateDiff

Returns the length of time between two dates. You can specify the format as years, months, days, hours, minutes, seconds, milliseconds, or microseconds. The dateDiff function subtracts the second date from the first date and returns the difference.
The dateDiff function calculates the value based on the number of months instead of the number of days. It calculates the date differences for partial months with the days selected in each month. To calculate the date difference for the partial month, dateDiff adds the days used within the month. It then divides the value with the total number of days in the selected month.
The dateDiff function gives a different value for the same period in the leap year period and a non-leap year period. The difference occurs when February is part of the dateDiff function. The dateDiff function divides the days with 29 for February for a leap year and 28 if it is not a leap year.
For example, you want to calculate the number of months from September 13 to February 19. In a leap year period, dateDiff calculates the month of February as 19/29 months or 0.655 months. In a non-leap year period, dateDiff calculates the month of February as 19/28 months or 0.678 months. The dateDiff function similarly calculates the difference in the dates for the remaining months and the dateDiff function returns the total value for the specified period.
Note: Some databases might use a different algorithm to calculate the difference in dates.

Syntax

date:dateDiff(xs:dateTime('date'), xs:dateTime('date'), 'format')
Note: You must manually add the xs:dateTime phrase and enclose the date values within single quotation marks.
The following table describes the arguments:
Argument
Required/ Optional
Description
date
Required
Date/Time data type. Passes the values for the first date that you want to compare.
You can enter any valid transformation expression.
date
Required
Date/Time data type. Passes the values for the second date that you want to compare.
You can enter any valid transformation expression.
format
Required
Format string that specifies the date or time measurement. You can specify years, months, days, hours, minutes, seconds, milliseconds, or microseconds. You can specify only one part of the date, such as 'mm'. Enclose the format strings within single quotation marks. The format string is not case sensitive. For example, the format string 'mm' is the same as 'MM', 'Mm', or 'mM'.

Return Value

Double value. If the first date is later than the second date, the return value is a positive number. If the first date is earlier than the second date, the return value is a negative number.
0 if the dates are the same.
NULL if one (or both) of the date values is NULL.

Examples

The following expressions return the number of hours between the DATE_PROMISED and DATE_SHIPPED columns:
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'HH')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'HH12')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'HH24')
The following table lists some sample values and return values:
DATE_PROMISED
DATE_SHIPPED
RETURN VALUE
Jan 1 1997 12:00:00AM
Mar 29 1997 12:00:00PM
-2100
Mar 29 1997 12:00:00PM
Jan 1 1997 12:00:00AM
2100
NULL
Dec 10 1997 5:55:10PM
NULL
Dec 10 1997 5:55:10PM
NULL
NULL
Jun 3 1997 1:13:46PM
Aug 23 1996 4:20:16PM
6812.89166666667
Feb 19 2004 12:00:00PM
Feb 19 2005 12:00:00PM
-8784
The following expressions return the number of days between the DATE_PROMISED and the DATE_SHIPPED columns:
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'D')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'DD')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'DDD')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'DY')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'DAY')
The following table lists some sample values and return values:
DATE_PROMISED
DATE_SHIPPED
RETURN VALUE
Jan 1 1997 12:00:00AM
Mar 29 1997 12:00:00PM
-87.5
Mar 29 1997 12:00:00PM
Jan 1 1997 12:00:00AM
87.5
NULL
Dec 10 1997 5:55:10PM
NULL
Dec 10 1997 5:55:10PM
NULL
NULL
Jun 3 1997 1:13:46PM
Aug 23 1996 4:20:16PM
283.870486111111
Feb 19 2004 12:00:00PM
Feb 19 2005 12:00:00PM
-366
The following expressions return the number of months between the DATE_PROMISED and DATE_SHIPPED columns:
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'MM')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'MON')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'MONTH')
The following table lists some sample values and return values:
DATE_PROMISED
DATE_SHIPPED
RETURN VALUE
Jan 1 1997 12:00:00AM
Mar 29 1997 12:00:00PM
-2.91935483870968
Mar 29 1997 12:00:00PM
Jan 1 1997 12:00:00AM
2.91935483870968
NULL
Dec 10 1997 5:55:10PM
NULL
Dec 10 1997 5:55:10PM
NULL
NULL
Jun 3 1997 1:13:46PM
Aug 23 1996 4:20:16PM
9.3290162037037
Feb 19 2004 12:00:00PM
Feb 19 2005 12:00:00PM
-12
The following expressions return the number of years between the DATE_PROMISED and DATE_SHIPPED columns:
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'Y')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'YY')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'YYY')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'YYYY')
The following table lists some sample values and return values:
DATE_PROMISED
DATE_SHIPPED
RETURN VALUE
Jan 1 1997 12:00:00AM
Mar 29 1997 12:00:00PM
-0.24327956989247
Mar 29 1997 12:00:00PM
Jan 1 1997 12:00:00AM
0.24327956989247
NULL
Dec 10 1997 5:55:10PM
NULL
Dec 10 1997 5:55:10PM
NULL
NULL
Jun 3 1997 1:13:46PM
Aug 23 1996 4:20:16PM
0.77741801697531
Feb 19 2004 12:00:00PM
Feb 19 2005 12:00:00PM
-1
The following expressions return the number of months between the DATE_PROMISED and DATE_SHIPPED columns:
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'MM')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'MON')
date:dateDiff(xs:dateTime('DATE_PROMISED'), xs:dateTime('DATE_SHIPPED'), 'MONTH')
The following table lists some sample values and return values:
DATE_PROMISED
DATE_SHIPPED
LEAP YEAR VALUE
(in Months)
NON-LEAP YEAR VALUE
(in Months)
Sept 13
Feb 19
-5.237931034
-5.260714286
NULL
Feb 19
NULL
N/A
Sept 13
NULL
NULL
N/A

dateTime

Constructs a dateTime value from a date value and a time value.

Syntax

fn:dateTime(arg1, arg2)
The fn:dateTimeAdd (arg1 as xs:date?, arg2 as xs:time?) is different from the xs:dateTime constructor, which accepts a single argument that includes the date and time. Time zone is taken into account when constructing the date/time.

Return Value

Example

The following expression returns 2023-06-12T11:35:29 as the result:
fn:dateTime((xs:date("2023-06-12")), (xs:time("11:35:29")))

day-from-date

Returns the day portion of a date.

Syntax

fn:day-from-date(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The date value from which the day component is to be extracted.
The date-value is of type xs:date, or is an empty sequence.

Return Value

Returns the day portion from an xs:date value in its localized form, as an integer between 1 and 31 inclusive.
If date-value is an empty sequence, the returned value is an empty sequence.

Example

The following expression returns 15 as the result:
fn:day-from-date(xs:date('2023-07-15'))

day-from-dateTime

Returns the day portion of a date/time.

Syntax

fn:day-from-dateTime(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The dateTime value from which the day component is to be extracted.
The dateTime-value is of type xs:dateTime or is an empty sequence.

Return Value

Returns the day portion from an xs:dateTime value in its localized form, as an integer between 1 and 31 inclusive.
If dateTime-value is an empty sequence, the returned value is an empty sequence.

Example

The following expression returns 15 as the result:
fn:day-from-dateTime(xs:dateTime('2023-07-15T18:00:00'))

days-from-duration

Returns the number of days in a duration.

Syntax

fn:days-from-duration(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The duration value from which the days component is to be extracted.
The duration-value is an empty sequence, or is a value that has one of the following types:
  • - xs:dayTimeDuration
  • - xs:duration
  • - xs:yearMonthDuration

Return Value

Example

The following expression returns the days from the duration:
fn:days-from-duration(xs:dayTimeDuration('DURATION'))
The following table lists some sample values and return values:
DURATION
RETURN VALUE
P5D
5
-PT24H
-1
PT23H
0
P1DT36H
2
PT1440M
1

getDatePart

Returns the specified part of a date as an integer value. Therefore, if you create an expression that returns the month portion of the date, and pass a date such as 1997-04-01T00:00:00, getDatePart returns 4.

Syntax

date:getDatePart(xs:dateTime('date'), 'format')
Note: You must manually add the xs:dateTime phrase and enclose the date values within single quotation marks.
The following table describes the arguments:
Argument
Required/ Optional
Description
date
Required
Date/Time data type.
You can enter any valid transformation expression.
format
Required
A format string that specifies the portion of the date value that you want to return. Enclose format strings within single quotation marks, for example, 'mm'. The format string is not case sensitive.
For example, if you pass the date 1997-04-01 to getDatePart, the format strings 'YYYY' returns 1997.

Return Value

Integer representing the specified part of the date.
NULL if a value passed to the function is NULL.

Examples

The following expressions return the hour for each date in the DATE_SHIPPED column. 12:00:00AM returns 0 because the default date format is based on the 24 hour interval:
date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'HH')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
1997-03-13T12:00:00AM
0
1997-09-2T2:00:01AM
2
1997-08-22T12:00:00PM
12
1997-06-3T11:30:44PM
23
NULL
NULL
The following expressions return the day for each date in the DATE_SHIPPED column:
date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'DD')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
1997-03-13T12:00:00AM
13
1997-06-3T11:30:44PM
3
1997-08-22T12:00:00PM
22
NULL
NULL
The following expressions return the month for each date in the DATE_SHIPPED column:
date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'MM')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
1997-03-13T12:00:00AM
3
1997-06-3T11:30:44PM
6
NULL
NULL
The following expressions return the year for each date in the DATE_SHIPPED column:
date:getDatePart(xs:dateTime('DATE_SHIPPED'), 'YYYY')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
1997-03-13T12:00:00AM
1997
1997-06-3T11:30:44PM
1997
NULL
NULL

getLocale

Returns a string representing the current locale where the process is running.

Syntax

date:getLocale()
Use the getLocale function to retrieve the current locale setting active within the system. It identifies regional or language specific settings that are used to generate certain values such as language code and a country/region code.

Return Value

Returns the locale value as a text string.

Example

If the process is being executed in the IST time zone, the following expression returns the locale information:
date:getLocale()
The following table lists some sample properties and values:
PROPERTY
VALUE
Base locale ID
en_IN
Language
en
Country
IN
Display name
English (India)

getTimeZone

Returns a string that specifies the timezone ID of the Secure Agent machine that runs the process.
For processes and taskflows that run on cloud server, the system always sets the timezone to GMT.

Syntax

date:getTimeZone()

Return Value

Returns the timezone ID as a string value.

Example

If you run the process on a Secure Agent configured with the system time zone set to IST, the function date:getTimeZone() returns IST.
If you run the process or taskflows on the Cloud Server, the function date:getTimeZone() returns GMT.

hours-from-dateTime

Returns the hour portion of a date/time.

Syntax

fn:hours-from-dateTime(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The dateTime value from which the hours component is to be extracted.
The dateTime-value is of type xs:dateTime or is an empty sequence.

Return Value

Returns the hour portion of an xs:dateTime value in its localized form, as an integer between 0 and 23 inclusive.
If dateTime-value is an empty sequence, the returned value is an empty sequence.

Example

The following expression returns the hour from the date/time:
fn:hours-from-dateTime(xs:dateTime('TIME'))
The following table lists some sample values and return values:
TIME
RETURN VALUE
2023-08-15T10:30:23
10
2023-08-15T10:30:23-05:00
10

hours-from-duration

Returns the hours in a duration.

Syntax

fn:hours-from-duration(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The duration value from which the hours component is to be extracted.
The duration-value is an empty sequence or is a value that has one of the following types:
  • - xs:dayTimeDuration
  • - xs:duration
  • - xs:yearMonthDuration

Return Value

Example

The following expression returns the hours from the duration:
fn:hours-from-duration(xs:dayTimeDuration('DURATION'))
The following table lists some sample values and return values:
DURATION
RETURN VALUE
P1DT5H
5
-PT36H
-12
PT23H
23
PT1H90M
2
PT2H59M
2
PT3600S
1

hours-from-time

Returns the hour portion of a time.

Syntax

fn:hours-from-time(arg)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
arg
Required
The time value from which the hours component is to be extracted.
The time-value is of type xs:time or is an empty sequence.

Return Value

Returns the hour portion of an xs:time value in its localized form, as an integer between 0 and 23 inclusive.
If time-value is an empty sequence, the returned value is an empty sequence.

Example

The following expression returns the hour from the time:
fn:hours-from-time(xs:time('TIME'))
The following table lists some sample values and return values:
TIME
RETURN VALUE
10:30:23
10
10:30:23-05:00
10
09:30:00-08:00
9

implicit-timezone

Returns the value of the implicit timezone property.

Syntax

fn:implicit-timezone()
The implicit time zone is used in comparisons and calculations involving date and time values that do not have explicitly defined time zones. The implicit time zone is defined by the implementation.

Return Value

Returns the implicit time zone as an xs:dayTimeDuration value.

Example

If the implicit time zone is UTC minus 5 hours, the following expression returns -PT5H as the result:
fn:implicit-timezone()

lastDay

Returns the date of the last day of the month for each date in a column.

Syntax

date:lastDay(date)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
date
Required
Date/Time data type. Passes the date for which you want to return the last day of the month.
You can enter any valid transformation expression that evaluates to a date.

Return Value

Date. The last day of the month for the date value that you pass to this function.
NULL if a value in the selected column is NULL.

Example

The following expression returns the current date as the last day:
date:lastDay(fn:current-dateTime('DATE'))
The following table lists some sample values and return values:
DATE
RETURN VALUE
18-04-98 01:00
Apr 18 1998 01:00:00 AM
20-08-99 05:00
Aug 20 1999 05:00:00 AM
The following expression returns the last day of the previous month for each date in the DATE column:
date:lastDay(date:addToDate(fn:current-dateTime('DATE','MM',-1))
The following table lists some sample values and return values:
DATE
RETURN VALUE
Apr 1 1998 12:00:00AM
Mar 31 1998 12:00:00AM
Jan 6 1998 12:00:00AM
Dec 31 1997 12:00:00AM
Feb 2 1996 12:00:00AM
Jan 31 1996 12:00:00AM
NULL
NULL
You can nest toDate to convert string values to a date. toDate function always includes time information. If you pass a string that does not have a time value, the date returned will include the time 00:00:00.
The following example returns the last day of the month for each date in the same format as the string:
date:lastDay(toDate('DATE', 'MON-DD-YYYY'))
The following table lists some sample values and return values:
DATE
RETURN VALUE
'18-NOV-98'
Nov-30-1998 00:00:00
'28-APR-98'
Apr-30-1998 00:00:00
NULL
NULL
'18-FEB-96'
Feb-29-1996 00:00:00(Leap year)
date:lastDay(date:toDate("DATE", "YYYY-MM-DD"))
The following table lists some sample values and return values:
DATE
RETURN VALUE
'18-NOV-98'
1998-Nov-30 00:00:00
'28-APR-98'
1998-Apr-30 00:00:00
NULL
NULL
'18-FEB-96'
1996-Feb-29 00:00:00(Leap year)

millisToDate

Converts the current time from milliseconds.

Syntax

date:millisToDate(millis)
Argument
Required/
Optional
Description
millis
Required
Numeric data type. Passes the values in milliseconds.

Return Value

The function returns a date that is the number of milliseconds passed since January 1, 1970, 00:00:00 UTC.

Examples

The function returns the corresponding date values for the value mentioned in the MILLISECONDS column:
MILLISECONDS
RETURN VALUE
1000
1970-01-01T00:00:01Z
1900800000  
1970-01-23T00:00:00Z

minutes-from-dateTime

Returns an xs:integer value between 0 and 59, both inclusive, representing the minute component in the localized value of $arg.

Syntax

fn:minutes-from-dateTime(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as datetime that you want to convert to minutes.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:integer value between 0 and 59, both inclusive, representing the minute component in the local value of $arg.

Examples

The function returns the corresponding date values for the value mentioned in the MILLISECONDS column:
MILLISECONDS
RETURN VALUE
1999-05-31T13:40:00-05:00
40
1999-05-31T13:30:00+05:30
30

minutes-from-duration

The function returns an xs:integer representing the minutes component in the value of $arg.

Syntax

fn:minutes-from-duration(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a duration that must be converted to minutes.

Return Value

The function returns an xs:integer representing the minutes component in the value of $arg. The result is obtained by casting $arg to an xs:dayTimeDuration.

Examples

The function returns the corresponding date values for the value mentioned in the DURATION column:
DURATION
RETURN VALUE
P3DT12H32M12S
32
-P5DT12H30M
-30

minutes-from-time

Returns an xs:integer value between 0 and 59, both inclusive, representing the minute component in the localized value of $arg.

Syntax

fn:minutes-from-time(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a time that must be converted to minutes.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:integer value between 0 and 59, both inclusive, representing the minute component in the local value of $arg.

Examples

The function returns the corresponding date values for the value mentioned in the TIME column:
TIME
RETURN VALUE
11:23:00
23
13:00:00Z
0

month-from-date

Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of $arg.

Syntax

fn:month-from-date(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a date that must be converted to months.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:integer value between 1 and 12, both inclusive, representing the month component in the local value of $arg.

Examples

The function returns the corresponding date values for the value mentioned in the DATE column:
DATE
RETURN VALUE
1991-05-31-05:00
05
2000-01-01+05:00
01

month-from-dateTime

Returns an xs:integer between 1 and 12, both inclusive, representing the month component in the localized value of $arg.

Syntax

fn:month-from-dateTime(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a datetime that must be converted to months.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:integer value between 1 and 12, both inclusive, representing the month component in the local value of $arg.

Examples

The function returns the corresponding date values for the value mentioned in the DATETIME column:
DATETIME
RETURN VALUE
1995-05-31T13:20:00-05:00
05
1996-12-31T19:20:00-05:00
12

months-from-duration

Returns an xs:integer representing the minutes component in the value of $arg . The result is obtained by casting $arg to an xs:dayTimeDuration.

Syntax

fn:months-from-duration(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a duration that must be converted to months.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:integer value between 1 and 12, both inclusive, representing the month component in the local value of $arg.

Examples

The function returns the corresponding date values for the value mentioned in the DURATION column:
DURATION
RETURN VALUE
1991-05-31-05:00
05
2000-01-01+05:00
01

seconds-from-dateTime

Returns an xs:decimal value greater than or equal to 0 and less than 60, representing the seconds and fractional seconds in the localized value of $arg.

Syntax

fn:seconds-from-dateTime(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a datetime that must be converted to seconds.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:decimal value greater than or equal to 0 and less than 60, representing the seconds and fractional seconds in the local value of $arg.

Examples

The function returns the corresponding date values for the value mentioned in the DATETIME column:
DATETIME
RETURN VALUE
2006-08-15T10:30:14.5
14.5
2001-05-31T13:20:40
40

seconds-from-duration

Returns an xs:decimal representing the seconds component in the value of $arg . The result is obtained by casting $arg to an xs:dayTimeDuration.

Syntax

fn:seconds-from-duration(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a duration that must be converted to seconds.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:decimal value greater than or equal to 0 and less than 60, representing the seconds and fractional seconds in the local value of $arg.

Examples

The function returns the corresponding date values for the value mentioned in the DURATION column :
DURATION
RETURN VALUE
PT30.8S
30.8

seconds-from-time

Returns an xs:decimal value greater than or equal to zero and less than 60, representing the seconds and fractional seconds in the localized value of $arg.

Syntax

fn:seconds-from-time(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a time that must be converted to seconds.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:decimal value greater than or equal to 0 and less than 60, representing the seconds and fractional seconds in the localized value of $arg.

Examples

The function returns the corresponding date values for the value mentioned as arg in the TIME column :
TIME
RETURN VALUE
13:20:11.5
11.5

timezone-from-date

Returns the timezone component of $arg, if any.

Syntax

fn:timezone-from-date(arg)

Return Value

If $arg has a timezone component, the result is an xs:dayTimeDuration that indicates deviation from UTC. Its value might range from +14:00 to -14:00 hours, both inclusive. Otherwise, the result is an empty sequence.

Examples

The function returns the corresponding date values for the value mentioned in the DATE column:
DATE
RETURN VALUE
1999-05-31-05:00
-PT5H

timezone-from-dateTime

Returns the timezone component of an xs:dateTime.

Syntax

fn:timezone-from-dateTime(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a datetime that must be converted to a timezone.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns the timezone component of $arg, if any. If $arg has a timezone component, the result is an xs:dayTimeDuration that indicates deviation from UTC. Its value might range from +14:00 to -14:00 hours, both inclusive. If $arg has no timezone component, the result is the empty sequence.

Examples

The function returns the corresponding date values for the value mentioned in the DATETIME column:
DATETIME
RETURN VALUE
1995-05-31T13:20:00-05:00
-PT5H

timezone-from-time

Returns the timezone component of an xs:time.

Syntax

fn:timezone-from-time(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a time that must be converted to a timezone.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise the fucntion returns the timezone component of the xs:time value supplied as argument. The result is an xs:dayTimeDuration that indicates deviation from UTC. Its value might range from +14:00 to -14:00 hours, both inclusive.

Examples

The function returns the corresponding date values for the value mentioned in the TIME column:
TIME
RETURN VALUE
12:00:00-05:00
-PT5H

toChar

Converts the date passed to a string based on the specified format string.

Syntax

date:toChar(date, format)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a date that must be converted to a specified format string.

Examples

The function returns the corresponding date values for the value mentioned as arg in the DATE column:
DATE
RETURN VALUE
date:toChar(08-02-2017, DL)
August 02, 2017

toDate

Converts a character string to a date data type. You use the toDate format strings to specify the format of the source strings.
The output port must be Date/Time for toDate expressions.
If you are converting two-digit years with toDate, use either the RR or YY format string. Do not use the YYYY format string.

Syntax

date:toDate(xs:dateTime('date'), 'format')
Note: You must manually add the date phrase and enclose the date values within single quotation marks.
The following table describes the arguments:
Argument
Required/
Optional
Description
date
Required
Must be a string data type. Passes the values that you want to convert to dates. You can enter any valid transformation expression.
format
Required
Enter a valid toDate format string. The format string must match the parts of the date argument. For example, if you pass the date 'Mar 15 1998 12:43:10AM', you must use the format string 'MON DD YYYY HH12:MI:SSAM'.

Return Value

Date.
The toDate function always returns a date and time. If you pass a string that does not have a time value, the date returned always includes the time 00:00:00.000000000. You can map the results of this function to any target column with a datetime data type.
NULL if you pass a NULL value to this function.

Examples

date:toDate(xs:dateTime('DATE_PROMISED'), 'MM/DD/YY')
The following table lists some sample values and return values:
DATE_PROMISED
RETURN VALUE
'01/22/98'
Jan 22 1998 00:00:00
'05/03/98'
May 3 1998 00:00:00
'11/10/98'
Nov 10 1998 00:00:00
'10/19/98'
Oct 19 1998 00:00:00
NULL
NULL
date:toDate(xs:dateTime('DATE_PROMISED'), 'MON DD YYYY HH12:MI:SSAM')
The following table lists some sample values and return values:
DATE_PROMISED
RETURN VALUE
'Jan 22 1998 02:14:56PM'
Jan 22 1998 02:14:56PM
'Mar 15 1998 11:11:11AM'
Mar 15 1998 11:11:11AM
'Jun 18 1998 10:10:10PM'
Jun 18 1998 10:10:10PM
'October 19 1998'
Error. Integration Service skips this row.
NULL
NULL
The following expression converts strings in the SHIP_DATE_MJD_STRING port to date values:
date:toDate(xs:dateTime('SHIP_DATE_MJD_STR'), 'J')
The following table lists some sample values and return values:
SHIP_DATE_MJD_STR
RETURN_VALUE
'2451544'
Dec 31 1999 00:00:00.000000000
'2415021'
Jan 1 1900 00:00:00.000000000
Because the J format string does not include the time portion of a date, the return values have the time set to 00:00:00.000000000.
The following expression converts a string to a four-digit year format. The current year is 1998:
date:toDate(xs:dateTime('DATE_STR'), 'MM/DD/RR')
The following table lists some sample values and return values:
DATE_STR
RETURN VALUE
'04/01/98'
04/01/1998 00:00:00.000000000
'08/17/05'
08/17/2005 00:00:00.000000000
The following expression converts a string to a four-digit year format. The current year is 1998:
date:toDate(xs:dateTime('DATE_STR'), 'MM/DD/YY')
The following table lists some sample values and return values:
DATE_STR
RETURN VALUE
'04/01/98'
04/01/1998 00:00:00.000000000
'08/17/05'
08/17/1905 00:00:00.000000000
The following expression converts a string to a four-digit year format. The current year is 1998:
date:toDate(date('DATE_STR'), 'MM/DD/Y')
The following table lists some sample values and return values:
DATE_STR
RETURN VALUE
'04/01/8'
04/01/1998 00:00:00.000000000
'08/17/5'
08/17/1995 00:00:00.000000000
The following expression converts a string to a four-digit year format. The current year is 1998:
date:toDate(xs:dateTime('DATE_STR'), 'MM/DD/YYY')
The following table lists some sample values and return values:
DATE_STR
RETURN VALUE
'04/01/998'
04/01/1998 00:00:00.000000000
'08/17/995'
08/17/1995 00:00:00.000000000
The following expression converts strings that includes the seconds since midnight to date values:
date:toDate(xs:dateTime('DATE_STR'), 'MM/DD/YYYY SSSSS')
The following table lists some sample values and return values:
DATE_STR
RETURN_VALUE
'12/31/1999 3783'
12/31/1999 01:02:03
'09/15/1996 86399'
09/15/1996 23:59:59

trunc (Dates)

Truncates dates to a specific year, month, day, hour, minute, second, or millisecond.
You can truncate the following date parts:

Syntax

date:trunc(xs:dateTime('date'), 'format')
Note: You must manually add the xs:dateTime phrase and enclose the date values within single quotation marks.
The following table describes the arguments:
Argument
Required/
Optional
Description
date
Required
Date/Time data type. The date values that you want to truncate. You can enter any valid transformation expression that evaluates to a date.
To pass a NULL value, you must specify an empty sequence in the following format: ()
format
Required
Enter a valid format string. The format string is not case sensitive.
To pass a NULL value, you must specify an empty sequence in the following format: ()

Return Value

Date.
NULL if a value passed to the function is NULL.

Examples

The following expressions truncate the year portion of dates in the DATE_SHIPPED column:
date:trunc(xs:dateTime('DATE_SHIPPED'), 'Y')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'YY')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'YYY')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'YYYY')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 1 1998 00:00:00.000000000
Apr 19 1998 1:31:20PM
Jan 1 1998 00:00:00.000000000
Jun 20 1998 3:50:04AM
Jan 1 1998 00:00:00.000000000
Dec 20 1998 3:29:55PM
Jan 1 1998 00:00:00.000000000
NULL
NULL
The following expressions truncate the month portion of each date in the DATE_SHIPPED column:
date:trunc(xs:dateTime('DATE_SHIPPED'), 'MM')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'MON')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'MONTH')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 1 1998 00:00:00.000000000
Apr 19 1998 1:31:20PM
Apr 1 1998 00:00:00.000000000
Jun 20 1998 3:50:04AM
Jun 1 1998 00:00:00.000000000
Dec 20 1998 3:29:55PM
Dec 1 1998 00:00:00.000000000
NULL
NULL
The following expressions truncate the day portion of each date in the DATE_SHIPPED column:
date:trunc(xs:dateTime('DATE_SHIPPED'), 'D')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'DD')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'DDD')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'DY')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'DAY')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 15 1998 00:00:00.000000000
Apr 19 1998 1:31:20PM
Apr 19 1998 00:00:00.000000000
Jun 20 1998 3:50:04AM
Jun 20 1998 00:00:00.000000000
Dec 20 1998 3:29:55PM
Dec 20 1998 00:00:00.000000000
Dec 31 1998 11:59:59PM
Dec 31 1998 00:00:00.000000000
NULL
NULL
The following expressions truncate the hour portion of each date in the DATE_SHIPPED column:
date:trunc(xs:dateTime('DATE_SHIPPED'), 'HH')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'HH12')
date:trunc(xs:dateTime('DATE_SHIPPED'), 'HH24')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:31AM
Jan 15 1998 02:00:00.000000000
Apr 19 1998 1:31:20PM
Apr 19 1998 13:00:00.000000000
Jun 20 1998 3:50:04AM
Jun 20 1998 03:00:00.000000000
Dec 20 1998 3:29:55PM
Dec 20 1998 15:00:00.000000000
Dec 31 1998 11:59:59PM
Dec 31 1998 23:00:00.000000000
NULL
NULL
The following expression truncates the minute portion of each date in the DATE_SHIPPED column:
date:trunc(xs:dateTime('DATE_SHIPPED'), 'MI')
The following table lists some sample values and return values:
DATE_SHIPPED
RETURN VALUE
Jan 15 1998 2:10:30AM
Jan 15 1998 02:10:00.000000000
Apr 19 1998 1:31:20PM
Apr 19 1998 13:31:00.000000000
Jun 20 1998 3:50:04AM
Jun 20 1998 03:50:00.000000000
Dec 20 1998 3:29:55PM
Dec 20 1998 15:29:00.000000000
Dec 31 1998 11:59:59PM
Dec 31 1998 23:59:00.000000000
NULL
NULL

year-from-date

Returns an xs:integer representing the year in the localized value of $arg. The value might be negative.

Syntax

fn:year-from-date(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a date that must be converted to a year format.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:integer representing the year in the localized value of $arg.

Examples

The function returns the corresponding year values for the value mentioned as arg in the DATE column:
DATE
RETURN VALUE
1999-06-30
1999
2001-01-01+05:00
2001

year-from-dateTime

Returns an xs:integer representing the year component in the localized value of $arg.

Syntax

fn:year-from-dateTime(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a datetime that must be converted to a year format.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:integer representing the year in the localized value of $arg.

Examples

The function returns the corresponding year values for the value mentioned as arg in the DATETIME column:
DATETIME
RETURN VALUE
1999-06-30+08:00
1999
2001-01-01+05:00
2001

years-from-duration

Returns an xs:integer representing the years component in the value of $arg. The result is obtained by casting $arg to an xs:yearMonthDuration.

Syntax

fn:years-from-duration(arg)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument as a duration that must be converted to years.

Return Value

If $arg is an empty sequence, the function returns the empty sequence. Otherwise, the function returns an xs:integer representing the years component in the value of $arg. Given that a duration is a ($months, $seconds) tuple, the result is the value of ($months idiv 12).

Examples

The function returns the corresponding date values for the value mentioned as arg in the DURATION column:
DATETIME
RETURN VALUE
P20Y15M
21
-P15M
-1

Lists

The following functions are available in the Lists section of the Expression Editor:

append

The append function in XQuery concatenates two input sequences by returning a sequence consisting of all items from the first sequence followed by all items from the second sequence.

Syntax

list:append(objectlist, newItem)
The following table describes the argument for this command:
Argument
Required/Optional
Description
objectlist
Required
The first sequence of items to be concatenated.
newItem
Required
The second sequence of items to append to the first

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
list:append((), ("a", "b"))
a;b
list:append(("apple"), ())
("apple")
list:append((), ())
()

Additional information

count

The count function in XQuery returns the number of items in a sequence.

Syntax

list:count(objectlist)
The following table describes the argument for this command:
Argument
Required/Optional
Description
objectlist
Required
The input sequence whose items are to be counted.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
list:count((1, 2, 3, 4))
4
list:count(())
0
list:count(("apple", "orange"))
2
list:count(document{<a/>, <b/>, <c/>}/child::node())
3
list:count(1 to 10)
10

Additional information

head

The head function in XQuery returns the first item in a sequence or the empty sequence if the input sequence is empty.

Syntax

list:head(objectlist)
The following table describes the argument for this command:
Argument
Required/Optional
Description
objectlist
Required
The input sequence from which the first item is to be returned.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
list:head((10, 20, 30))
10
list:head(())
()
list:head(("apple", "banana"))
"apple"

Additional information

list

The list function in XQuery converts a sequence of IDs into a semicolon-separated list of IDs for an object list.

Syntax

list:list(sequence)
The following table describes the argument for this command:
Argument
Required/Optional
Description
sequence
Required
A sequence of items to be included in the list.

Return Value

Returns a sequence of a semicolon-separated list of the input items.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
list:list(('a','b','c'))
("a", "b", "c")
list:list((1,2,3))
(1, 2, 3)

remove

The remove function in XQuery returns a sequence that is the input sequence with the item at the specified position removed.

Syntax

list:remove(objectlist, position)
The following table describes the argument for this command:
Argument
Required/Optional
Description
objectlist
Required
The input sequence from which an item is to be removed.
position
Required
The 1-based position of the item to remove from $seq.

Return Value

Additional information

replace

The replace function in XQuery replaces an existing item in a list with a new value.

Syntax

list:replace(objectlist, position, newItem)
The following table describes the argument for this command:
Argument
Required/Optional
Description
objectlist
Required
The sequence or list in which to replace the item.
position
Required
The 1-based position of the item to replace.
newItem
Required
The new item to insert in place of the old one.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
list:replace((10, 20, 30, 40), 2, 25)
(10, 25, 30, 40)
list:replace(("a", "b", "c"), 1, "x")
("x", "b", "c")
list:replace((1, 2, 3), 4, 5)
(1, 2, 3)

sequence

The sequence function in XQuery converts a semicolon-separated list to a sequence. When an object list field is inserted into formula and content, the field is wrapped in the list:sequence(objectlist_field_name) XQuery function. For object lists in hosted objects, this converts the semicolon separated list of IDs in the object list into a sequence. For object lists for process objects, the value is already a sequence and the function returns the list unchanged.

Examples

The following example converts an object list in a semicolon-separated list, then iterates over each item:
for $objectid in list:sequence($objectlist)
...
The following example converts a sequence of IDs into a semicolon-separated list of IDs for an object list for hosted objects. For an object list for process objects, it returns a sequence of values:
let $mergedObjectLists :=
( as:sequence($objectlist1), as:sequence($objectlist2) )
return list:list($mergedObjectLists)

tail

The tail function in XQuery returns all items of an input sequence except for the first item. If the input sequence is empty or contains only one item, the result is an empty sequence.

Syntax

list:tail(objectlist)
The following table describes the argument for this command:
Argument
Required/Optional
Description
objectlist
Required
The input sequence from which the tail, that is except for the first item is returned.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
list:tail((10, 20, 30, 40))
(20, 30, 40)
list:tail(("apple", "banana"))
("banana")
list:tail((<a/>, <b/>, <c/>))
(<b/>, <c/>)
list:tail((42))
()
list:tail(())
()

Math functions

The following functions are available in the Math section of the Expression Editor:

acos

The acos function in XQuery returns the arc cosine, that is inverse cosine of a numeric input value. The input represents the cosine of an angle, and the function returns the angle in radians, within the range 0 to π.

Syntax

math:acos(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
A numeric value representing the cosine of an angle; valid input range is -1 to 1.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:acos(1)
0
math:acos(0)
1.57079632679
math:acos(-1)
3.14159265359
math:acos(1.5)
empty sequence
math:acos(())
()

Additional information

asin

The asin function in XQuery returns the arcsine (inverse sine) of a numeric input value. The input represents the sine of an angle, and the function returns the angle in radians, within the range -π/2 to π/2.

Syntax

math:asin(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
A numeric value representing the sine of an angle; valid input range is -1 to 1.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:asin(0)
0
math:asin(1)
1.57079632679
math:asin(-1)
-1.57079632679
math:asin(1.5)
Empty sequence
math:asin(())
()

Additional information

atan

The atan function in XQuery returns the arctangent (inverse tangent) of a numeric input value. It calculates the angle in radians whose tangent is the given number. The result ranges from -π/2 to π/2.

Syntax

math:atan(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
A numeric value representing the tangent of an angle.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:atan(0)
0
math:atan(1)
0.78539816339
math:atan(-1)
-0.78539816339
math:atan(())
()

Additional information

atan2

The atan2 function in XQuery returns the angle in radians subtended at the origin by the point on a plane with coordinates (x, y) and the positive x-axis, the result being in the range -π to +π.

Syntax

math:atan2(arg1, arg2)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
The y-coordinate or numerator in the quotient (tan θ = y/x).
arg2
Required
The x-coordinate or denominator in the quotient.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT (approximate)
math:atan2(0, 1)
0
math:atan2(1, 1)
0.78539816339
math:atan2(1, 0)
1.57079632679
math:atan2(-1, -1)
-2.35619449019
math:atan2((), 2)
()
math:atan2(1, ())
()

Additional information

cos

The cos function in XQuery returns the cosine of a numeric input value, where the input represents an angle expressed in radians.

Syntax

math:cos(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The angle in radians to calculate the cosine of. It can be any numeric type.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:cos(0)
1
math:cos(math:pi())
-1
math:cos(())
()

Additional information

exp

The exp function in XQuery calculates the exponential of a given numeric input, returning e^{x}, where e is Euler’s number that is approximately 2.71828, and x is the input argument.

Syntax

math:exp(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The exponent value used to calculate ( e^{x} ). Accepts any numeric type (integer, decimal, float, double).

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:exp(0)
1
math:exp(1)
2.718281828459045
math:exp(2)
7.38905609893065
math:exp(-1)
0.367879441171442
math:exp(())
()

Additional information

exp10

The exp10 function in XQuery returns the value of 10 raised to the power of the numeric input argument, that is it calculates ( 10^x ), where ( x ) is the input value.

Syntax

math:exp10(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The exponent value ( x ) used to calculate ( 10^x ). Accepts any numeric type.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:exp10(0)
1
math:exp10(1)
10
math:exp10(2)
100
math:exp10(-1)
0.1
math:exp10(())
()

Additional information

log

The log function in XQuery returns the natural logarithm of the argument.

Syntax

math:log(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The positive numeric value to compute the natural logarithm of.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:log(1)
0
math:log(math:e())
1
math:log(10)
2.302585092994046
math:log(-1)
Error or empty sequence
math:log(())
()

Additional information

log10

The log10 function in XQuery returns the base-ten logarithm of the argument.

Syntax

math:log10(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The positive numeric value to compute the base-10 logarithm of.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:log10(1)
0
math:log10(10)
1
math:log10(100)
2
math:log10(-5)
Error or empty sequence
math:log10(())
()

Additional information

pi

The pi function in XQuery returns the mathematical constant π (pi), which is approximately 3.141592653589793.

Syntax

math:pi()

Return Value

Returns the constant π as a double precision floating-point number (xs:double).

Examples

The following table shows the sample value and its return value:
SAMPLE FUNCTION
OUTPUT
math:pi()
3.141592653589793

Additional information

pow

The pow function in XQuery returns the value of the first numeric argument raised to the power of the second numeric argument, that is ( x^y ).

Syntax

math:pow(arg1, arg2)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
The base number to be raised to a power.
arg2
Required
The exponent value to raise the base to.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:pow(2, 3)
8
math:pow(10, 0)
1
math:pow(5, -1)
0.2
math:pow((), 2)
()
math:pow(2, ())
()

Additional information

sin

The sin function in XQuery returns the sine of a numeric input angle, where the angle is given in radians.

Syntax

math:sin(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The angle in radians for which to compute the sine.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:sin(0)
0
math:sin(math:pi() div 2)
1
math:sin(math:pi())
1.2246467991473532E-16
math:sin(())
()

Additional information

sqrt

The sqrt function in XQuery returns the square root of a non-negative numeric input value.

Syntax

math:sqrt(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
A non-negative numeric value to compute the square root of.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:sqrt(9)
3
math:sqrt(0)
0
math:sqrt(2)
1.41421356237
math:sqrt(-1)
Error or empty sequence
math:sqrt(())
()

Additional information

tan

The tan function in XQuery returns the tangent of a given numeric value interpreted as an angle in radians.

Syntax

math:tan(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The input angle in radians.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
math:tan(0)
0
math:tan(1)
Approximately 1.55740772465490
math:tan(3.1415926535 div 4)
0.9999999999999999
math:tan(())
()

Additional information

Miscellaneous functions

The following functions are available in the Miscellaneous section of the Expression Editor:

aesDecryption

Decrypts the specified data with the provided key using the Advanced Encryption Standard (AES) algorithm. You must use the same key that you had used for encrypting the data in the aesEncryption function.

Syntax

util:aesDecryption(key, dataToDecrypt)

Return Value

The function returns a decrypted value.

Examples

The following example returns decrypted values for the data and the key passed as inputs in the function:
SAMPLE FUNCTION
OUTPUT
util:aesDecryption("1234@abc", "QETcr60N6QBSTB0X8V4Y+GL\/K0+nt7M6ON0VommGAU4=")
Informatica
util:aesEncryption("abcdefghkl", "tceVjWKW2lKWQ+ZJfHn4gUKXPDUPrEilmNoTueesPo0=")
cloud

aesEncryption

Encrypts the specified data with the provided key using the Advanced Encryption Standard (AES) algorithm.

Syntax

util:aesEncryption(key, dataToEncrypt)

Return Value

The function returns an encrypted value.

Examples

The following example returns encrypted values for the data and the key passed as inputs in the function:
SAMPLE FUNCTION
OUTPUT
util:aesEncryption("1234@abc", "Informatica")
QETcr60N6QBSTB0X8V4Y+GL\/K0+nt7M6ON0VommGAU4=
util:aesEncryption("abcdefghkl", "cloud")
tceVjWKW2lKWQ+ZJfHn4gUKXPDUPrEilmNoTueesPo0=

decode

Searches a column for a value that you specify. If the function finds the value, it returns a result value, which you define. You can build an unlimited number of searches within a decode function.
If you use decode to search for a value in a string column, you can either trim trailing blank characters with the rtrim function or include the blanks in the search string.

Syntax

util:decode(value, search1, result1, args, default)
The following table describes the arguments:
Argument
Required/
Optional
Description
value
Required
Passes the values that you want to search.
You can enter any valid transformation expression. You can pass any data type except Binary.
To pass a NULL value, you must specify an empty sequence in the following format: ()
search1
Required
Passes the values for which you want to search.
You can enter any valid transformation expression. You can pass any value with the same data type as the value argument. The search value must match the value argument. You cannot search for a portion of a value. Also, the search value is case sensitive.
For example, if you want to search for the string 'Halogen Flashlight' in a particular column, you must enter 'Halogen Flashlight, not just 'Halogen'. If you enter 'Halogen', the search does not find a matching value.
To pass a NULL value, you must specify an empty sequence in the following format: ()
result1
Required
The value that you want to return if the search finds a matching value.
You can enter any valid transformation expression and pass any data type except Binary.
To pass a NULL value, you must specify an empty sequence in the following format: ()
args
Required
Pairs of search values and result values separated by a comma.
For example, use the following syntax:
util:decode(value, search1, result1, search2, result2, searchn, resultn, default)
To pass a NULL value, you must specify an empty sequence in the following format: ()
default
Required
The value that you want to return if the search does not find a matching value.
You can enter any valid transformation expression and pass any data type except Binary.
To pass a NULL value, you must specify an empty sequence in the following format: ()

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
util:decode("apple", "apple", "Fruit", ("carrot", "Vegetable"), "Unknown")
"Fruit"
util:decode(3, 1, "One", (2, "Two", 3, "Three"), "N/A")
"Three"
util:decode("car", "bike", "Two-wheel", ("car", "Four-wheel"), "Unknown")
"Four-wheel"
util:decode("bus", "bike", "Two-wheel", ("car", "Four-wheel"), "Not found")
"Not found"
util:decode("bus", "bike", "Two-wheel", "car", "Four-wheel")
()

escape-Json-String 

Escapes special characters in the provided string to make it valid for usage in JSON.

Syntax

util:escapeJsonString(str)

Return Value

Encodes and returns the value as a JSON string according to http://json.org/ rules.

Examples

The function returns the following values for various strings provided as input:
STRING INPUT
RETURN VALUE
//
/\/\
Item1, Items2
Item1, Items2  
\n
\\\\n

getAssetLocation

Returns the location where the process or the guide that uses the function is stored.
Note: In addition to guides, you can use the getAssetLocation function only in processes that run on the Cloud Server.

Syntax

util:getAssetLocation()

Return Value

The function returns the location of the folder where the asset exists.

getAssetName

Returns the name of the process or the guide that uses the function.

Syntax

util:getAssetName()

Return Value

The function returns the asset name as a string in the output.

getInstanceStartTime

Returns the start time of the running instance of the specified process or guide.

Syntax

util:getInstanceStartTime()

Return Value

The function returns the start time of the running instance corresponding to the specified asset. The function returns an output in the yyyy-MM-dd'T'HH:mm:ss.SS'Z' format.

Examples

The following sample displays the result of the function that is used in a process:
2023-09-20T09:02:50.774Z

getOrganizationId

Returns the Informatica Intelligent Cloud Services organization ID string in the context of the executing instance.

Syntax

util:getOrganizationId()

Return Value

When the process is deployed on the agent, the function returns the output as $public.
When the process is deployed on the cloud server, the function returns the Informatica Intelligent Cloud Services organization ID string as the output.

Examples

The following sample displays the result of the function:

getOrganizationName

Returns the organization name in the context of the executing process, guide, service connector, or data access service connector.

Syntax

util:getOrganizationName()

Return Value

The function returns the organization name string as the output.

iif

Returns one of two values that you specify based on the results of a condition.

Syntax

util:iif(condition, val1 ,val2)
The following table describes the arguments:
Argument
Required/Optional
Description
condition
Required
The condition that you want to evaluate.
You can enter any valid transformation expression that evaluates to TRUE or FALSE.
val1
Required
The value that you want to return if the condition is TRUE. The return value is always the data type specified by this argument.
You can enter any valid transformation expression, including another iif expression. You can pass any data type except Binary.
val2
Optional
The value that you want to return if the condition is FALSE.
You can enter any valid transformation expression, including another iif expression. You can pass any data type except Binary.
The FALSE (val2) condition in the iif function is not required. If you omit val2, the function returns one of the following values when the condition is FALSE:
For example, the following expression does not include a FALSE condition and val1 is a string data type so decode returns an empty string for each row that evaluates to FALSE:
util:iif(SALES > 100, EMP_NAME)
The following table lists some sample values and return values:
SALES
EMP_NAME
RETURN VALUE
150
John Smith
John Smith
50
Pierre Bleu
'' (empty string)
120
Sally Green
Sally Green
NULL
Greg Jones
'' (empty string)

Return Value

val1 if the condition is TRUE.
val2 if the condition is FALSE.
For example, the following expression includes the FALSE condition NULL so decode returns NULL for each row that evaluates to FALSE:
util:iif(SALES > 100, EMP_NAME, NULL)
The following table lists some sample values and return values:
SALES
EMP_NAME
RETURN VALUE
150
John Smith
John Smith
50
Pierre Bleu
NULL
120
Sally Green
Sally Green
NULL
Greg Jones
NULL

iif and data types

When you use iif, the data type of the return value is the same as the data type of the result with the greatest precision.
For example, you have the following expression:
util:iif(SALES < 100, 1, .3333)
The TRUE result (1) is an integer and the FALSE result (.3333) is a decimal. The Decimal data type has a greater precision than the Integer data type. Therefore, the data type of the return value is always a decimal value.

Special uses of iif

Use nested iif statements to test multiple conditions. The following example tests for various conditions and returns 0 if sales is 0 or negative:
util:iif(SALES > 0, util:iif(SALES < 50, SALARY1, util:iif(SALES < 100, SALARY2, util:iif( SALES < 200, SALARY3, BONUS))), 0 )

in

Matches input data to a list of values. By default, the match is case sensitive.

Syntax

util:in(valueToSearch, values, caseFlag)
The following table describes the arguments:
Argument
Required/
Optional
Description
valueToSearch
Required
Can be a string, date, or numeric value. Input value that you want to match against a comma-separated list of values.
To pass a NULL value, you must specify an empty sequence in the following format: ()
values
Required
Can be a string, date, or numeric value. Comma-separated list of values that you want to search for. Values can be columns. There is no limit to the maximum number of values that you can list.
To pass a NULL value, you must specify an empty sequence in the following format: ()
caseFlag
Optional
Must be an integer. Determines whether the arguments in this function are case sensitive. You can enter any valid transformation expression.
When caseFlag is a number other than 0, the function is case sensitive.
When caseFlag is a null value or 0, the function is not case sensitive.

Return Value

TRUE (1) if the input value matches the list of values.
FALSE (0) if the input value does not match the list of values.
NULL if the input is a null value.

Example

The following expression determines if the input value is a safety knife, chisel point knife, or medium titanium knife. The input values do not have to match the case of the values in the comma-separated list:
util:in(ITEM_NAME, ‘Chisel Point Knife’, ‘Medium Titanium Knife’, ‘Safety Knife’, 0)
The following table lists some sample values and return values:
ITEM_NAME
RETURN VALUE
Stabilizing Vest
0 (FALSE)
Safety knife
1 (TRUE)
Medium Titanium knife
1 (TRUE)
NULL

isNull

Returns whether a value is NULL.

Syntax

util:isNull(value)
The following table describes the argument for this command:
Argument
Required/
Optional
Description
value
Required
Passes the rows that you want to evaluate. You can enter any valid transformation expression. You can pass a value of any data type except Binary.

Return Value

TRUE (1) if the value is NULL.
FALSE (0) if the value is not NULL.

Example

The following example checks for NULL values in the items table:
util:isNull( ITEM_NAME )
The following table lists some sample values and return values:
ITEM_NAME
RETURN VALUE
Flashlight
0 (FALSE)
NULL
1 (TRUE)
Regulator system
0 (FALSE)
''
0 (FALSE)  Empty string is not NULL

removeSystemNamespaceXML

Removes system namespaces from an XML document to provide a more simplified and readable XML structure.

Syntax

util:removeSystemNamespaceXML(currentElement)

Return Value

The function returns a more simplified and readable XML structure.

Examples

The following table contains an example of an XML code snippet that is passed as an input in the function and the corresponding XML output:
SAMPLE FUNCTION
OUTPUT

<root>
<Request xmlns:sf="http://schemas.active-endpoints.com/appmodules/screenflow/2010/10/avosScreenflow.xsd"
xmlns:aetgt="http://schemas.informatica.com/spi/types/2013/12/spi-interface/"
xmlns:ns2="http://schemas.informatica.com/spi/types/2013/12/spi-interface/"
xmlns:type="http://schemas.informatica.com/spi/types/2013/12/spi-interface/"
xmlns:ns4="http://schemas.active-endpoints.com/appmodules/screenflow/2011/06/avosHostEnvironment.xsd"
xmlns:ns3="http://schemas.active-endpoints.com/appmodules/screenflow/2011/07/avosCommon.xsd"
xmlns:ns5="http://schemas.active-endpoints.com/appmodules/screenflow/2012/09/avosObjectDiscovery.xsd"
xmlns:ns6="http://schemas.active-endpoints.com/appmodules/screenflow/2010/10/avosScreenflow.xsd">
<MessageID>001</MessageID>
<Customer>
<CustomerID>CUST123</CustomerID>
<Name>Jane Doe</Name>
</Customer>
<Order>
<OrderID>ORD789</OrderID>
<Product>Gadget X</Product>
<Quantity>5</Quantity>
</Order>
</Request>
</root>

<root>
<Request>
<MessageID>001</MessageID>
<Customer>
<CustomerID>CUST123</CustomerID>
<Name>Jane Doe</Name>
</Customer>
<Order>
<OrderID>ORD789</OrderID>
<Product>Gadget X</Product>
<Quantity>5</Quantity>
</Order>
</Request>
</root>

rsaDecryption

Asymmetric encryption is a cryptographic method that uses a public-private key pair and optionally a passphrase or password to encrypt and decrypt data. The rsaDecryption function decrypts cipher text using the RSA algorithm with the provided private key and passphrase. You can protect private keys with a passphrase. If you're not using a passphrase, leave the string empty. If your key file isn't password protected, the passphrase is ignored.
Note: You can decrypt data only in a process configured to run on a Secure Agent, and the key file must be available on the selected agent.
You can use the following types of keys for RSA encryption:
RSA limits the amount of data you can encrypted or decrypted based on the following key size:

Syntax

util:rsaDecryption(keyType, key, passPhrase, dataToDecrypt)
The following table describes the arguments for this command:
Argument
Description
keyType
Specifies the type of RSA key used.
You can enter one of the following values:
  • - GPG
  • - OpenSSL
key
The absolute path of the private key file on the selected agent.
The Expression Editor accepts the file path of keys as input instead of the keys itself.
dataToDecrypt
The cipher text in the base64-encoded format that you want to decrypt.

Return Value

The function returns the data as a decrypted values.

Examples

The following example returns decrypted values for the data based on the key passed as inputs in the function:
SAMPLE FUNCTION
OUTPUT
util:rsaDecryption("GPG", "/absolute/path/to/private_key.asc", "password", "Bms....w5Y=")
Hello, world!

rsaEncryption

Asymmetric encryption is a cryptographic method that uses a public-private key pair and optionally a passphrase or password to encrypt and decrypt data. The rsaEncryption function encrypts data using the RSA algorithm and the provided public key.
Note: You can encrypt data only in a process configured to run on a Secure Agent, and the key file must be available on the selected agent.
You can use the following types of keys for RSA encryption:
RSA limits the amount of data you can encrypted or decrypted based on the following key size:

Syntax

util:rsaEncryption(keyType, key, dataToEncrypt)
The following table describes the arguments for this command:
Argument
Description
keyType
Specifies the type of RSA key used.
You can enter one of the following values:
  • - GPG
  • - OpenSSL
key
The absolute path of the public key file on the selected agent.
The Expression Editor accepts the file path of keys as input instead of the keys itself.
dataToEncrypt
The plain text data that you want to encrypt.

Return Value

The function returns a base64-encoded text as a result of the RSA encryption.

Examples

The following example returns encrypted values for the data based on the key passed as inputs in the function:
SAMPLE FUNCTION
OUTPUT
util:rsaEncryption("GPG", "/absolute/path/to/public_key.asc", "Hello, world!")
BmselDb3Z....QzE0XCyngU4JReww5Y=

toDecimal

Converts a string or numeric value to a decimal value. The toDecimal function ignores leading spaces.

Syntax

util:toDecimal(value, scale)
The following table describes the arguments:
Argument
Required/
Optional
Description
value
Required
Must be a string or numeric data type. Passes the value that you want to convert to decimals.
You can enter any valid transformation expression.
scale
Optional
Must be an integer literal between 0 and 28, inclusive. Specifies the number of digits allowed after the decimal point. If you omit this argument, the function returns a value with the same scale as the input value.
This argument is required in advanced mode.

Return Value

Decimal of precision and scale between 0 and 28, inclusive.
0 if the value in the selected column is an empty string or a non-numeric character.
NULL if a value passed to the function is NULL.

Example

This expression uses values from the column IN_TAX. The data type is decimal with precision of 10 and scale of 3:
util:toDecimal(IN_TAX, 3)
The following table lists some sample values and return values:
IN_TAX
RETURN VALUE
'15.6789'
15.679
'60.2'
60.200
'118.348'
118.348
NULL
NULL
'A12.3Grove'
0
This expression uses values from the column Sales. The data type is decimal with precision of 10 and scale of 2:
util:toDecimal(Sales, 2)
The following table lists some sample values and return values:
Sales
RETURN VALUE
'1234'
1234
'1234.01'
1234.01
If you want the return value in 1234.00 format, you can use the following expression:
format-number(util:toDecimal('1234', 2), '0.00')

Decimal overflow

If the size of the number on the left hand side of the decimal point exceeds the precision, the decimal operation overflows.
To resolve this, modify the scale and/or precision of the expression port and connect downstream ports of the mapping to accommodate the size of the input data in the expression.
For example:
If a numeric field is defined to be size 28 with scale of 15, this accepts 13 numbers on the left side of the decimal and 15 on the right. So the following numbers would be valid for a number of 28,15:
1234567890123.11143
13575.123451234567891
However, these numbers would cause a decimal overflow error:
111112222233333.4444
123.1111122222333334

toInteger

Converts a string or numeric value to an integer. The toInteger syntax contains an optional argument that you can choose to round the number to the nearest integer or truncate the decimal portion. The toInteger function ignores leading spaces.

Syntax

util:toInteger(value, flag)
The following table describes the arguments:
Argument
Required/
Optional
Description
value
Required
Must be a string or numeric data type. Passes the value that you want to convert to an integer.
You can enter any valid transformation expression.
flag
Optional
Specifies whether to truncate or round the decimal portion. The flag must be an integer literal or the constants TRUE or FALSE:
  • - toInteger truncates the decimal portion when the flag is TRUE or a number other than 0.
  • - toInteger rounds the value to the nearest integer if the flag is FALSE or 0 or if you omit this argument.

Return Value

Integer.
NULL if a value passed to the function is NULL.
0 if a value passed to the function contains alphanumeric characters.

Example

The following expressions use values from the column IN_TAX:
util:toInteger(IN_TAX, fn:boolean(1))
The following table lists some sample values and return values:
IN_TAX
RETURN VALUE
'15.6789'
15
'60.2'
60
'118.348'
118
NULL
NULL
'A12.3Grove'
0
'    123.87'
123
'-15.6789'
-15
'-15.23'
-15

trace

Provides an execution trace to be used in debugging queries.
The fn:trace function accepts items and a label for those items and returns the items unchanged. The exact behavior of the function is implementation-dependent, but generally the processor puts the label and the value of the items in a log file or user console.

Syntax

fn:trace(value, label)
The following table describes the arguments:
Argument
Required/
Optional
Description
value
Required
The items to trace.
label
Optional
A label to display with the trace information.

Return Value

Based on the items and a label for those items, it returns the items unchanged.

Example

Assume that you have the following variable definition:
let $var1 := 5
The following expression returns The correct value is: 5 as the result:
fn:trace($var1, 'The correct value is: ')

trunc (Numbers)

Truncates numbers to a specific digit based on the number of decimal places specified by the precision.

Syntax

util:trunc(arg, precision)
Argument
Required/
Optional
Description
arg
Required
Numeric data type. Passes the argument that you want to truncate. You can enter any valid expression that evaluates to a numeric data type.
precision
Optional
Can be a positive or negative integer. You can enter any valid expression that evaluates to an integer. The integer specifies the number of digits to truncate.
If precision is a positive integer, trunc returns arg with the number of decimal places specified by precision. If precision is a negative integer, trunc changes the specified digits to the left of the decimal point to zeros. If you omit the precision argument, trunc truncates the decimal portion of arg and returns an integer.
All trailing zeros after the decimal point in an argument will be truncated. For example, the following expression returns 2345.7535 as the result:
util:trunc(2345.75350000, 6)
If a number contains more than 16-digits after the decimal point, the result returns an exponential value due to an XQuery limitation.
For example, the following expression returns 1.234567812345679E7 as the result:
util:trunc(12345678.12345678901234567890, 15)
If you pass a decimal precision value, the arg is rounded to the nearest integer before evaluating the expression.

Return Value

Numeric or integer value based on the parameters provided in the function.

Examples

The following expressions truncate the values in the PRICE column:
util:trunc(PRICE, 3)
PRICE
RETURN VALUE
12.9995
12.999
-18.8652  
-18.865
56.9563
56.956
15.9928
15.992
util:trunc(PRICE, -1)
PRICE
RETURN VALUE
12.99
10
-187.86  
-180
56.95
50
1235.99
1230
util:trunc(PRICE )
PRICE
RETURN VALUE
12.99
12
-18.99  
-18
56.95
56
15.99
15

serialize

This function serializes the supplied node $arg, returning the serialized node as a string.

Syntax

fn:serialize()

Return Value

When the process is deployed on the cloud server or agent, the function returns a string output.

Examples

The function returns the following output for the provided input using Saxon 9.5.1.10 PE version:
INPUT
OUTPUT
<a/> (element)
&lt;?xml...?&gt;&lt;a/&gt;
"<a/>" (string)
<a/>
The function returns the following output for the provided input using Saxon 11.5 EE version:
INPUT
OUTPUT
<a/> (element)
&lt;a/&gt;
"<a/>" (string)
&lt;a/&gt;
For more information about changed behaviors in Application Integration due to Saxon libraries upgrade, see the following knowledge base article: KB 000205484.

simplifyXml

Rearranges data within XML so that it can be used by the process objects.

Syntax

util:simplifyXml(undefined)

Return Value

When the process is deployed on the cloud server or agent, the function returns an output without name spaces and convert attributes into child elements.

Examples

The function returns the following output for the XML data provided as input:
INPUT
OUTPUT
<ns:root xmlns:ns="https://qwerty"
attrKey="attrValue">
data
</ns:root>
<root><attrKey>attrValue</attrKey>
<text>data</text>
</root>

Numbers functions

The following functions are available in the Numbers section of the Expression Editor:

abs

Returns the absolute value of a numeric value.

Syntax

fn:abs(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
Numeric datatype. Returns the absolute value of a number. You can enter any valid expression.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:abs(40)
40
fn:abs(3.5)
3.5
fn:abs(-4)
-4
Null
Null
The following expression returns the difference between two numbers as a positive value, regardless of which number is larger:
fn:abs( PRICE - COST )
PRICE
COST
RETURN VALUE
250
150
100
52
48
4
169.95
69.95
100
70
30
40
430
330
100
100
200
100

avg

Returns the average of the values in the input sequence given in the argument, that is, the sum of the values divided by the number of values.

Syntax

fn:avg(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
Numeric data type. Passes the values for which you want to calculate an average. You can enter any valid transformation expression.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE Function
OUTPUT
fn:avg( (1, 2, 3, 4, 5) )
3
fn:avg( (1, 2, 3, (), 4, 5) )
3
fn:avg( () )
()
The following expression returns the average wholesale cost of flashlights:
fn:avg( WHOLESALE_COST, ITEM_NAME='Flashlight' )
ITEM_NAME
WHOLESALE_COST
Flashlight
35.00
Navigation Compass
8.05
Regulator System
150.00
Flashlight
29.00
Depth/Pressure Gauge
88.00
Flashlight
31.00

Tip

You can perform arithmetic on the values passed to AVG before the function calculates the average. For example:
fn:avg( QTY * PRICE - DISCOUNT )

ceiling

Returns the smallest, that is, closest to negative infinity number with no fractional part that is not less than the value of argument. If the type of argument is one of the four numeric types xs:float, xs:double, xs:decimal, or xs:integer, the type of the result is the same as the type of argument. If the type of argument is a type derived from one of the numeric types, the result is an instance of the base numeric type.

Syntax

fn:ceiling(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
Numeric data type. You can enter any valid expression.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:ceiling(5)
5
fn:ceiling(5.1)
6
fn:ceiling(5.5)
6
fn:ceiling(-5.5)
-5
fn:ceiling(-5.51)
-5
fn:ceiling( () )
()
The following expression returns the price rounded to the next integer:
fn:ceiling( PRICE )
PRICE
RETURN VALUE
39.79
40
125.12
126
74.24
75
NULL
NULL
-100.99
-100

Tip

You can perform arithmetic on the values passed to ceiling before ceiling returns the next integer value. For example, if you wanted to multiply a numeric value by 10 before you calculated the smallest integer less than the modified value, you might write the function as follows:
fn:ceiling( PRICE * 10 )

floor

Returns the largest, that is, closest to positive infinity number with no fractional part that is not greater than the value of argument. If type of argument is one of the four numeric types xs:float, xs:double, xs:decimal, or xs:integer, the type of the result is the same as the type of argument. If the type of argument is a type derived from one of the numeric types, the result is an instance of the base numeric type.

Syntax

fn:floor(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
Numeric datatype. You can enter any valid expression as long as it evaluates to numeric data.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:floor(5)
5
fn:floor(5.1)
5
fn:floor(5.7)
5
fn:floor(-5.1)
-6
fn:floor(-5.7)
-6
fn:floor( () )
()
The following expression returns the largest integer less than or equal to the values in the PRICE column:
fn:floor( PRICE )
PRICE
RETURN VALUE
39.79
39
125.12
125
74.24
74
NULL
NULL
-100.99
-101

Tip

You can perform arithmetic on the values you pass to floor. For example, to multiply a numeric value by 10 and then calculate the largest integer that is less than the product, you might write the function as follows:
fn:floor( UNIT_PRICE * 10 )

max

The max XQuery function is used to find the maximum value in a sequence of atomic values.

Syntax

fn:max(arg, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The sequence of values.
collation
Optional
A string used to specify the collation for string comparisons. It defines how string comparison is performed. If not provided, the default collation applies. This parameter is relevant when comparing strings.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:max( (2, 1, 5, 4, 3) )
5
fn:max( ('a', 'b', 'c') )
c
fn:max( (xs:date('1999-04-15'), current-date()) )
Current date
fn:max( 2 )
2
fn:max( () )
()

min

Selects an item from the input sequence argument whose value is less than or equal to the value of every other item in the input sequence. If there are two or more such items, then the specific item whose value is returned is implementation dependent.

Syntax

fn:min(arg, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The sequence of values.
collation
Required
The collation to use for comparing strings.

Return Value

xs:anyAtomicType?
NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:min( (2.0, 1, 3.5, 4) )
1
fn:min( ('a', 'b', 'c') )
a

round

Returns the number with no fractional part that is closest to the argument. If there are two such numbers, the one that is closest to positive infinity is returned. If type of argument is one of the four numeric types xs:float, xs:double, xs:decimal, or xs:integer, the type of the result is the same as the type of argument. If the type of argument is a type derived from one of the numeric types, the result is an instance of the base numeric type.

Syntax

fn:round(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
Numeric datatype. Returns the number with no fractional part that is closest to the argument. You can enter any valid expression.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:round(5)
5
fn:round(5.1)
5
fn:round(5.5)
6
fn:round(-5.5)
-5
fn:round(-5.51)
-6

round-half-to-even

The value returned is the numerically closest value to $arg that is a multiple of ten to the power of minus $precision. If two such values are equally near, for example, if the fractional part in $arg is exactly .500..., the function returns the one whose least significant digit is even.

Syntax

fn:round-half-to-even(arg, precision)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The number to round.
precision
Required
The precision to round the number to. It can be a positive or negative integer.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:round-half-to-even(5.5)
6
fn:round-half-to-even(6.5)
6
fn:round-half-to-even(9372.253, 2)
9372.25
fn:round-half-to-even(9372.253, 0)
9372
fn:round-half-to-even(9372.253, -3)
9000

sum

Returns a value obtained by adding together the values in $arg.

Syntax

fn:sum(arg, zero)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
Numeric data type. Passes the values you want to add. You can enter any valid transformation expression. You can use operators to add values in different fields.
zero
Required
The return condition for an empty sequence. If $zero is not specified, the value returned for an empty sequence is the xs:integer value 0. If $zero is specified, the value returned for an empty sequence is $zero.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:sum( (1, 2, 3) )
6
fn:sum( (1, 2, 3, () ) )
6
fn:sum( () )
0
fn:sum( (), () )
()
The following expression returns the sum of all values greater than 2000 in the Sales field:
sum( SALES, SALES > 2000 )
SALES
2500.0
1900.0
1200.0
NULL
3458.0
4519.0
RETURN VALUE: 10477.0

Tip

You can perform arithmetic on the values passed to sum before the function calculates the total. For example:
sum( QTY * PRICE - DISCOUNT )

Sequences functions

The following functions are available in the Sequences section of the Expression Editor:

count

The count function in XQuery is used to determine the number of items in a sequence.

Syntax

fn:count(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The sequence of items to count.

Return Value

Examples

If you have an XML document containing a list of books and you want to count how many books are listed:
<library>
<book>Book A</book>
<book>Book B</book>
<book>Book C</book>
</library>
Use the following XQuery:
let $books := doc("library.xml")/library/book
return fn:count($books)
The output is 3.
The following table lists some additional sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:count( (1, 2, 3) )
3
fn:count( (1, 2, 3, () ) )
3
fn:count( (1, 2, 3, 1, 2 ) )
5
fn:count( () )
0

distinct-values

The distinct-values function in XQuery returns a sequence containing only the distinct atomic values from the provided sequence, effectively removing any duplicates.

Syntax

fn:distinct-values(arg, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The sequence of atomic values.
collation
Optional
The collation to use for comparing strings.

Return Value

Returns a sequence where duplicate values in $arg have been removed, keeping only one instance for each set of values that are equal (eq) to each other. Values of type xs:untypedAtomic are treated as xs:string for comparison purposes. If values cannot be compared because the eq operator is not defined for their types, these values are treated as distinct. The order of the returned sequence may vary depending on the implementation.

Examples

Consider the following XML sample:
let $in-xml :=
<in-xml>
<a>3</a>
<b>5</b>
<b>3</b>
</in-xml>
The following table lists some sample values and return values based on the above snippet:
SAMPLE FUNCTION
OUTPUT
fn:distinct-values( ('a', 'b', 'a') )
('a', 'b')
fn:distinct-values( (1, 2, 3) )
(1, 2, 3)
fn:distinct-values( ('a', 2, 3) )
('a', 2, 3)
fn:distinct-values(
(xs:integer('1'),
xs:decimal('1.0'),
xs:float('1.0E0') ) )
1
fn:distinct-values($in-xml/*)
(3, 5)
fn:distinct-values( () )
()

index-of

The index-of function in XQuery is used to find the positions of items in a sequence that are equal to a given search item. It returns a sequence of positions where the specified item occurs.

Syntax

fn:index-of(seqParam, srchParam, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
seqParam
Required
The sequence of atomic values to be searched. This sequence can include strings, numbers, and booleans.
srchParam
Optional
The item for which you want to find the index positions within $seqParam.
collation
Optional
A string specifying the collation to use when comparing strings, if required. If omitted, the default collation is used.

Return Value

Returns a sequence of positive integers giving the positions within the sequence $seqParam of items that are equal to $srchParam. If no matches are found, it returns an empty sequence.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:index-of( ('a', 'b', 'c'), 'a')
1
fn:index-of( ('a', 'b', 'c'), 'd')
()
fn:index-of( (4, 5, 6, 4), 4)
(1, 4)
fn:index-of( (4, 5, 6, 4), 04.0)
(1, 4)
fn:index-of( ('a', 5, 6), 'a')
1
fn:index-of( (), 'a')
()
fn:index-of( (<a>1</a>, <b>1</b>), <c>1</c> )
(1, 2)

insert-before

The insert-before function in XQuery is used to insert items into a sequence at a specified position. This function allows the modification of sequences by adding elements before a designated index.

Syntax

fn:insert-before(target, position, inserts)
The following table describes the argument for this command:
Argument
Required/Optional
Description
target
Required
The sequence into which new items will be inserted.
position
Optional
The position in the $target sequence before which the items in $inserts should be inserted. Positions are 1-based. If the position is less than 1, the items are inserted at the beginning of the sequence; if the position is greater than the length of the sequence, the items are appended to the end.
inserts
Required
The sequence of items to be inserted into the $target sequence.

Return Value

The fn:insert-before function returns a copy of the $target sequence with the item(s) in $inserts inserted at the position indicated by $position. Position numbers start at 1, not 0.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:insert-before( ('a', 'b', 'c'), 1, ('x', 'y'))
('x', 'y', 'a', 'b', 'c')
fn:insert-before( ('a', 'b', 'c'), 2, ('x', 'y'))
('a', 'x', 'y', 'b', 'c')
fn:insert-before( ('a', 'b', 'c'), 10, ('x', 'y'))
('a', 'b', 'c', 'x', 'y')
fn:insert-before( ('a', 'b', 'c'), 0, ('x', 'y'))
('x', 'y', 'a', 'b', 'c')
fn:insert-before( ('a', 'b', 'c'), 2, ())
('a', 'b', 'c')
fn:insert-before( (), 3, ('a', 'b', 'c') )
('a', 'b', 'c')
fn:insert-before((1, 2, 3), 2, ())
(1, 2, 3)

last

The last function in XQuery is used to determine the position number of the last item in the current context node list during the evaluation of an expression. It is particularly useful within XPath expressions and FLWOR loops to determine the size or to operate on the last item of a sequence.

Syntax

fn:last()
The last function does not take any parameters. It operates within a context, usually within XPath expressions or FLWOR (For, Let, Where, Order by, Return) expressions.

Return Value

Returns the context size from the dynamic context.
It returns the integer position of the last item in the current context sequence. If you are iterating over a sequence, last() provides the total number of items in that sequence.

Examples

The following table lists some sample queries and return values:
SAMPLE FUNCTION
OUTPUT
let $doc :=
<items>
<item>Apple</item>
<item>Banana</item>
<item>Cherry</item>
</items>
(: Select the last <item> :)
let $lastItem := $doc/item[position() = fn:last()]
(: Select all but the last <item> :)
let $allButLast := $doc/item[position() lt fn:last()]
return
<results>
<last-item>{$lastItem/text()}</last-item>
<all-but-last>{ $allButLast/text() }</all-but-last>
</results>
<results><last-item>Cherry</last-item><all-but-last>Apple Banana</all-but-last></results>

position

The position function in XQuery is used to determine the current position number of an item during the iteration over a sequence.

Syntax

fn:position()
The position function does not require any parameters. It operates within the context of a sequence, typically used in iterative expressions like FLWOR loops.

Return Value

Returns the context position from the dynamic context. It returns an integer representing the position starting with 1, not 0, of the current context item within the context sequence.

Examples

The following table lists some sample queries and return values:
SAMPLE FUNCTION
OUTPUT
let $doc :=
<items>
<item>Apple</item>
<item>Banana</item>
<item>Cherry</item>
</items>
(: Select the last <item> :)
let $lastItem := $doc/item[position() = fn:last()]
(: Select all but the last <item> :)
let $allButLast := $doc/item[position() lt fn:last()]
return
<results>
<last-item>{$lastItem/text()}</last-item>
<all-but-last>{ $allButLast/text() }</all-but-last>
</results>
<results><last-item>Cherry</last-item><all-but-last>Apple Banana</all-but-last></results>

remove

The remove function in XQuery is used to eliminate an item from a sequence located at a specified position. This function helps in restructuring sequences by removing items without altering the rest.

Syntax

fn:remove(target, position)
The following table describes the argument for this command:
Argument
Required/Optional
Description
target
Required
The sequence from which an item will be removed.
position
Optional
The position of the item in the sequence that should be removed. If $pos is less than 1 or greater than the number of items in the sequence, the sequence remains unchanged.

Return Value

Returns a sequence that includes all the items except for the one at the specified position. If the position is out of range, it returns the original sequence.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:remove( ('a', 'b', 'c'), 2)
('a', 'c')
fn:remove( ('a', 'b', 'c'), 10)
('a', 'b', 'c')
fn:remove( ('a', 'b', 'c'), 0)
('a', 'b', 'c')

reverse

Reverses the order of items in a sequence.

Syntax

fn:reverse(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
Any character value. Value you want to reverse.

Return Value

String. Reverse of the input value. If $arg is the empty sequence, the empty sequence is returned.

Example

The following expression reverses the numbers of the customer code:
fn:reverse( CUSTOMER_CODE )
CUSTOMER_CODE
RETURN VALUE
0001
1
0002
2
0003
3
0004
4
(())
()

subsequence

The subsequence function in XQuery is designed to retrieve a specific portion of a sequence based on a starting location and an optional length. It allows extracting parts of a sequence efficiently, focusing only on the desired segment.

Syntax

fn:subsequence(sourceSeq, startingLoc, length)
The following table describes the argument for this command:
Argument
Required/Optional
Description
sourceSeq
Required
The input sequence from which a subsequence will be extracted.
startingLoc
Optional
The 1-based position within $sourceSeq where the subsequence starts. Non-integer values are rounded to the nearest integer. If $startingLoc is less than 1, it adjusts appropriately to start from the beginning of the sequence.
length
Optional
The number of items to include in the subsequence. Non-integer values are rounded to the nearest integer. If not specified or if the value is such that the subsequence extends beyond the end of $sourceSeq, all remaining items are included.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:subsequence(
('a', 'b', 'c', 'd', 'e'), 3)
('c', 'd', 'e')
fn:subsequence(
('a', 'b', 'c', 'd', 'e'), 3, 2)
('c', 'd')
fn:subsequence(
('a', 'b', 'c', 'd', 'e'), 3, 10)
('c', 'd', 'e')
fn:subsequence(
('a', 'b', 'c', 'd', 'e'), 10)
()
fn:subsequence(
('a', 'b', 'c', 'd', 'e'), -2, 5)
('a', 'b')
fn:subsequence( (), 3)
()
fn:subsequence((5, 10, 15, 20), 2.5, 2.6)
15, 20

unordered

The unordered function in XQuery is used to indicate that the order of items in a sequence does not matter for a particular operation. It informs the query engine to ignore the order, potentially optimizing performance, especially in parallel processing scenarios.

Syntax

fn:unordered(sourceSeq)
The following table describes the argument for this command:
Argument
Required/Optional
Description
sourceSeq
Required
The sequence of items whose order is deemed unimportant. This sequence can contain any kind of items, including nodes, elements, and atomic values.

Return Value

Returns the same sequence of items as $sourceSeq, but the order of the items might change during query evaluation. The specific returned order is implementation-dependent and might vary.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:unordered((3, 1, 4, 1, 5, 9))
3, 1, 4, 1, 5, 9
fn:unordered(("a", "o", "b", "g"))
a, o, b, g

Strings functions

The following functions are available in the Strings section of the Expression Editor:

codepoint-equal

The codepoint-equal function in XQuery is used to compare two strings to determine if they are equal based on their Unicode code points. It checks if two strings are identical without considering any advanced collation rules.

Syntax

fn:codepoint-equal(comparand1, comparand2)
The following table describes the argument for this command:
Argument
Required/Optional
Description
comparand1
Required
The first string to compare. It can be an actual string or an empty sequence (()).
comparand2
Required
The second string to compare. It can also be an actual string or an empty sequence (()).

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:codepoint-equal('abc', 'abc')
true
fn:codepoint-equal('abc', 'ab c')
false
fn:codepoint-equal('abc', ())
()
fn:codepoint-equal((), ())
()
fn:codepoint-equal("hello", "world")
false
fn:codepoint-equal("hello", "")
false

codepoints-to-string

The codepoints-to-string function in XQuery is used to construct a string from a sequence of Unicode code points. This function takes numeric representations of characters and converts them into a string.

Syntax

fn:codepoints-to-string(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
A sequence of integers representing Unicode code points. Each integer corresponds to a Unicode code point that is converted into the respective character in the resulting string.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:codepoints-to-string((97, 32, 98, 32, 99))
a b c
fn:codepoints-to-string(97)
a
fn:codepoints-to-string(())
zero-length string
fn:codepoints-to-string((72, 101, 108, 108, 111))
"Hello"
fn:codepoints-to-string((87, 111, 114, 108, 100, 32, 88, 81, 117, 101, 114, 121))
"World XQuery"

compare

The compare function in XQuery is used to compare two strings using a specified collation. This function can help determine the order of strings, for example, sorting based on a defined collation.

Syntax

fn:compare(comparand1, comparand2, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
comparand1
Required
The first string to be compared. This can be a valid string or empty-sequence().
comparand2
Required
The second string to be compared. This can also be a valid string or empty-sequence().
collation
Optional
A string that specifies the collation URI to be used for the comparison. If omitted, the default collation is used. The collation affects how string comparison is done, taking locale-specific rules into account.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:compare('a', 'b')
-1
fn:compare('a', 'a')
0
fn:compare('b', 'a')
1
fn:compare('ab', 'abc')
-1
fn:compare('a', 'B')
1
This shows that when using the simple code point collation, a lowercase a comes after an uppercase B.
fn:compare(upper-case('a'), upper-case('B'))
-1
fn:compare('a', ())
()
fn:compare('a', 'b', 'FOO')
Error FOCH0002
fn:compare((), ())
()

concat

The concat function in XQuery is used to concatenate two or more strings into a single string. This function allows you to effectively combine multiple string values into one continuous string.

Syntax

fn:concat(arg1, arg2)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
The first value to concatenate.
arg2
Required
The second value to concatenate.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:concat('a')
Error XPST0017
fn:concat('a', 'b')
ab
fn:concat('a', 'b', 'c')
abc
fn:concat('a', (), 'b', '', 'c')
abc
fn:concat( ('a', 'b', 'c') )
Error XPST0017
fn:concat('a', <x>b</x>, 'c')
abc
fn:concat("Hello, ", "World", "!")
"Hello, World!"
fn:concat("Result: ", 42)
"Result: 42"
fn:concat("Start-", (), "End")
"Start-End"

contains

The contains function in XQuery is used to determine whether one string contains another substring. This function determines if the main string contains at least one occurrence of the specified substring. It evaluates to a boolean value indicating the presence or absence of a substring within a larger string.

Syntax

fn:contains(arg1, arg2, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
The main string to check for the presence of another substring. If it is empty-sequence(), it is treated as an empty string.
arg2
Required
The substring to find within $arg1. This is the substring you are searching for. If it is empty-sequence(), it is treated as an empty string.
collation
Optional
A URI that specifies the collation to be used when comparing strings. Collations define locale-specific rules for string comparison. If omitted, the default collation is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:contains('query', 'e')
true
fn:contains('query', 'ery')
true
fn:contains('query', 'query')
true
fn:contains("Hello", "hel")
false
fn:contains('query', 'x')
false
fn:contains('query', '')
true
fn:contains('query', ())
true
fn:contains( (), 'q')
false

Additional Notes

default-collation

The concept of default-collation is not a direct function in XQuery but rather a setting or property that can affect XQuery expressions, particularly those dealing with collation-sensitive operations such as string comparisons. XQuery relies on this default collation to perform operations, such as sorting and comparing strings when a specific collation is not provided.

Syntax

fn:default-collation()

Return Value

Returns the default collation that is used in most operations where a collation is not explicitly specified. If no default collation is specified in the query prolog, the function returns the system default collation. If no system default collation is defined, the function returns a value representing the Unicode code point collation.

Example

The following expression represents the sample value and return value:
fn:default-collation()
It returns,
http://www.w3.org/2005/
xpath-functions/collation/codepoint
For example, if that is the name of the default collation.

ends-with

The ends-with function in XQuery is used to determine whether a string ends with a specified substring. It is a useful function for string manipulation and validation tasks.

Syntax

fn:ends-with(arg1, arg2, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
The main string to be checked. This is the string you want to analyze to see if it ends with $arg2. If it is an empty-sequence(), it is treated as an empty string.
arg2
Required
The substring to compare against the end of $arg1. If it is an empty-sequence(), it is treated as an empty string.
collation
A URI that specifies the collation to be used when comparing strings. Collations define locale-specific rules for comparing characters. The default collation is used if this parameter is omitted.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:ends-with('query', 'y')
true
fn:ends-with('query', 'query')
true
fn:ends-with('query', '')
true
fn:ends-with('query ', 'y')
false
fn:ends-with('', 'y')
false
fn:ends-with("Hello, World!", "World!")
true
fn:ends-with("Hello, World!", "Hello")
false
fn:ends-with("Frère Jacques", "Jacques", "http://example.com/collation")
Assume "http://example.com/collation" supports specific comparison rules. The output would depend on whether the specified collation affects the treatment of accents or other features, possibly returning true.

lang

The lang function in XQuery is used to determine whether a node's language attribute matches a specified language. This function is particularly useful for querying XML documents that use language attributes to manage multilingual content.

Syntax

fn:lang(testlang, node)
The following table describes the argument for this command:
Argument
Required/Optional
Description
testlang
Required
The language tag to test against the xml:lang attribute of the node. It typically follows language tagging conventions, such as "en", "fr", and "en-US". This parameter must be provided as a string.
node
Required
The context node whose language attribute is to be tested. If omitted, the context item from which the function is called is used by default.

Return Value

Examples

The following table lists some sample XML structures, queries, and return values:
XML STRUCTURE
QUERY
OUTPUT
<book xml:lang="en">
<title>Hello World</title>
</book>
fn:lang("en", /book/title)
true
<book xml:lang="fr">
<title>Bonjour le Monde</title>
</book
fn:lang("en", /book/title)
false
<article xml:lang="en-US">
<section>
<para>This is a paragraph.</para>
</section>
</article>
fn:lang("en-US")
true
<document>
<content>Some text here.</content>
</document>
fn:lang("en", /document/content)
false

lower-case

The lower-case function in XQuery is used to convert all the characters in a string to lowercase. This function is useful for tasks where case-insensitivity is required, such as searching, sorting, or normalizing textual data.

Syntax

fn:lower-case(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The string to be converted to lowercase. If the argument is an empty sequence (()), it is treated as an empty string.

Return Value

Returns a string where all the alphabetic characters in the input string have been converted to lowercase. Characters that are not alphabetic, such as numbers and punctuation remain unchanged.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:lower-case('QUERY')
query
fn:lower-case('Query')
query
fn:lower-case('query')
query
fn:lower-case('QUERY123')
query123
fn:lower-case("Hello World!")
"hello world!"
fn:lower-case("")
""
fn:lower-case("1234!@#$")
"1234!@#$"

matches

The matches function in XQuery is used to determine whether a string matches a given regular expression pattern. This function is essential for pattern matching and text validation tasks.

Syntax

fn:matches(input, pattern, flags)
The following table describes the argument for this command:
Argument
Required/Optional
Description
input
Required
The input string to be tested against the pattern. If this argument is an empty sequence (()), it is treated as an empty string.
pattern
Required
A regular expression pattern against which the input string is matched. The pattern should be a valid regular expression according to the XML Schema definition.
flags
Optional
A string of flags that modify the matching behavior as follows:
  • - m: Multi-line mode, where the start and end of line anchors (^ and $) match the start and end of any line instead of the entire string.
  • - s: Single-line mode, where the dot (.) matches all characters, including line terminators.
  • - i: Case-insensitive matching.

Return Value

Returns true if $input matches the regular expression supplied as $pattern as influenced by the value of $flags, if present. Otherwise, returns false .

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:matches('query', 'q')
true
fn:matches('query', 'ue')
true
fn:matches('query', '^qu')
true
fn:matches('query', 'qu$')
false
fn:matches('query', 'q.*')
true
fn:matches('query', '[a-z]{5}')
true
fn:matches((), 'q' )
false
fn:matches('query', '[qu')
Error FORX0002
fn:matches("Hello World", "World")
true
fn:matches("Hello World", "^World")
false
fn:matches("Hello World", "hello", "i")
true
fn:matches((), "^$")
true

normalize-space

The normalize-space function in XQuery removes leading and trailing whitespace from a string and replaces sequences of whitespace characters within the string with a single space. This function is useful for cleaning up and formatting text data.

Syntax

fn:normalize-space(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The input string whose spaces need to be normalized. If this argument is omitted, the function operates on the context item typically the current node or string in the query. If the argument is an empty sequence (()), it is treated as an empty string.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:normalize-space('query')
query
fn:normalize-space(' query ')
query
fn:normalize-space('xml query')
xml query
fn:normalize-space('xml query')
xml query
fn:normalize-space('xml
query')
xml query
fn:normalize-space('')
zero-length string
fn:normalize-space(' ')
zero-length string
fn:normalize-space(())
zero-length string
fn:normalize-space(
<element> query </element>)
query
fn:normalize-space("CleanString")
CleanString
fn:normalize-space("Line1\n\tLine2\t Line3")
Line1\\n\\tLine2\\t Line3

normalize-unicode

The normalize-unicode function in XQuery performs Unicode normalization, that allows text to be compared without regard to subtle variations in character representation. It replaces certain characters with equivalent representations. Two normalized values can then be compared to determine whether they are the same. Unicode normalization is also useful for allowing character strings to be sorted appropriately.
The $normalizationForm argument controls which normalization form is used, and hence which characters are replaced.

Syntax

fn:normalize-unicode(arg, normalizationForm)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The input string to be normalized. If this argument is an empty sequence (()), it is treated as an empty string.
normalizationForm
Optional
The Unicode normalization form to apply. According to the Unicode Standard, the allowed forms are:
  • - "NFC": Canonical Composition
  • - "NFD": Canonical Decomposition
  • - "NFKC": Compatibility Composition
  • - "NFKD": Compatibility Decomposition
If omitted, "NFC" is the default form used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:normalize-unicode('query')
query
fn:normalize-unicode('query', '')
query
fn:normalize-unicode('£', 'NFKC')
£
Converts &#xFFE1; to &#xA3;.
fn:normalize-unicode('leçon', 'NFKD')
leçon
Converts le&#231;on to lec&#807;on. There are two characters in the output, a "c" and a separate cedilla, but it might not be visible separately in your browser.
fn:normalize-unicode('15 ㎗')
15 ㎗
fn:normalize-unicode('15 ㎗', 'NFKC')
15 dl
Converts &#x3397; to the letters 'dl'.

replace

The replace function in XQuery is used to replace parts of a string that match a specified regular expression with a replacement string. This function is highly useful for string manipulation tasks such as text sanitation, formatting, and transformation.

Syntax

fn:replace(input, pattern, replacement, flags)
The following table describes the argument for this command:
Argument
Required/Optional
Description
input
Required
The input string to be processed. If this argument is an empty sequence (()), it is treated as an empty string.
pattern
Required
A regular expression pattern that specifies what part of the input string to replace. The pattern must be a valid regular expression.
replacement
Required
The string that will replace each substring of the input string that matches the regular expression pattern. Special replacement strings, such as $1, can be used to refer to captured groups within the pattern.
flags
A string of flags that modify the behavior of the regular expression as follows:
  • - s: Single-line mode, where the dot (.) matches all characters, including newline.
  • - m: Multi-line mode, where start ^ and end $ anchors match the start and end of any line.
  • - i: Case-insensitive mode.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:replace('query', 'r', 'as')
queasy
fn:replace('query', 'qu', 'quack')
quackery
fn:replace('query', '[ry]', 'l')
quell
fn:replace('query', '[ry]+', 'l')
quel
fn:replace('query', 'z', 'a')
query
fn:replace('query', 'query', '')
zero-length string
fn:replace( (), 'r', 'as')
zero-length string
fn:replace('query', 'r?', 'as')
Error FORX0003
fn:replace('query', '(r', 'as')
Error FORX0002
fn:replace('Chapter', '(Chap)|(Chapter)', 'x')
xter
The following examples show the difference between reluctant and regular quantifiers:
SAMPLE FUNCTION
OUTPUT
fn:replace('reluctant', 'r.*t', 'X')
X
fn:replace('reluctant', 'r.*?t', 'X')
Xant
fn:replace('aaah', 'a{2,3}', 'X')
Xh
fn:replace('aaah', 'a{2,3}?', 'X')
Xah
fn:replace('aaaah', 'a{2,3}', 'X')
Xah
fn:replace('aaaah', 'a{2,3}?', 'X')
XXh
The following examples exhibit the use of sub-expressions:
SAMPLE FUNCTION
OUTPUT
fn:replace('Chap 2...Chap 3...Chap 4...',
'Chap (\d)', 'Sec $1.0')
Sec 2.0...Sec 3.0...Sec 4.0...
fn:replace('abc123', '([a-z])', '$1x')
axbxcx123
fn:replace('2315551212',
'(\d{3})(\d{3})(\d{4})', '($1) $2-$3')
(231) 555-1212
fn:replace('2006-10-18',
'\d{2}(\d{2})-(\d{2})-(\d{2})',
'$2/$3/$1')
10/18/06
fn:replace('25', '(\d+)', '\$$1.00')
$25.00

starts-with

The starts-with function in XQuery is used to determine whether a string begins with a specified substring. This function is particularly useful for string validation and prefix matching tasks.

Syntax

fn:starts-with(arg1, arg2, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
The main string to be checked. This is the string you want to determine if it starts with $arg2. If it is an empty sequence (()), it is treated as an empty string.
arg2
Required
The substring to check for at the start of $arg1. If this argument is an empty sequence, it is treated as an empty string.
collation
Optional
A URI that specifies the collation to be used for string comparison. Collations are sets of rules for comparing characters in strings. If this parameter is omitted, the default collation is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:starts-with('query', 'que')
true
fn:starts-with('query', 'query')
true
fn:starts-with('query', 'u')
false
fn:starts-with('query', '')
true
fn:starts-with('', 'query')
false
fn:starts-with('', '')
true
fn:starts-with('query', ())
true
fn:starts-with(' query', 'q')
false
fn:starts-with("Query", "que")
false

string-join

The string-join function in XQuery is used to concatenate a sequence of strings into a single string, with a specified separator between each. This function is particularly useful for combining strings into a formatted output.

Syntax

fn:string-join(arg1, arg2)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
A sequence of strings to be joined. Each item in the sequence is joined together in the order they appear. If the sequence is empty, the function returns an empty string.
arg2
Required
The string to insert between adjacent items in the sequence. This separator is appended between each pair of strings in the sequence.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:string-join( ('a', 'b', 'c'), '')
abc
fn:string-join( ('a', 'b', 'c'), '/*')
a/*b/*c
fn:string-join( ('a', '', 'c'), '/*')
a/*/*c
fn:string-join( 'a', '/*')
a
fn:string-join((), '/*')
zero-length string
fn:string-join(("Line1", "Line2", "Line3"), "\n")
"Line1
Line2
Line3"

string-length

The string-length function in XQuery is used to determine the number of characters in a given string including the leading and trailing whitespace characters. It is particularly useful for tasks that require string validation or manipulation, where the size of the string is relevant.

Syntax

fn:string-length(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The input string whose length you want to determine. If the argument is omitted, the function defaults to using the context item; if the context item is not a string, a type error is raised. If the argument is an empty sequence (()), it is treated as an empty string.

Return Value

Returns an integer equal to the length in characters of the value of $arg. For an empty string or empty sequence, it returns 0.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:string-length('query')
5
fn:string-length(' query ')
9
fn:string-length(normalize-space(' query '))
5
fn:string-length('xml query')
9
fn:string-length('')
0
fn:string-length(())
0
fn:string-length("Hello, World!")
13
fn:string-length(" \t")
4

string-to-codepoints

The string-to-codepoints function in XQuery is used to convert a string into a sequence of Unicode codepoints. This function provides a way to analyze and manipulate the individual characters embedded within a string at their fundamental encoding level.

Syntax

fn:string-to-codepoints(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The input string to be converted into Unicode codepoints. If the argument is an empty sequence (()), it is treated as an empty string.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:string-to-codepoints('abc')
(97, 98, 99)
fn:string-to-codepoints('a')
97
fn:string-to-codepoints('')
()
fn:string-to-codepoints("Hello World")
(72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100)

substring

The substring function in XQuery extracts a portion of a string based on specified start and optional length parameters. It is useful for string manipulation tasks where specific parts of a string need to be isolated and processed.

Syntax

fn:substring(sourceString, startingLoc, length)
The following table describes the argument for this command:
Argument
Required/Optional
Description
sourceString
Required
The string from which the substring will be extracted. If the argument is an empty sequence (()), it is treated as an empty string.
startingLoc
Required
The position within the source string where the substring begins. Position indexing starts at 1. If this number is less than 1, the start is considered from the first character.
length
Optional
The number of characters to include in the substring. If omitted, the substring extends to the end of the source string.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:substring('query', 1)
query
fn:substring('query', 3)
ery
fn:substring('query', 1, 1)
q
fn:substring('query', 2, 3)
uer
fn:substring('query', 2, 850)
uery
fn:substring('query', 6, 2)
zero-length string
fn:substring('query', -2)
query
fn:substring('query', -2, 5)
qu
fn:substring('query', 1, 0)
zero-length string
fn:substring('', 1)
zero-length string
fn:substring((), 1)
zero-length string
fn:substring("Example", 0)
"Example"
fn:substring("Short", 10)
""

substring-after

The substring-after function in XQuery returns the part of a string that follows a specified substring. It is useful for extracting text that appears after a certain character or sequence in a given string.

Syntax

fn:substring-after(arg1, arg2, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
The input string from which the substring will be extracted. If the argument is an empty sequence (()), it is treated as an empty string.
arg2
Required
The substring to search for within $arg1. The function returns the portion of $arg1 that follows the first occurrence of $arg2. If $arg2 is an empty sequence, it is treated as an empty string.
collation
Required
The collation to use to compare strings

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:substring-after('query', 'u')
ery
fn:substring-after('queryquery', 'ue')
ryquery
fn:substring-after('query', 'y')
zero-length string
fn:substring-after('query', 'x')
zero-length string
fn:substring-after('query', '')
query
fn:substring-after('', 'x')
zero-length string
fn:substring-after("Hello, World!", ", ")
"World!"

substring-before

The substring-before function in XQuery returns the part of a string that appears before a specified substring. This function is useful for extracting text that precedes a certain character or sequence in a given string.

Syntax

fn:substring-before(arg1, arg2, collation)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg1
Required
The input string from which the substring will be extracted. If this argument is an empty sequence (()), it is treated as an empty string.
arg2
Required
The substring to search for within $arg1. The function returns the portion of $arg1 that occurs before the first occurrence of $arg2. If $arg2 is an empty sequence, it is treated as an empty string.
collation
Required
The collation to use to compare strings

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:substring-before('query', 'r')
que
fn:substring-before('query', 'ery')
qu
fn:substring-before('queryquery', 'ery')
qu
fn:substring-before('query', 'query')
zero-length string
fn:substring-before('query', 'x')
zero-length string
fn:substring-before('query', '')
zero-length string
fn:substring-before('query', ())
zero-length string
fn:substring-before("Hello, World!", ", ")
"Hello"
fn:substring-before("repeat", "repeat")
""
fn:substring-before("XQuery", "SQL")
""

tokenize

The tokenize function in XQuery is used to split a string into a sequence of substrings based on a specified regular expression pattern that serves as a delimiter. This function is particularly useful for parsing and separating components of a string for further processing.

Syntax

fn:tokenize(input, pattern, flags)
The following table describes the argument for this command:
Argument
Required/Optional
Description
input
Required
The input string to be tokenized. If this argument is an empty sequence (()), it is treated as an empty string.
pattern
Required
A regular expression pattern that specifies the delimiter by which the input string will be split. The pattern should be a valid regular expression according to the XML Schema definition.
flags
Optional
A string of flags that modify the behavior of the regular expression as follows:
  • - s: Single-line mode, where the dot (.) matches all characters, including newline.
  • - m: Multi-line mode, where start ^ and end $ anchors match the start and end of any line.
  • - i: Case-insensitive mode.

Return Value

Returns a sequence of strings obtained by partitioning the $input string at delimiters specified by the $pattern. If the input string is empty or the pattern does not find any matches, an empty sequence or the entire input string is returned as appropriate.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:tokenize(
'a b c', '\s')
('a', 'b', 'c')
fn:tokenize(
'a b c', '\s')
('a', '', '', 'b', 'c')
fn:tokenize(
'a b c', '\s+')
('a', 'b', 'c')
fn:tokenize(
' b c', '\s')
('', 'b', 'c')
fn:tokenize(
'a,b,c', ',')
('a', 'b', 'c')
fn:tokenize(
'a,b,,c', ',')
('a', 'b', '', 'c')
fn:tokenize(
'a, b, c', '[,\s]+')
('a', 'b', 'c')
fn:tokenize(
'2006-12-25T12:15:00', '[\-T:]')
('2006', '12', '25',
'12', '15', '00')
fn:tokenize(
'Hello, there.', '\W+')
('Hello', 'there', '')
fn:tokenize(
(), '\s+')
()
fn:tokenize(
'abc', '\s')
abc
fn:tokenize(
'abcd', 'b?')
Error FORX0003
fn:tokenize(
'a,xb,xc', ',|,x')
('a', 'xb', 'xc')
fn:tokenize("", ",")
()

translate

The translate function in XQuery is used to replace characters in a string based on a specified mapping from source characters to target characters. This function is useful for simple character substitutions and deletions within strings.

Syntax

fn:translate(arg, mapString, transString)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The input string in which character replacements are to be made. If this argument is an empty sequence (()), it is treated as an empty string.
mapString
Required
A string containing characters to be replaced. Each character in mapString is mapped to the corresponding character in transString.
transString
Required
A string containing replacement characters. Each character in mapString is replaced by the character at the corresponding position in transString. If transString is shorter than mapString, characters with no corresponding replacement are removed from the input.

Return Value

Returns a string where each character in the input $src is replaced according to the mappings defined by $mapString and $transString. Characters in $src that are not in $mapString remain unchanged. If replacements result in removal, those characters are removed.

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:translate('1999/01/02', '/', '-')
1999-01-02
fn:translate('xml query', 'qlmx', 'QLMX')
XML Query
fn:translate('xml query', 'qlmx ', 'Q')
Query
fn:translate('xml query', 'qlmx ', '')
uery
fn:translate('xml query', 'abcd', 'ABCD')
xml query
fn:translate('', 'qlmx ', 'Q')
zero-length string
fn:translate((), 'qlmx ', 'Q')
zero-length string
fn:translate("hello world", "hod", "jrx")
"jellr wxrlr"
fn:translate("12345", "9", "0")
"12345"

upper-case

The upper-case function in XQuery converts all the characters in a given string to their uppercase equivalents according to the Unicode standard. This function is helpful for normalizing text for comparison or display purposes.

Syntax

fn:upper-case(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The input string whose characters are to be converted to uppercase. If this argument is an empty sequence (()), it is treated as an empty string.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:upper-case('query')
QUERY
fn:upper-case('QUERY')
QUERY
fn:upper-case('Query')
QUERY
fn:upper-case('query-123')
QUERY-123
fn:upper-case("123abc!@#")
"123ABC!@#"
fn:upper-case("")
""

XML Documents, URIs and IDs

The following functions are available in the XML Documents, URIs and IDs section of the Expression Editor:

base-uri

The base-uri function in XQuery returns the base URI of the given node. The base URI is typically the URI against which relative URIs in the document should be resolved.

Syntax

fn:base-uri(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The node for which to retrieve the base URI. If omitted or empty, the context item is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:base-uri() (when context item is a node with base URI)
"http://example.com/doc.xml"
fn:base-uri(/root)
"http://example.com/doc.xml"
fn:base-uri(())
()
fn:base-uri() (with no context item)
Error

Additional information

collection

The collection function in XQuery returns a sequence of nodes from a collection identified by a URI. It is used to access sets of XML documents or items stored in a collection, typically in an XQuery or XML database environment.

Syntax

fn:collection(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The URI identifying the collection to retrieve. If omitted or empty, the default collection for the static context is returned.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:collection("http://example.com/myCollection")
Sequence of nodes from the collection
fn:collection()
Sequence of nodes from default collection
fn:collection("")
Empty sequence
fn:collection("nonexistent")
Empty sequence

Additional information

doc

The doc function in XQuery retrieves a single XML document node identified by a URI. It is commonly used to load an XML document from a given URI into an XQuery expression for querying.

Syntax

fn:doc(uri)
The following table describes the argument for this command:
Argument
Required/Optional
Description
uri
Required
The URI identifying the XML document to retrieve.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:doc("http://example.com/sample.xml")
Document node of the specified XML
fn:doc("")
Empty sequence
fn:doc("nonexistent.xml")
Empty sequence

Additional information

doc-available

The doc-available function in XQuery checks whether a document identified by the given URI is available and can be retrieved without error.

Syntax

fn:doc-available(uri)
The following table describes the argument for this command:
Argument
Required/Optional
Description
uri
Required
The URI identifying the XML document to check.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:doc-available("http://example.com/sample.xml")
true
fn:doc-available("nonexistent.xml")
false
fn:doc-available("")
false

Additional information

document-uri

The document-uri function in XQuery returns the document URI associated with a given document node. It helps identify the URI of the document from which the node originates.

Syntax

fn:document-uri(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
The document node whose document URI is to be retrieved.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:document-uri(fn:doc("http://example.com/sample.xml"))
"http://example.com/sample.xml"
fn:document-uri(())
()
fn:document-uri(<root/>)
()

Additional information

encode-for-uri

The encode-for-uri function in XQuery returns a string where characters in the input string that are not allowed in a URI component are percent-encoded according to RFC 3986. It is similar to URL encoding but tailored for URI components.

Syntax

fn:encode-for-uri(uri-part)
The following table describes the argument for this command:
Argument
Required/Optional
Description
uri-part
Required
The string to be encoded for use as a URI component.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:encode-for-uri("a b+c/d")
"a%20b%2Bc%2Fd"
fn:encode-for-uri("name@example.com")
"name%40example.com"
fn:encode-for-uri("")
""

Additional information

escape-html-uri

The escape-html-uri function in XQuery returns a string that is safe to use within HTML URIs by escaping characters that have a special meaning in HTML, such as &, <, >, ", and ' with corresponding percent-encodings. This ensures the URI can be safely embedded in HTML attributes without breaking the markup.

Syntax

fn:escape-html-uri(uri)
The following table describes the argument for this command:
Argument
Required/Optional
Description
uri
Required
The URI string to be escaped for HTML usage.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:escape-html-uri("foo<>\")
"foo%3C%3E%22"
fn:escape-html-uri("")
""

Additional information

id

The id function in XQuery returns a sequence of element nodes with unique IDs matching the specified ID value(s). It retrieves elements based on the values of their ID attributes, commonly used for referencing elements defined with xml:id or DTD ID attributes.

Syntax

fn:id(arg, node)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
One or more ID values (space-separated tokens) to locate matching elements.
node
Optional
The node that provides the context for resolving the IDs. Defaults to the root node of the context item if omitted.

Return Value

Additional information

idref

The idref function in XQuery returns the sequence of element or attribute nodes with an IDREF value matching the value of one or more of the ID values supplied in $arg .

Syntax

fn:idref(arg, node)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Required
One or more IDREF values (space-separated tokens) to find referencing elements.
node
Optional
The node that provides context for resolving IDREFs. Defaults to root node of the context item if omitted.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:idref("item1", /root)
Elements that refer to the ID "item1" under /root.
fn:idref(("item1", "item2"))
Sequence of elements referring to "item1" or "item2".
fn:idref("nonexistent")
()
fn:idref("item1") (with context node omitted)
Elements referring to "item1" relative to context root node.

Additional information

iri-to-uri

The iri-to-uri function in XQuery converts an Internationalized Resource Identifier (IRI) to a Uniform Resource Identifier (URI) by escaping characters that are not allowed in URIs according to RFC 3986. This process includes percent-encoding characters outside the ASCII range and certain reserved characters.

Syntax

fn:iri-to-uri(iri)
The following table describes the argument for this command:
Argument
Required/Optional
Description
iri
Required
The IRI string to be converted to a URI.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:iri-to-uri("http://example.com/ümlaut")
"http://example.com/%C3%BCmlaut"
fn:iri-to-uri("https://example.com/space here")
"https://example.com/space%20here"
fn:iri-to-uri("foo://bar.com/παράδειγμα")
"foo://bar.com/%CF%80%CE%B1%CF%81%CE%AC%CE%B4%CE%B5%CE%B9%CE%B3%CE%BC%CE%B1"

Additional information

resolve-uri

The resolve-uri function in XQuery resolves a given relative URI against a base URI, producing an absolute URI. If the first argument is already an absolute URI, it returns it directly. It is useful for combining relative paths with base locations.

Syntax

fn:resolve-uri(relative, base)
The following table describes the argument for this command:
Argument
Required/Optional
Description
relative
Required
The relative URI to be resolved. If absolute, it is returned unchanged.
base
Optional
The base URI against which to resolve the relative URI. If omitted, the base URI of the static context or empty sequence is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:resolve-uri("page.html", "http://example.com/folder/")
"http://example.com/folder/page.html"
fn:resolve-uri("", "http://example.com")
()
fn:resolve-uri("../image.png", "http://example.com/folder/page.html")
"http://example.com/image.png"

Additional information

static-base-uri

The static-base-uri function in XQuery returns the static base URI of the query or module in which it is called. This is the base URI that was statically assigned, often the location of the query file or module, and is used as the default base for resolving relative URIs in the query.

Syntax

fn:static-base-uri()

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:static-base-uri()
"http://example.com/queries/myquery.xq"
fn:static-base-uri() (in an environment without static base URI)
()

Additional information

XML Namespaces and Names

The following functions are available in the XML Namespaces and Names section of the Expression Editor:

QName

The QName function in XQuery constructs a QName (Qualified Name) from a namespace URI and a local part (local name). It is used to create a QName value dynamically in XQuery.

Syntax

fn:QName(paramURI, paramQName)
The following table describes the argument for this command:
Argument
Required/Optional
Description
paramURI
Optional
The namespace URI part of the QName. It can be empty or "" if no namespace is desired.
paramQName
Required
The local part or the local name of the QName. It must be a valid non-colonized name (NCName).

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:QName("http://example.com/ns", "name")
QName("{http://example.com/ns}name")
fn:QName("", "name")
QName("name")
fn:QName((), "name")
QName("name")
fn:QName("http://example.com/ns", "1invalid")
Error

Additional information

in-scope-prefixes

The in-scope-prefixes function returns the sequence of namespace prefixes that are in scope for a given element node. This helps identify what namespace prefixes can be used for that element and its sub-elements.

Syntax

fn:in-scope-prefixes(element)
The following table describes the argument for this command:
Argument
Required/Optional
Description
element
Required
The element node whose in-scope prefixes are to be returned.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:in-scope-prefixes(<a xmlns="http://ns1" xmlns:x="http://ns2"/>)
("", "x")
fn:in-scope-prefixes(())
Validation error. Empty sequence is not allowed as first argument to in-scope-prefixes function.

Additional information

local-name

The local-name function in XQuery returns the local part (local name) of the expanded QName of the node provided as input. This excludes the namespace prefix and namespace URI.

Syntax

fn:local-name(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The node from which to extract the local name. If omitted or empty, the context item is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:local-name(<a:book xmlns:a="http://example.com"/> )
"book"
fn:local-name(text{"Hello"})
""
fn:local-name(())
""
fn:local-name() (with context node <ex:item> in scope)
"item"

Additional information

local-name-from-QName

The local-name-from-QName function in XQuery returns the local part of a QName value. It extracts only the local name without namespace prefix or URI from the given xs:QName.

Syntax

fn:local-name-from-QName(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The QName from which to extract the local name. If empty or omitted, returns an empty sequence.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:local-name-from-QName(QName("", "bar"))
"bar"
fn:local-name-from-QName(())
()

Additional information

name

The name function in XQuery returns the QName value of the node as a string, representing the element or attribute name including its prefix, if any. It returns the string-form of the node's name.

Syntax

fn:name(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The node whose name is to be returned. If omitted, the context item is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:name(<a:book xmlns:a="http://example.com"/> )
"a:book"
fn:name(text{"Hello"})
""
fn:name(())
""
fn:name() (with context node <ex:item> in scope)
"ex:item"

Additional information

namespace-uri

The namespace-uri function in XQuery returns the namespace URI of the expanded QName of the provided node. It helps retrieve the namespace part associated with elements or attributes.

Syntax

fn:namespace-uri(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The node whose namespace URI is to be retrieved. If omitted, the context item is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:namespace-uri(<a:book xmlns:a="http://example.com"/>)
"http://example.com"
fn:namespace-uri(document{<root/>})
""
fn:namespace-uri(text{"Hello"})
""
fn:namespace-uri(())
""

Additional information

namespace-uri-for-prefix

The namespace-uri-for-prefix function in XQuery returns the namespace URI that is bound to a specific prefix in the context of a given element node. This is useful for determining what namespace a prefix corresponds to when processing XML.

Syntax

fn:namespace-uri-for-prefix(prefix, element)
The following table describes the argument for this command:
Argument
Required/Optional
Description
prefix
Required
The namespace prefix to be resolved. Use "" (empty string) for default namespace.
element
Optional
The element node whose namespace context is used for resolving the prefix. If omitted, the static context is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:namespace-uri-for-prefix("ex", <a xmlns:ex="http://example.com"/> )
"http://example.com"
fn:namespace-uri-for-prefix("", <a xmlns="http://default.com"/> )
"http://default.com"
fn:namespace-uri-for-prefix("unknown", <a/>)
()
fn:namespace-uri-for-prefix("a") (with context item <a xmlns:a="http://a.com"/>)
"http://a.com"

Additional information

namespace-uri-from-QName

The namespace-uri-from-QName function in XQuery returns the namespace URI part of a given QName value. This allows extracting the namespace URI component from an xs:QName.

Syntax

fn:namespace-uri-from-QName(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The QName from which to extract the namespace URI. Returns empty sequence if $arg is empty or omitted.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:namespace-uri-from-QName(QName("", "bar"))
"" (empty string)
fn:namespace-uri-from-QName(())
()

Additional information

node-name

The node-name function in XQuery returns the QName of the node, which includes the namespace prefix and local name as an xs:QName value. It is used to obtain the qualified name of element or attribute nodes.

Syntax

fn:node-name(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The node whose QName is returned. If omitted, the context item is used.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:node-name(<a:book xmlns:a="http://example.com"/>)
QName("{http://example.com}book")
fn:node-name(text{"Hello"})
()
fn:node-name(())
()
fn:node-name() (with context node <ex:item/>)
QName corresponding to context node

Additional information

prefix-from-QName

The prefix-from-QName function in XQuery returns the namespace prefix part of a given QName value. If the QName has no prefix, the function returns an empty sequence.

Syntax

fn:prefix-from-QName(arg)
The following table describes the argument for this command:
Argument
Required/Optional
Description
arg
Optional
The QName from which to extract the prefix. Returns empty sequence if input is empty or omitted.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:prefix-from-QName(QName("", "bar"))
()
fn:prefix-from-QName(())
()

Additional information

resolve-QName

The resolve-QName function in XQuery takes a QName string and resolves it to an xs:QName value using the in-scope namespaces of a supplied element node. It essentially maps a QName in string form to an actual QName based on the element's namespace context.

Syntax

fn:resolve-QName(qname, element)
The following table describes the argument for this command:
Argument
Required/Optional
Description
qname
Required
A string representing the QName to be resolved, which might include a prefix. For example, "ex:tag".
element
Required
The element node providing the namespace context for resolving prefixes in the QName string.

Return Value

Examples

The following table lists some sample values and return values:
SAMPLE FUNCTION
OUTPUT
fn:resolve-QName("ex:foo", <a xmlns:ex="http://example.com"/>)
QName("{http://example.com}foo")
fn:resolve-QName("bar", <a xmlns="http://default.com"/> )
QName("{http://default.com}bar")
fn:resolve-QName("ns:tag", <a/>)
Error

Additional information

XML Nodes functions

The following XML functions are available in the XML Nodes section of the Expression Editor:

data

The atomic value of a node.
The fn:data function takes a sequence of items and returns a sequence of atomic values.

Syntax

fn:data(arg)
The following table describes the argument:
Argument
Required/
Optional
Description
arg
Required
The items whose typed values are to be returned.

Return Value

For atomic values, it returns the unchanged value. For nodes, it extracts the typed value of the node.

Example

The following expression returns 123, 456 as the result:
fn:data((123, 456))
Assume that you have the following variable definition:
let $x := <hello>Hello
let $x := <hello>Hello
<world>World</world>
</hello>
The expression fn:data($x) returns the following result:
Hello World

deep-equal

Assesses whether two nodes have the same content and attributes.
To be deep-equal, they must contain items that are pairwise deep-equal; and for two items to be deep-equal, they must either be atomic values that compare equal, or nodes of the same kind, with the same name, whose children are deep-equal. The $collation argument identifies a collation which is used at all levels of recursion when strings are compared, but not when names are compared.

Syntax

fn:deep-equal(parameter1, parameter2, collation)
The following table describes the arguments:
Argument
Required/
Optional
Description
parameter1
Required
The first sequence to compare.
parameter2
Required
The second sequence to compare.
collation
Optional
The collation to use for comparing strings. The collation argument identifies the collation to be used at all levels of recursion when strings are compared, but not when names are compared.

Return Value

Returns true if both the $parameter1 and $parameter2 sequences contain the same values, in the same order.
Atomic values are compared based on their typed values, using the eq operator. If two atomic values cannot be compared, for example, if one is a number, and the other is a string, the function returns false rather than raising an error.

Examples

The following expression returns true as the result:
fn:deep-equal (1, 1)
The following expression returns false as the result:
fn:deep-equal ((1,2), (2,1))
The following expression returns false as the result:
fn:deep-equal (123, John)

root

Returns the root of the tree that contains the argument.

Syntax

fn:root(arg)
The following table describes the argument:
Argument
Required/
Optional
Description
arg
Required
The node whose root node will be returned.

Return Value

The fn:root function returns a document node if the $arg node is part of a document. However, it returns an element if the $arg node is not part of a document.
If $arg is the empty sequence, the empty sequence is returned.
If the function is called without an argument, the context item is used as the default argument. If the context item is undefined or is not a node, an error occurs.

Example

Assume that you have the following variable definition:
let $in-xml := <a><x>123</x></a>
The expression root($in-xml/x) returns the following result:
<a>
<x>123</x>
</a>

Specifying Functions and Variables

To configure service connectors, you may need to specify variables and functions to define bindings, output fields, and other properties.

Built-in Variables

You can reference these variables in a service connector using an XQuery expression:
Variable
Variable Type
Description
$VariableName
All connection properties
Properties, input and Other Parameters can be specified using this format.
$ResponseStatusCode
Output field mapping
HTTP response code.
$ResponseHeaders
Output field mapping
Contains the HTTP response header in an element list where each item is:
<header name="Content-Type">text/plain</header>
For example:
$ResponseHeaders[@name = "Content-Type"]/text()
$RESTResponse
Output field mapping
Contains the RESTResponse XML data, including the headers and code. Visible in the Test Results for the Service Connector.

Output Field Mapping Functions

When you define bindings in the service connector, you can use many functions in the Expression Editor.
For information on all the available functions, see Using Functions and Using the Expression Editor.
The following table describes functions available for service connector output field mappings:
Function
Syntax
Description
responseHeaderExists
svc:responseHeaderExists($ResponseHeaders, headerName ) : boolean
Returns a Boolean value that indicates if a header parameter exists within the response.
getResponseHeader
svc:getResponseHeader( $ResponseHeaders, headerName, defaultValue ) : string
svc:getResponseHeader( $ResponseHeaders, headerName ): string
Returns a response header value. If the header parameter is not defined, this function returns the optional default value.
getResponseHeaderNames
svc:getResponseHeaderNames( $ResponseHeaders ) : list of strings
Returns a list that contains the names of all the parameters within a response header.

Digital Signature Functions Overview

Using the digital signature functions available for Process Designer, you can use XQuery to create processes and service connectors that handle signing of content. The supported functions are either:
One common use for signed digital content is to allow for API authentication in a service connector, which allows you to use hashing and related functions on string-based content. For example, you might need to use signed headers as part of the payload
For more information on each of the functions, see Using Functions.
Note: There are currently no supported functions to verify signed content, or to sign binary content.

HMAC

The HMAC signing method is used with many services, including:
Process Designer supports HMAC SHA1, HMAC SHA256, and HMAC SHA512 with Base64, Hex, Hex64 or Base64Url encoding. For example, you might use one of these functions to sign content for AWS:

AWS Authentication

The AWS REST API requires the authentication header in this format:
Authorization: AWS AWSAccessKeyId:Signature
where:
Signature = dsig:hmacSHA1signature($strToSign, "AwsSecretKeyId")
The AWSAccessKey and AwsSecretKeyId are generated by AWS and accessible through the AWS Developer Console.
Note: $strToSign is combination of HTTP header values and other parameters.
For more information on REST authentication for AWS, see: http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html

Asymmetric Private Key-Based Signing

The following private key methods are supported:
Note: If using a private key to sign content, the keystore file must reside on a Secure Agent and the process or service connector must run on the Secure Agent in order to access the key. The file path to the key must be specified in the object properties (for example, "C:/certs/mykey.p12").
You can also:

PKCS8 Key File

To sign with the PKCS8 key file, use this function:
dsig:signWithKeyFile( $messageToSign as xs:string, $pathToKey as xs:string, $encryptionAlgorithm as xs:string, $digestAlgorithm as xs:string ) as xs:string
The key file can be binary or in Base64-encoded format.
P12 and Keystore Based Files
To sign with a P12 or KeyStore-based file, use this function:
dsig:signWithCertificate( $messageToSign as xs:string, $pathToCertificate as xs:string, $keyRecoveryPassword as xs:string, $encryptionAlgorithm as xs:string, $digestAlgorithm as xs:string ) as xs:string
For example, you can use this method for Google JWT (JSON Web Token) Authentication for service accounts. After you obtain a Google private key for access and save it on your Secure Agent, you create a JWT request and sign it with your private key.
For more information on JWT authentication, see: https://console.developers.google.com and https://developers.google.com/identity/protocols/OAuth2ServiceAccount.

hmacSHA256signatureForList

Calculates a hash-based message authentication code (HMAC) using the SHA256 algorithm and the optional encoding where $encoding is one of the following values: Base64 (default), Base64Url, Hex, or Hex64.

Syntax

dsig:hmacSHA256signatureForList(data, delimiter, secretKey, encoding, keyCharset)
The following table describes the arguments:
Argument
Required/
Optional
Description
data
Required
Plain text to compute hash.
delimiter
Required
A sequence of one or more characters based on which you want to split the string.
secretKey
Required
The secret key for HMAC computation. The key can be of any length. However, the recommended size is 64 bytes. If the key is more than 64 bytes long, it is hashed using SHA-256 to derive a 32-byte key.
encoding
Required
Type of encoding used for the output. For example, you can calculate HMAC using the SHA256 algorithm where encoding is one of the following values: Base64 (default), Base64Url, Hex, or Hex64.
keyCharset
Optional
An argument used to specify the character set of the secret key that you pass as an argument in the function. The keyCharset is set to UTF-8 by default.

Attachments

Process Designer exposes an endpoint so you can access attachments in a process using an event handler, internal API calls, custom service connectors or built-in connectors like the Amazon S3 Connector. This enables you to pass through an attachment and extract data about the attachment like the file size and file name using functions on the response (where supported).
When you design a process, you can pass attachments into a subprocess, service connector, or Service steps or return attachments (where the output field is defined using the Attachment type).
In a process, you can allow the user to add one or more attachments as inputs where the attachment is coming directly from the screen (not carried across steps using process fields). For example, you could use a process to capture real property data and allow the user to attach photos of the associated property. However, you cannot access the attachment data within a process.
Note: If you run a process on the cloud server, do not use an attachment whose size is more than the default 5,242,880 bytes. The cloud server cannot process attachments that are greater than 5,242,880 bytes.
Encoding
Attachments can be encoded as:
Data Types
You can specify named input parameters as attachments using two Simple data types:
From within the process, you can access metadata about the attachment using an XQuery formula and built-in functions. For example, the following returns the size of the 'photo' input:
sff:getAttachmentSize($input.photo)
You can assign input attachment fields to outputs or temp fields using an Assignment step. In that case, be sure that the target temp or output field is also of type Attachment.
In this example, the second parameter ($encodedContent) is a base64-encoded string:
sff:createAttachmentFromBase64("base64", "UOpGUIRA", "ascii")
Note: The attachment functions are available in processes but not in service connectors. See below for more information on handling attachments in service connectors.
Refer to Using Functions for more information on the functions available for use with attachments.

Attachment Payload

When using simple attachments, be sure that:

Using Attachments in Service Connectors

You can define a service connector in order to submit an attachment from a process to a service connector's input or obtain an attachment from a service connector and submit it to a process as an attachment.
Attachments are sent directly to the service input (including Salesforce-based services) from processes and service connectors.
Note: You upload or download content from services like Amazon S3 and propagate the attachment back to the main process under the name defined in the output mapping. With the Amazon S3 Connector, you can read or write the contents of an S3 object both as a Base64-encoded string and as an attachment. For more information, see the Amazon S3 Connector Guide.

Using Multiple Output Attachments in Service Connectors

A service connector can handle a multipart response appropriately and create multiple attachments for different response parts. The part related metadata information is available in the attachment properties.
A service connector can also recognize the payload part. The first JSON/XML/Text part is used as the payload. You can extract data from the payload in the output field expressions of the action as you would normally do when you work with non-multipart responses. Note that the selected payload will not be available as an attachment.
In the Output tab, you can use the Get from Attachments option to work with multiple attachments and pass the entire list of attachments to the selected variable except the payload.
You can also use an expression to work with attachments in service connectors. When you open the Expression Editor, you can find the new functions in the Functions tab, under the Output Attachments section.

Using GET, POST, and PUT

You can define a service connector to use GET, POST, or PUT operations on a resource that does not support JSON or XML.
Note that:
Note: The "sff" functions are available only in processes.

HTTP and JMS Headers

Use header functions to get details about headers that you pass when you invoke a process. You can get details about process headers and message event headers.
Use header functions to get information that is only available in the header that you pass when you invoke a process. Examples include dates, JSON Web Tokens, and security IDs.
You can assign the header value to a field and, optionally, perform XQuery operations on the value.
The following image shows the header functions available under the Request Context section of the Expression Editor:
This image shows the Functions section of the Expression Editor with six HTTPS header functions under the Request context section.
To understand how each function works, consider a process invoked with the following headers and values:
Header
Value
accept-language
en-US;q=0.9
client-ip
192.0.2.1
accept
text/xml
postman-token
0023-a5dfd-8vdg3-n2b3
CustomHeader
This is a custom header
ExecutionDate
Wed, July 25 2018 06:25:24 GMT
You can use the following header functions on their own, or along with other functions:
Get All Header Values
Use the getAllHeaders function to get a list of all headers and their values.
For example, if you use the following expression, you get a specific output:
Expression:
fn:getAllHeaders()
Output:
<headers>
<header name="accept-language">en-US;q=0.9</header>
<header name="client-ip">192.0.2.1</header>
<header name="accept">text/xml</header>
<header name="postman-token">0023-a5dfd-8vdg3-n2b3</header>
<header name="CustomHeader">This is a custom header</header>
<header name="ExecutionDate">Wed, July 25 2018 06:25:24 GMT</header>
</headers>
Get Date Headers
Use the getDateHeader function to get the value of a Date header. The function returns data in the dateTime type.
You can use other Date and Time functions to parse the value.
For example, if you use the following expression, you get a specific output:
Expression:
fn:year-from-dateTime(request:getDateHeader("ExecutionDate")
Output:
2018
Get a Specific Header Value
Use the getHeader function to get the value of a specific header.
For example, if you use the following expression, you get a specific output:
Expression:
request:getHeader("accept")
Output:
text/xml
Get a list of Headers Names
Use the getHeaderNames function to get a sequence of header names without values.
For example, if you use the following expression, you get a specific output:
Expression:
request:getHeaderNames()
Output:
accept-language,client-ip,accept,postman-token,CustomHeader,ExecutionDate
Get a Header value or 'Default'
Use the getHeaderOrDefault to get a header value if the header exists, or some default value if the header does not exist.
To use this function, you must give the header name and a default value as expression parameters.
Let the default value be Not Available.
For example, if you use the following expression, you get a valid output:
Expression:
concat ("The header I want is",
request:getHeaderOrDefault("postman-token","Not Avaialble" )
Output:
The header I want is 0023-a5dfd-8vdg3-n2b3
If you use the following expression, you get a Not Available output:
Expression:
concat ("The header I want is",
request:getHeaderOrDefault("special-token","Not Avaialble" )
Output:
The header I want is Not Available
This is because the request does not contain a header with the name special-token.
Check if a Specific Header Exists
Use the headerExists function to check if a header with a specific name exists.
You get either True or False in the output.
For example, if you use the following expression, you get a specific output:
Expression:
request:headerExists("CustomHeader")
Output:
True

Headers from Message Events

If a process has message events, you can use any header functions to get headers from the message events. To do this, you must add the case-sensitive message event name as an expression parameter.
For example, if you pass a header with the name CustomHeader to the message event receive step, use the following expression to get the value of CustomHeader from the message event ME1.
request:getHeader("CustomHeader","ME1")

HTTP verb functions

Use HTTP verb functions to retrieve the HTTP verb and the resource path segments that are used in a request. The HTTP verb functions are available under the Request Context section of the Expression Editor.
You can use the following HTTP verb functions:
getRequestHTTPVerb
Use the getRequestHTTPVerb function to determine the HTTP verb that is used in a request. The function retrieves the HTTP verb from the request and returns one of the following responses in a string format:
getResourcePathSegments
Use the getResourcePathSegments function to retrieve all or specific resource path segments of REST requests. The function returns the values as a string of tokens.
For example, consider the following request URL:
https://na1.ai.dm-us.informaticacloud.com/active-bpel/rt/InitiateOrder/Orders/OrderID_100/quantity/5
If you use the request:getResourcePathSegments() expression, you see the following response:
[Orders, OrderID_100, quantity, 5]
To retrieve a specific resource path segment, use a numeric qualifier to denote the position of the resource path segment from the process name.
For example, to retrieve the OrderID_100 segment alone in the response, use the following expression:
request:getResourcePathSegments()[2]
Note: You cannot use the getResourcePathSegments function to fetch the resource path segments of SOAP requests and message events. You cannot use the getResourcePathSegments function to fetch the host context.

Human task XQuery utilities

If you use a Human Task step in a process, you can use human task utility functions when working with XQuery in Process Designer or in any field that uses a formula to set a value.
The human task utility functions are available under the Human Task Utilities section of the Expression Editor.
The following table describes the human task utility functions:
Function
Syntax
Description
getHumanTaskId
task:getHumanTaskId(humanTaskStepName)
Returns the ID of the human task associated with the specified Human Task step name.
You can use the ID for other actions such as getting information about a human task, reassigning a task, or canceling a task.
getHumanTaskInfo
task:getHumanTaskInfo(humanTaskId)
Returns the following information about the human task based on the specified human task ID:
  • - Task ID
  • - Task name
  • - Status
  • - Priority
  • - Task initiator
  • - Stakeholders
  • - Potential owners
  • - Administrators
  • - Task owner
  • - Task creation date
  • - User who created the task
  • - Task activation time
  • - Task expiration time
  • - Skippable option value
reassignHumanTask
task:reassignHumanTask(humanTaskId, users, groups)
Reassigns a human task to the specified users and groups, and returns the task ID.
If you reassign the task to a single user, the user becomes the task owner. If you reassign the task to a group or multiple users, a user must claim the task to become the task owner.
To specify multiple users or groups, use a comma character as the delimiter. For example, use the following syntax:
task:reassignHumanTask(humanTaskId, ('<user1>','<user2>'), ('<group1>','<group2>'))
If you want to reassign the task to a specific user and not a group, use the following syntax:
task:reassignHumanTask(humanTaskId, '<user1>',")
cancelHumanTask
task:cancelHumanTask(humanTaskId)
Cancels a human task and makes the task obsolete. Returns the task ID. The process continues to the next step after a human task is canceled.