Context Reference Examples

The following examples show how context references are used in business processes, maps, and rule sets.

For Business Processes and Maps

Context Variable

Resulting Operation

./OrderIn/Order/OrderItems/Price

 

Retrieves all of the price fields from the document.

./OrderIn/Order/OrderItems/Type

Retrieves all instances of Type.

 

./OrderIn/Order/OrderItems
[./Type = 'blue']/Price

Retrieves all of the price fields from the document of the Type, blue.

 

./OrderIn/Order/OrderItems[3]/Price

Retrieves the third instance of OrderItems and returns its Price field. The indexing of elements in a business process or a map starts with 1, so the first element is referenced by [1].

 

Note: In business process or maps, the [*] denotes a repeating element in XPath. When you are setting the context reference, you must replace the asterisk with an integer index, a boolean expression, predicate functionality, or remove it entirely. See Setting Context References for Repeating Elements.

For Rule Sets

Context Variable

Resulting Operation

./OrderIn/Order/OrderItems/Price

 

Retrieves the first instance of price in the XML document.

 

./OrderIn/Order/OrderItems/Price[2]

Retrieves the third instance of price in the XML document. The indexing of elements in a rule set starts with 0, so first element is referenced by [0].

 

./OrderIn/Order/OrderItems/Price[*]

Retrieves all of the price fields from the XML document.

In this example /Price[*] translates to /Price at runtime.

 

Note: In Rule Sets, the use of the [*] is distinct from its alternate uses in the business process or a map. Repeating fields in rule sets must use brackets to reference a specific field, and predicates are not supported. Also, rule sets can only evaluate repeating terminal nodes in an .xsd. Embedded repeating nodes are not accessible. If the embedded data is needed for evaluation, map embedded repeating nodes to terminal nodes in another .xsd file.