IBM BPM, V8.0.1, All platforms > Authoring services in Integration Designer > Developing monitor models > What are monitor models? > Expression support

XPath functions and operators

A subset of the XML Path Language (XPath) 2.0 is implemented in IBM Business Monitor and the IBM Business Monitor development toolkit.

The following tables show the symbols, operators, terminal symbols, and functions of XPath 2.0 that are supported by Business Monitor and the Business Monitor development toolkit. For more information about XPath 2.0, including the complete syntax in Extended Backus-Naur Form (EBNF), see http://www.w3.org/TR/xpath20/.


Supported symbols

The following table identifies the symbols that are supported. The symbol numbers in the first column are found in http://www.w3.org/TR/xpath20/#id-grammar.

Supported symbols
Number Symbol Consists of Expression
[1] XPath ::= Expr
[2] Expr ::= ExprSingle
[3] ExprSingle ::= IfExpr | OrExpr
[7] IfExpr ::= "if" "(" Expr ")" "then" ExprSingle "else" ExprSingle
[8] OrExpr ::= AndExpr ( "or" AndExpr )*
[9] AndExpr ::= ComparisonExpr ( "and" ComparisonExpr )*
[10] ComparisonExpr ::= RangeExpr ( (ValueComp | GeneralComp) RangeExpr )?
[11] RangeExpr ::= AdditiveExpr
[12] AdditiveExpr ::= MultiplicativeExpr ( ("+" | "-") MultiplicativeExpr )*
[13] MultiplicativeExpr ::= UnionExpr ( ("*" | "div" | "idiv" | "mod") UnionExpr )*
[14] UnionExpr ::= IntersectExceptExpr
[15] IntersectExceptExpr ::= InstanceofExpr
[16] InstanceofExpr ::= TreatExpr
[17] TreatExpr ::= CastableExpr
[18] CastableExpr ::= CastExpr
[19] CastExpr ::= UnaryExpr
[20] UnaryExpr ::= ("-" | "+")* ValueExpr
[21] ValueExpr ::= PathExpr
[22] GeneralComp ::= "=" | "!=" | "<" | "<=" | ">" | ">="
[23] ValueComp ::= "eq" | "ne" | "lt" | "le" | "gt" | "ge"
[25] PathExpr ::= ("/" RelativePathExpr?) | RelativePathExpr
[26] RelativePathExpr ::= StepExpr (("/") StepExpr)*
[27] StepExpr ::= FilterExpr | AxisStep
[28] AxisStep ::= (ReverseStep | ForwardStep)
[29] ForwardStep ::= AbbrevForwardStep
[31] AbbrevForwardStep ::= NodeTest
[32] ReverseStep ::= AbbrevReverseStep
[34] AbbrevReverseStep ::= ".."
[35] NodeTest ::= NameTest
[36] NameTest ::= QName
[38] FilterExpr ::= PrimaryExpr
[41] PrimaryExpr ::= Literal | ParenthesizedExpr | ContextItemExpr | FunctionCall
[42] Literal ::= NumericLiteral | StringLiteral
[43] NumericLiteral ::= IntegerLiteral | DecimalLiteral
[46] ParenthesizedExpr ::= "(" Expr? ")"
[47] ContextItemExpr ::= "."
[48] FunctionCall ::= QName "(" (ExprSingle ("," ExprSingle)*)? ")"


Additional support for inbound and outbound events

To refer to inbound and outbound events specifically, use the following paths.

Common Base Event predefined data elements:

InboundEventDefinitionRef '/' 'predefinedData' '/' (
'creationTime'|'elapsedTime'|'extensionName'|'globalInstanceId'|
'localInstanceId'|'msg'|'priority'|'repeatCount'|'sequenceNumber'|
'severity'|'version')

Common Base Event context data elements:

InboundEventDefinitionRef '/' 'propertyData' '/' ContextDataElementName

Common Base Event extended data elements:

InboundEventDefinitionRef '/' 'extendedData' '/' ExtendedDataElementName (
'/' ExtendedDataElementName)*

Any event content:

InboundEventDefinitionRef '/' EventPartId '/' Expr

where:

The following table is applicable to expressions referencing inbound events and their content.

