Add XML Node

Contents

Overview

You can use this filter to add an XML element, attribute, text, comment, or CDATA section node to an XML message. The new node is inserted into the location pointed to by an XPath expression. XPath is a query language that enables you to select nodes in an XML document.

Configuration

You can configure the following fields for this filter:

Name:
Enter a suitable name that reflects the role of the filter. For example, if the purpose of this filter is to add an <Address> element to the message, it would be appropriate to name this filter Add Address Element.

XPath Location:
Specify an XPath expression to indicate where to insert the new node. If this expression returns more than one node, the first one is used. If no nodes are returned, the filter aborts. The following options determine where the new node is placed relative to the node(s) returned by the XPath expression.

  • Append:
    The new node is appended as a child node of the node returned by the XPath expression. If there are already child nodes of the node returned by the XPath expression, the new node is added as the last child node.
  • Before:
    The new node is inserted as a sibling node before the node returned by the XPath expression.
  • Replace:
    The node pointed to by the XPath expression is completely replaced by the new node.

Node Source:
The following options are available:

  • Create a new node:
    If this option is selected, a new node is created and inserted into the location pointed to by the XPath expression configured above.
  • Insert previously removed nodes:
    You can configure a Remove XML Node filter to remove XML nodes from the message and store them in the deleted.node.list message attribute. You can then use the Add XML Node filter to re-insert these nodes back into a different location inside the message, effectively moving the deleted nodes in the message. To use this option, select the Save deleted nodes option on a Remove XML Node filter that is configured to run before the Add XML Node filter in the policy.

Node Type:
Select the type of the new node from the drop-down list. It is important to note that the selection here determines where you can insert the new node according to the following rules:

  • You can only append a node to a Node Type of Element or Text.
  • If you append a Text node, you must append another Text node.
  • If you add a new Attribute node using the Replace option, it must replace an existing Attribute node.

Node Content:
This field contains the node to be inserted into the message. The Node Content field must contain valid XML when the Node Type is set to Element. You can also enter wildcards, which are populated at runtime by the Enterprise Gateway.

Attribute Name:
The attribute-related fields are only enabled when you select Attribute from the Node Type drop-down list. Enter the name of the attribute in this field.

Attribute Namespace URL:
Enter the namespace of the attribute in this field.

Attribute Namespace Prefix:
Specify the prefix to use to map the element to the namespace entered above in this field. The new attribute is prefixed by this prefix.