Try OpenEdge Now
skip to main content
BPM Events User's Guide
XML messages : XML data field access syntax : Dot notation for XML data fields
 

Dot notation for XML data fields

Let x be XML data, and a be an element name of the top XML structure.
Instead of writing x.find("a"), you may use x.a as if it is an attribute of the xml object.
Even if there is more than one element with a, it returns only the first element with a as the name.
Dot notation is mainly for non-namespace associated XML data. But it can also be used while declaring the default namespace.
x.a.b is also allowed if x.a is a node element. When x.a is a leaf element or attribute value, it is converted to appropriate primitive values inferred from the content. If there is no such constraint, then it is recommended to use explicit conversion function like, toInt, toFloat. Another way to create constraint is to use the type specification for val declaration like:
Val p: int = item.quantity;
Note that the type of item.quantity is XML type (this is sort of a super class of all XML types like po:purchaseOrder).
So the above conversion does not change this type itself. It only implicitly inserts conversion function which converts an XML value to a primitive value (like int).
For example,
Val p = item.quantity;
Val s = "abc"+p; // BP compiler implicitly replace p by toString(p) .
Val I = 2 + p; // BP compiler implicitly replace p by toInt(p) .