Tech-invite3GPPspaceIETFspace
21222324252627282931323334353637384‑5x

Content for  TS 32.161  Word version:  18.0.0

Top   Top   Up   Prev   Next
0…   5…   6…   7…   A…   B…   C…   D…

 

7  Jex expressionsp. 11

7.1  Introductionp. 11

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.

7.2  Basicsp. 11

7.2.1  Evaluation contextp. 11

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.

7.2.2  Scalar valuesp. 11

7.2.2.1  Stringp. 11

The representation of a string is as defined in Section 7 of RFC 8259. A string is always surrounded by quotation marks.
String ::= '"' StringChar '"'
StringChar ::= #'[^"\/\b\f\n\r\t]*'

7.2.2.2  Numberp. 12

The representation of a number is as defined in Section 6 of RFC 8259.
Number ::= ( Minus )? NonNegativeInteger ( Fraction )? ( Exponent )?
DecimalPoint ::= '.'
Zero  ::= '0'
Digit0-9 ::= #'[0-9]+'
Digit1-9 ::= #'[1-9]+'
e ::= 'e' | 'E'
Exponent ::= e ( Minus | Plus )? Digit0-9+
Fraction ::= DecimalPoint Digit0-9+
NonNegativeInteger ::= Zero | ( Digit1-9 Digit0-9* )
Minus ::= '-'
Plus  ::= '+'

7.2.2.3  Literal stringsp. 12

The three string literals are
true ::= 'true'
false ::= 'false'
null ::= 'null'

7.2.3  Error handlingp. 12

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.
Up

7.2.4  White space handlingp. 12

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.

7.3  The location pathp. 12

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.
LocationPath ::= AbsoluteLocationPath | RelativeLocationPath
An absolute location path consists of "/", optionally followed by a relative location path. A "/" by itself selects the root node.
AbsoluteLocationPath ::= '/' RelativeLocationPath?
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.
RelativeLocationPath ::= ChildAxisStep ('/' ChildAxisStep)*
ChildAxisStep ::= DataNodeNameTest Predicate? | AbbreviatedStep
DataNodeNameTest ::= DataNodeName | '*'
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.
Predicate ::= '[' PredicateExpr ']'
PredicateExpr ::= JexBasicPredicateExpr | JexAdvancedPredicateExpr
The abbreviated step selects the current node.
AbbreviatedStep ::= '.'
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:
Up

7.4  Jex basic for node selectionp. 13

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".
Other conditions are not supported in predicates.
JexBasicPredicateExpr ::= MoiSelectorExpr | AttributeElementSelector
MoiSelectorExpr ::= 'id=' String
AttributeElementSelector ::= NonNegativeInteger
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.
Up

7.5  Jex advanced for node selectionp. 14

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.
JexAdvancedExpr ::= AbsolutePathExpr | (AbsolutePathExpr)*
AbsolutePathExpr ::= ('/' RelativePathExpr?)
RelativePathExpr ::= StepExpr ('/' StepExpr)*
StepExpr ::= ChildFilterExpr | ChildAxisStep
ChildFilterExpr ::= '(' UnionExpr ')'
UnionExpr ::= LocationPath ('|' LocationPath)*
LocationPath ::= AbsoluteLocationPath | RelativeLocationPath
Examples:
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".
Predicate                ::= '[' JexAdvancedPredicateExpr ']'
JexAdvancedPredicateExpr ::= OrExpr | AttributeElementSelector
OrExpr                   ::= AndExpr (' or ' AndExpr)*
AndExpr                  ::= AndOperandExpr (' and ' AndOperandExpr)*
AndOperandExpr           ::= ComparisionExpr| LocationPath | FunctionCall | '(' OrExpr ')' | 'not' '(' OrExpr ')'
ComparisionExpr          ::= EqualityExpr | RelationalExpr
AttributeElementSelector ::= NonNegativeInteger
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.
EqualityExpr   ::= LocationPath ('=' | '!=') (String
                                              | Number
                                              | true | false | null)
RelationalExpr ::= LocationPath ('<' | '>' | '<=' | '>=' ) 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.
FunctionCall ::= FunctionName'('LocationPath','Argument')'
FunctionName ::= "contains"
Argument     ::= String
Examples:
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".
Up

7.6  Jex conditions for condition evaluationp. 16

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.
Up

Up   Top   ToC