Show TOC

Generic FunctionsLocate this document in the navigation structure

Use

The expression editor contains a list with built-in functions for transforming data. The list is now enhanced with a set of generic functions such as sort, filter, and so on. With anyType support, it is possible to create such generic functions, whose input parameters and/or return types are xsd:anyType. This means that you can provide every custom or base type as an actual parameter to the function. If you provide a concrete type as a parameter, the function returns the same concrete type as a result.

The following table lists the built-in generic functions, their description, signature, and an example for each generic function. The asterisk (*) indicates that there are zero or more occurrences of the marked element:

Generic Function

Description

Signature

Example

Sort

Sorts a list which is provided as one of the input parameters of the function. The list is sorted by the string representation of the input parameter serving as a sort criterion. The sort direction can be either ascending or descending and is set as a Boolean value. The result is a sorted list.

Note that if the criterion is an attribute, you must prefix it with an at sign (@).

sort( list as xsd:anyType*, sortBy as xsd:string, descending as xsd:boolean ) as xsd:anyType*

The sort function sorts a list of task attributes contained in a data object DataObject . The sort criterion is the type of actual owner. The sort direction is descending, which means that the Boolean value is true .

                           sort( DataObject/TaskAttributes, "actualOwner/type", true )
                        

The sort function sorts a list with addresses contained in data object DataObject . The sort criterion is the country zipcode, which is an attribute and is prefixed with an at (@) sign.

                           DataObject
  Address
    city
    country
      @zipcode
      #text()
                           sort( DataObject/Address, "country/@zipcode", true )
                        

Filter

Filters a list, which is provided as one of the input parameters of the function. The list is filtered by the string representation of the input parameter serving as a filter criterion. Note that the filter criterion cannot be a list.

The result after executing the function is a filtered list.

In case you want to use a parameter whose type has a qualified namespace, you need to specify the namesapce together with the parameter in the expression editor.

Note that if the criterion is an attribute, you must prefix it with an at sign (@).

filter( list as xsd:anyType*, criteria as xsd:string ) as xsd:anyType*

The filter function filters a list of principals contained as potential owners in a data object DataObject . To evaluate the filter criterion, the built-in function concat is invoked, which returns a result as xs:string. This example shows the possibility the filter criterion to have a dynamic value.

                           filter( 
DataObject/PotentialOwners/principal,
concat(
"principalId=",DataObject/ExcludedOwners/principal/principalId )
 ) 
                        

The parameter e1 that you want to use as a filter criterion has a type with a qualified namespace "http://www.example.org/NewXMLSchema" . You specify the namespace of the parameter when using the filter function as follows:

                           filter( arg1,"http://www.example.org/NewXMLSchema:e1=1")
                        

Get

Gets the N-th element from a list, starting the count from 0. The input parameters of the function are a list and an index. The result is a single element.

get( list as xsd:anyType*, index as xsd:long ) as xsd:anyType ( single )

The get function gets the third principal from a list of excluded owners, contained in a data object DataObject .

                           get( DataObject/ExcludedOwners/principal, 3 )
                        

Count

Counts the number of elements in the input parameter. The result is a number.

count( arg as xsd:anyType* ) as xsd:long

The count function counts the principals contained as potential owners in a data object DataObject .

                           count( DataObject/PotentialOwners/principal )
                        

Insert-Before

Inserts a list in another list in a defined position, starting the count from 0.

insert-before( target as xsd:anyType*, position as xsd:long, inserts as xsd:anyType* ) as xsd:anyType*

The insert-before function inserts the principals from the excluded owners list in the list of potential owners starting from position 2. Both lists are contained in a data object DataObject .

                           insert-before( DataObject/PotentialOwners/principal,
2,
DataObject/ExcludedOwners/principal )
                        

IF

This function could be used over both lists and single values as input parameters.

Caution

All of the three input parameters are evaluated. That is why, you have to define semantically correct expression for all of the parameters that could be evaluated at runtime.

Based on the returned Boolean value from the evaluation of the first input parameter (the Boolean condition), the function returns and xsd:duration representing the value received after the evaluation of either the second or the third input parameter.

IF( test as xsd:boolean, thenValue as xsd:anyType*, elseValue as xsd:anyType* ) as xsd:anyType*

The IF function evaluates the result of the condition as false and takes the value of the description, contained in a data object DataObject .

                           IF( 
min( 3,5 )>10,
DataObject/subject,
DataObject/description )
                        

IsSet

Returns true as a result if the list that is provided as an input parameter, is not null.

isSet( list as xsd:anyType*) as xsd:boolean

The isSet function evaluates the list of potential owners in a data object DataObject and returns true if the list is initialized. If the list is null, the function returns false as a result.

                           isSet( DataObject/PotentialOwners/principal )
                        

Nilled

Returns true as a result only if the input parameter is initialized and annotated as xsi:nil

nilled( arg xsd:anyType) as xsd:boolean

The nilled function checks whether the element A in a data object DataObject is initialized and annotated as xsi:nil and returns true if it is. Otherwise the nilled function returns false .

                           <DataObject>

                           <A xsi:nil="true"/>

                           </DataObject>
                        
                           nilled( DataObject/A)-> true