XPath is a language used to address elements arranged in a tree data model (model in which the elements have a parent-child relationship).
There are different types of elements (or nodes):
- either a final value element with a primitive type (alphanumeric, numeric, Boolean),
- or an attribute element.
When used in the AMBSS, the model is made up of a Java Beans tree structure.
XPath is a language used to address objects arranged in a tree data model (model in which the objects have a parent-child relationship).
There are different types of objects (or nodes):
- either a final value node with a primitive type (alphanumeric, numeric, Boolean, etc.),
- or an attribute node. It is made up of a marker (or name) and value node assigned to the attribute. Attribute nodes are considered as belonging to an element node,
- or an element node. It is composed of attribute nodes (without a notion of order between these nodes),
- or a list node. These child nodes are sequenced and each node can be accessed using an index.
Elements are located in the form of location paths, similar to the Unix directory system: A location path is made up of different location steps separated by slashes (/) similar to file addressing in directory systems.
The order of nodes is determined by the path (governed by the nesting of nodes, from the parent to the child). The first node is the root node of the path.
The location paths are analyzed from left to right.
When used in the AMBSS, the model is made up of a Java Beans tree structure:
- a final node is a Java primitive type,
- an attribute node is equivalent to the getter of a Java Bean property,
- an element node is a Java Bean or Java Map (hash table),
- a list node is a Java collection.
Standard key of an Adelia subscriber.
A subscriber is defined by a tree object model in YAML (in the SubscribersConf.yml file) or in JSON (in the body of a REST API HTTP request):
YAML Adelia subscriber id: mySubcriber startOnCreation: true config: adeliaPgm: objectFileName: EAP_1 javaPackage: my.package.for.eadelia parameters: - Bob - Brown - 38 customObjectMapper: mapperBean1 adeliaPoolName: poolLambdaServer brokerConfig: factory: id: company.BrokerSubscriberFactory parameters: provider: factory.json aggregate: false | Souscripteur en JSON { "id": "mySubcriber", "startOnCreation": true, "config": { "adeliaPgm": { "objectFileName": "EAP_1", "javaPackage": "my.package.for.eadelia", "parameters": [ "Bob", "Brown", 38 ], "customObjectMapper": "mapperBean1" }, "adeliaPoolName": "poolLambdaServer", "brokerConfig": { "factory": { "id": "company.BrokerSubscriberFactory", "parameters": { "provider": "factory.json", "aggregate": false } } } } } |
---|
Attribute node
A standard key is defined by a "subconf" root node which identifies a subscriber and stores the information comprising it. "id", "startOnCreation" and "config" sub-nodes are attribute nodes.
"id" and "startOnCreation" nodes have primitive types (alphanumeric and Boolean). Their values can be accessed by "subconf/id" and "subconf/startOnCreation" paths.
The "config" node is an element node with the "adeliaPgm", "adeliaPoolName" and "brokerConfig" sub-nodes as children.
List node
To retrieve the parameter of the EADELIA program associated with the subscriber, 'subconf/config/adeliaPgm/parameters' list node elements need to be accessed. Index notation can be used to access an element in the list:
'subconf/config/adeliaPgm/parameters[1]' allows the first element in the list to be accessed.
Notes:
- The 'subconf/config/adeliaPgm/parameters[<index>]' expression is a read shortcut of the XPath expression using the predefined position() function: 'subconf/config/adeliaPgm/parameters[position()=<index>]'
- The last element can be accessed using the predefined last() function: 'subconf/config/adeliaPgm/parameters[last()]'
Accessing the properties of a list
Empty list
To determine whether a list element is empty, use the "empty" attribute as follows:
'subconf/config/adeliaPgm/parameters/empty' returns a Boolean value.
List size
The size of a list can be retrieved using the predefined Xpath count function:
'count(subconf/config/adeliaPgm/parameters)'
or using a predefined function delivered in the AMBSS:
'adelUtils:collectionSize(subconf/config/adeliaPgm/parameters)'
Map element node
In certain cases, an element node represents a hash table (structure enabling a key-value association, i.e. an associative array abstract-type implementation). It is an array which does not have an order (unlike an ordinary array which is indexed by integers). Each array value is accessed by its key which, transformed by a hash function into a hash value (a number), indexes the elements of the table.
In this case, the attribute elements act as a key.
In an Adelia subscriber, the factory's instantiation parameters designated by the XPATH path 'subConf/config/brokerConfig/factory/parameters' are stored in the form of a Map. As each factory has a different signature, the name, cardinality and type of the parameters are defined by the factory.
Accessing the properties of a map
Value associated with a key
To access the value associated with a known key name, use the following XPath expression:
'subConf/config/brokerConfig/factory/parameters/provider' which is a short form of the expression:
'subConf/config/brokerConfig/factory/parameters[@name='provider']'
Key list
The AMBSS provides a predefined function which is used to return a list of keys from a hash table:
'adelUtils:mapKeys(subConf/config/brokerConfig/factory/parameters)' returns a list element of two value elements ['provider', 'aggregate']
List of values associated with the keys
The AMBSS provides a predefined function which is used to return the list of values associated with the keys from a hash table:
'adelUtils:mapValues(subConf/config/brokerConfig/factory/parameters)' returns a list element of two value elements ['factory.json', false]
Note:
Specific key of an Adelia subscriber
The specific keys corresponding to variant elements 'subconf/config/brokerConfig/brokerConnection' and 'subconf/config/brokerConfig/subscribeTopic' follow the same write and syntax principles. Refer to the documentation relating to each broker to find out the data model of the variant elements.