Snip Service (com.ibi.agents.XDSnipAgent)

Syntax:

com.ibi.agents.XDSnipAgent

Description:

This service moves an XML subtree or a JSON value from the input document to the root of the output document. This may be especially useful to pull the body payload from a surrounding envelope with headers.

Parameters:

Parameter

Description

Target

Location of the desired XML subtree or JSON value, interpreted according to the Target Type.

Target Type

Determines how the Target is interpreted. The Target can be an XPath expression, the name of the parent XML element, the name of the XML element itself, or a JsonPath expression. A JsonPath expression requires a JSON input document, otherwise the input document must be XML.

XML Namespace Provider

Provider for the mapping between XML namespace prefix and namespace URI in XPath expressions. If left blank, then the XPath expression in the Target cannot contain namespaces.

XPath Syntax

Determines which syntax level of XPath should be used. The default option selects the syntax level as set in the console global settings.

When snipping an XML subtree, the inherited XML namespaces from the ancestor elements are redeclared on the target node to keep it well-formed.

The Target Type parameter determines how the Target is located. The possible values are: XPath, Parent, Root, or JsonPath.

When the Target Type is XPath, the Target is an XPath expression that is evaluated against the input XML document. The result must be a single element that is moved to the root of the output document. The service returns notfound if the result is empty, or duplicate if it contains multiple elements. The XML Namespace Provider parameter is optional. When the provider is specified, the XPath expression may contain namespace prefixes declared by that provider. You can choose the XPath engine with the XPath Syntax parameter. You can select from:

When the Target Type is Parent, the Target is the name of the parent element located with a depth-first search within the input XML document. The parent must contain a single child element that is moved to the root of the output document. The service returns notfound if the parent is not found or if it does not contain a child element. The service returns duplicate if the parent contains multiple child elements.

When the Target Type is Root, the Target is the name of the target element located with a depth-first search within the input XML document. The target element is moved to the root of the output document. The service returns notfound if the target element is not found.

When the Target Type is JsonPath, then the Target is a JsonPath expression that is evaluated against the input JSON document. The result must be a single JSON value that is moved to the root of the output document. The service returns notfound if the result is empty, or duplicate if it contains multiple values.

Edges:

The following table lists and describes the available edges for the Snip Service (com.ibi.agents.XDSnipAgent).

Line Edge

Description

Success

The XML subtree or JSON value was successfully snipped.

fail_parse

An iFL or XPath expression could not be evaluated.

fail_format

The input document is not in the required format for the Target Type.

duplicate

The expression returned more than one object or the located node under the parent has siblings.

Notfound

The XML subtree or JSON value was not found.

Example:

The following example selects the first element in the body of a SOAP envelope. This table lists the parameter values that would be used.

Parameter

Description

Target

/soap:Envelope/soap:Body/*[1]

Target Type

xpath

XMl Namespace Provider

nsprov

XPath Syntax

default

This example assumes the nsprov XML Namespace Provider declares the soap prefix to be:

http://schemas.xmlsoap.org/soap/envelope/

The following is a sample input document:

This sample input document produces the following output document: