Restricted XPATH Expressions

Some agent parameters accept an XPATH expression to locate an element in the XML document. These parameters support the full syntax of XPATH 1.0. For convenience, the agents can construct the path to the element if it is not found in the XML document. This is useful to guarantee a parent element exists before a new XML child is inserted at that location. Unfortunately, XPATH is ambiguous when describing the construction of a path. For example, the element name might be missing (/root/*), some parents might be unknown (//ds:Signature), or siblings might be unkown (/root/child[3]). To allow the creation of the path, you must restrict the syntax to a subset of XPATH 1.0.

A restricted XPath expression has the form /comp1/comp2/... where each path component has the form ns:elem[@ns1:attrib="attribValue"]. The ns: and ns1: namespace prefixes are optional, but if present, they must be declared in the XML Namespace provider. The selector in square brackets is optional. The selector means: once an element named elem in the namespace declared with a prefix ns is found, you must also make sure it has an attribute called attrib in the namespace declared with the prefix ns1, and the attribute value is equal to attribValue. If no element with matching attribute is found, then both the element and the attribute will be created.

The agents have a boolean parameter called "Create Parent Element." When the parameter is true, the path to the element will be constructed if necessary, but the expression syntax must be restricted XPATH. When the parameter is false, the full expressive power of XPATH 1.0 is available, but the parent element must already exist in the XML document, otherwise an exception will be thrown.


iWay Software