Try OpenEdge Now
skip to main content
BPM Events User's Guide
XML messages : XML data conversion : XPath query expression/statement
 

XPath query expression/statement

The current release of BPM Events contains three new expressions for an XPath query. There are corresponding functions for the new syntax, and they take additional parameter(s) for namespace context. They are essentially syntax add-ons to eliminate the need to provide namespace in XPath query where fixed namespace can be assumed.

SelectPath

This query returns all the (inner) nodes that satisfy the XPath condition.

*~:
XML*string->list<XML>::

this is to get nodes which satisfy the XPath.
Example1,
po *~ "po:purchaseOrder/po:itemsList/po:item[po.quantity > 10]";
Example2,
po.selectPath("po:purchaseOrder/po:itemsList/po:item[po.quantity > 10]", ns);
This returns a list of items where the quantity is larger than 10.

Find

This query returns a node that satisfies the XPath condition. This notation is already mentioned as field accessor, but it can be used for general XPath.

[]: XML*string->XML: (find)
this returns the first element which satisfy the XPath.
Example1,
po["po:purchaseOrder/po:itemsList/po:item[po.quantity > 10]"];
Example2,
po.find("po:purchaseOrder/po:itemsList/po:item[po.quantity > 10]", ns);
This returns an item where the quantity is larger than 10.

Match

This query returns TRUE if there is a node which satisfies the XPath condition; otherwise, it returns FALSE.

~~:
XML*string->boolean: (find)

this returns the first element which satisfy the XPath.
Example1,
po ~~ "po:purchaseOrder/po:itemsList/po:item[po.quantity > 10]";
Example2,
po.match("po:purchaseOrder/po:itemsList/po:item[po.quantity > 10]", ns);
This returns TRUE if there is an item where the quantity is larger than 10, otherwise returns FALSE.