Adding Replace Actions

Use a replace action to replace a node or the contents of a node specified by an XPath expression. The node or its contents are replaced with the value returned by an XQuery expression.

A replace action can be used to replace simple values, elements and even attributes. An XQuery expression that returns nothing is equivalent to deleting the identified nodes or making them empty, depending upon whether the action is replacing entire nodes or just node contents.

The replace action is one of a set of update actions.

Before you begin

These instructions assume you are already editing a message flow in the Edit Message Flow page, as explained in Creating, Editing, and Viewing Message Flows.

To add a Replace action

  1. Navigate to where you want to add the action, as described in Adding and Editing Actions in Message Flows.
  2. Click the appropriate icon, then select Add an Action > Message Processing > Replace.
  3. Click <XPath>. The XPath Expression Editor page is displayed. The XPath expression is used to specify the data (in the named variable) that will be replaced.See Creating and Editing Inline XQuery and XPath Expressions.
  4. When you finish editing the XPath expression, enter a context variable in the in variable field. See Appendix A, Message Context.
  5. Click <Expression>. The XQuery Expression Editor page is displayed. The XQuery expression is used to create the data that replaces the data specified by the XPath in the named variable.See Creating and Editing Inline XQuery and XPath Expressions.
  6. When you finish editing the XQuery expression, select one of the options:
    • Replace entire node-to specify that the nodes selected by the XPath expression you defined are replaced along with all of its contents
    • Replace node contents-to specify that the node is not replaced; only the contents are replaced.
    • Note: Selecting the Replace node contents option and leaving the XPath field blank is more efficient than selecting the Replace entire node option and setting the XPath to ./*

After you finish

When you complete the configuration of this action, continue by configuring other actions or by saving your configuration, as described in Adding and Editing Actions in Message Flows.