Inbound event paths referencing event content
Symbol Expression
Expr UnionExpr | FunctionName '(' UnionExpr ')'
FunctionName 'fn:count' | 'fn:avg' | 'fn:max' | 'fn:min' | 'fn:sum'
UnionExpr PathExpr ('|' PathExpr)*
PathExpr (StepExpr '/')* (StepExpr | ('@' | 'attribute::') AttrNameTest | ('child::')? 'text()')
StepExpr ('.' | ('child::')? NameTest) ('[' PredicateExpr ']')*
NameTest QName | '*' | NCName ':' '*'
AttrNameTest NameTest | '*' ':' NCName
PredicateExpr OrExpr | Digits
OrExpr AndExpr ('or' AndExpr)*
AndExpr BooleanExpr ('and' BooleanExpr)*
BooleanExpr '(' OrExpr ')' | ValueExpr GeneralComp ValueExpr | ('@' | 'attribute::') AttrNameTest
GeneralComp '=' | '!=' | '<' | '<=' | '>' | '>='
ValueExpr ('@' | 'attribute::') AttrNameTest | Literal
Literal NumericLiteral | StringLiteral
StringLiteral ('"' (EscapeQuot | [^"])* '"') | ("'" (EscapeApos | [^'])* "'")
NumericLiteral IntegerLiteral | DecimalLiteral | DoubleLiteral
IntegerLiteral [+-]? Digits
DecimalLiteral [+-]? ('.' Digits) | (Digits '.' [0-9]*)
DoubleLiteral [+-]? (('.' Digits) | (Digits ('.' [0-9]*)?)) [eE] [+-]? Digits
EscapeQuot '""'
EscapeApos "''"
Digits [0-9]+

The following table is applicable to expressions referencing outbound events and their content.

Outbound event paths referencing event content
Symbol Expression
Expr PathExpr
PathExpr (StepExpr '/')* ( StepExpr | '@' AttrNameTest )
StepExpr NameTest ('[' Digits ']')?
NameTest QName
AttrNameTest NameTest
Digits [0-9]+


Supported operators

The following table identifies the operators that are supported. The row numbers indicate precedence order and are defined in http://www.w3.org/TR/xpath20/#id-precedence-order.

Supported operators
Number Operator
3 if
4 or
5 and
6 eq, ne, lt, le, gt, ge, =, !=, <, <=, >, >=
8 +, -
9 *, div, idiv, mod
16 -(unary), +(unary)
18 /
19 ( )

For operands that are not null, the value comparison operators (ne, lt, le, gt, ge) and the general comparison operators (=, !=, <, <=, >, >=) behave identically. If one or both operands are null (empty sequences) however, a value comparison a returns null value, while a general comparison returns a value of false.


Supported terminal symbols

The following table identifies the terminal symbols that are supported. The symbol numbers in the first column are found in http://www.w3.org/TR/xpath20/#lexical-structure.

Supported terminal symbols
Number Symbol Consists of Expression
[71] IntegerLiteral ::= Digits
[72] DecimalLiteral ::= ("." Digits) | (Digits "." [0-9]*)
[74] StringLiteral ::= ("'" (EscapeApos | [^'])* "'")
[76] EscapeApos ::= " '' "


Access elements within lists

You can use predicates to refer to elements within a list (also sometimes referred to as array elements). The predicate is an expression enclosed by square brackets that follows the path expression referring to the list.

For example, if myEvent/myEventPart/theOrder/item points to a list of items in an order, you can reference an individual item by enclosing a numeric index in square brackets.

For example, to access the price of an individual item, say item 12, you would use:

myEvent/myEventPart/theOrder/item[12]/price

Lists can also be used as arguments to aggregate functions.

For example, to calculate the sum of the prices in all the orders you would use:

fn:sum(myEvent/myEventPart/theOrder/item/price)
For more information, see Aggregate functions.


Supported constructor functions

The following constructor functions are supported. Constructor functions are the XPath 2.0 mechanism used by Business Monitor to support casting. In XPath 2.0, the semantics of constructor functions are equivalent to the use of the "cast as" operator, but the syntax is different.

The Boolean constructor functions with numeric arguments return a value of true if the argument is non-zero and false if it is zero. The numeric constructor functions with a boolean argument return 1 if the argument is true and 0 if it is false. The integer constructor functions with a decimal argument discard any fractional part of the argument. The constructors converting between decimal and duration values map a day-time duration to its length in seconds (including any fractional seconds) and vice versa. All constructors with string arguments expect a valid lexical representation of the result data type. Constructor functions that return a string value return the canonical lexical representation of the argument. The dateTime constructor with a date argument returns the first instant of the given date.


Supported general functions

The following subset of available XPath 2.0 functions are supported. The namespace declarations used are xmlns:xs="http://www.w3.org/2001/XMLSchema" and xmlns:fn="http://www.w3.org/2005/xpath-functions", as in http://www.w3.org/TR/xpath-functions/.


Aggregate functions

The five aggregate functions fn:count, fn:avg, fn:max, fn:min, and fn:sum (defined in http://www.w3.org/TR/xpath-functions/#aggregate-functions) are supported, provided that their argument references data in an inbound event. The argument of fn:count() can have any type. The other four functions must have numeric arguments.

For example, fn:sum(myEvent/extendedData/widgetList/widget/quantity) returns the total number of widgets in a list held in extended data elements.

fn:avg(myEvent/listOfItems/tns:item/@tns:cost) returns the average item cost in a list represented by the listOfItems event part.


Retrieving QName values

The value of an attribute or element in the event with a data type defined as xs:QName is retrieved as a string of the format: {namespaceName}localPart. The namespace name is obtained by resolving the QName's prefix, based on the namespace declarations in the event.

For example, if the event contains the namespace declaration xmlns:app="http://www.my.com/my/application/namespace", the QName value app:customerRating would be retrieved as {http://www.my.com/my/application/namespace}customerRating.


Comparing time zones

Metrics with a data type of date, time, or dateTime can have a value that is either adjusted for a time zone or a value that is not adjusted for a time zone. When you compare metrics with a data type of date, time, or dateTime:

Otherwise, an error will occur at run time when the comparison takes place.

Expression support