Jex uses the same syntax, the same concepts and the same definitions as XPath. Jex expressions are a subset of XPath expressions. All subsets support only the abbreviated syntax.
A Jex expression is applied to an input JSON document. The output of a Jex expression is always a node set, or one of the boolean values true and false.
Different XPath subsets are defined in the following clauses A subset is also called Jex profile.
Jex expressions are evaluated in a context, that is a subset of the XPath evaluation context. The Jex context includes
a node (the context node)
a pair of non-zero positive integers (the context position and the context size)
a function library
The initial context node of a Jex expression is specified where the Jex pression is used. This initial context node is often referred to as base object.
Note that context position and context size work only for element nodes coming from JSON arrays.
A syntax error in the Jex expression results in no output or the bloolean value false
A data type mismatch in comparisons returns always false.
A Jex processor may evaluate Jex expressions based on the schema definition of the object tree the Jex expression is applied to. In this case the Jex expressions will never evaluate to true or a non-empty node set, for example because of a misspelled data node name, the Jex processor may raise an error. Details of error detection and how an error is notified is out of scope of the present document.
White spaces are not allowed in a Jex expression. An exception are "and" and "or" expressions where exactly one white space character shall be present before and after the operator.
A location path selects zero or more data nodes in an object tree. The location path is either an absolute location path or a relative location path. An absolute location path starts at the root node. A relative location path starts at the context node.
A relative location path consists of one or more axis steps. Only the child axis is supported in Jex. The location step contains a data node name test and an optional predicate. The asterisk "*" is supported and selects all element children of the context node.
The predicate is an expression encapsulated in rectangular brackets. The predicate expression shall evaluate to true or false. The child node is selected only when the predicate evaluates to true. The capabilities of the predicate differ for the different Jex profiles. The predicate expressions are defined where the profiles are defined.
The "DataNodeName" is either a class name, the string "attributes", an attribute name, an attribute field name, or a notification parameter. The characters delineating the components of a Jex expression are not allowed.
DataNodeName ::= #'[^"[\]=!<>\n ]*'
Note that depending on the context where the Jex expression is used more characters may be excluded.
Examples of an absolute location path without predicates:
Examples of an absolute location path with predicates:
An expression in Jex basic returns a set of data nodes. The output node set may be empty. The data nodes that can be selected are managed object instances, attributes, attribute fields and attribute elements of multi-valued attributes. Conditional data node selection with predicates is limited.
Each Jex basic expression is an absolute location path.
JexBasicExpr ::= AbsoluteLocationPath
Predicates are used in Jex basic only for selecting
element nodes representing managed object instances based on the value of their naming attribute "id".
array items representing attribute elements (of multi-valued attributes) based on their positional index. The first element has the index "0".
The function library in Jex Basic is empty.
Examples:
The following Jex expression selects all attributes of the "SubNetwork" whose "id" is SN1, or the complete managed object, depending on the context.
In the next examples the Jex expressions select one attribute of a specific manged object.
An example for selecting an attribute field may look as follows.
All attributes of an object instance can be selected with the wildcard "*".
The following expression selects the first attribute element of a multi-valued attribute.
The following example shows how all "ManagedElement" instances, that are childs of the "SubNetwork" with the "id" equal to SN1, are selected by the second location step with a name test. The following location steps select then the "vendorName" attribute of the previously selected "ManagedElement" instances.
Note that the EBNF allows also JEX expressions that do not make sense and result in empty node output sets in most cases.
An expression in Jex advanced returns a set of data nodes. The output node set may be empty. The data nodes that can be selected are managed object instances, attributes, attribute fields and attribute elements of multi-valued attributes. Conditional data node selection with predicates is much more powerful than in Jex basic.
An expression in Jex advanced is a union of absolute path expressions. The path expression is more flexible than the location path and allows to select element nodes with more than one data node name in a single step.
Jex Advanced also extends Jex Basic with more powerful predicates for selecting data nodes by supporting comparison expressions that can be combined using "or" and "and".
The "and" operator has a higher precedence than the "or" operator. An "and" expression, an "or" expression or any combination of an "and" and an "or" expressions can be enclosed in parentheses, which allows to control the precedence of the "and" and "or" operators.
Equality and relational expressions have on the left side of the operator an absolute location path or a relative location path. On the right side of the operator equality expressions have a string, a number or one of the three literals true, false, or null. Relational expressions have on the right side of the operator a number.
The data type of the value on the right side of the operator shall have the same data type as the value produced by the location path on the left side of the operator. If the values do not have the same data type the equality or relational expression shall evaluate to "false".
The function library in Jex Advanced features the XPath string function "contains" defined in clause 4.2 of the W3C XPath1.0 specification [2], and the boolean function "not" defined in clause 4.3 of the W3C XPath1.0 specification [2].
The "not" function returns true if its argument is false, and false otherwise. Its argument is an "or" expression.
Example:
The "contains" function returns true if the first argument string contains the second argument string, and otherwise returns false. It can be used only in predicates as follows.
In the first example the specified "ManagedElement" instance is selected only when the "vendorName" attribute has the value "Company XY".
Instead of the instance only one attribute can be selected.
The Jex expression in the next example selects all "ManagedElements" from the vendor "Company XY".
The following example selects the threshold level identified by the "level" 3.
The location paths in the predicates in the examples above are relative location paths with a single location step. Multiple location steps are also possible in a predicate.
The location path in a predicate can also be an absolute location path. This allows to test on conditions prevailing somewhere else in the object tree.
The following example shows how multiple attributes can be selected using a sequence expression.
Sequence expressions can also be used to select objects of different classes.
Multiple conditions can appear in a predicate.
The following expression selects all "ManagedElement" objects whose "location" value contains the string "tower".
The next expression returns the "location" only if its value contains the string "tower".
A Jex conditions expression evaluates to "true" or "false". It is equal to the predicate expression in Jex advanced.
JexConditionsExpr ::= JexAdvancedPredicateExpr
Jex conditions is used for evaluating conditions in an object tree or some other JSON document. Depending on the outcome certain actions may be triggered. For example, Jex conditions can be used for notification filtering, or starting and stopping collection of additional performance metrics when some basic permanently monitored performance metrics are above a certain threshold.