replace text element processor

Replace Text Element processor

Version: 17.07

Supported Since: 17.07

What is Replace Text Element processor?

A Replace Text Element processor is a processing element which accepts a message with an XML payload, selects one or more text elements from that by evaluating a provided XPath expression, and then replaces the value of the selected element/s with a given new value.

In order to use this processing element, you must first select the Regular XML Processors dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the Regular XML Processors dependency.

replace text outports

Out Ports

Next

The message will be sent to this outport if the element value replacement is executed successfully

On Exception

The message will be sent to this outport if the processing element failed to replace the element value due to some reason

Parameters

XPath *

Basic

The XPath expression to select the element/s to be replaced

Value *

Basic

The new value to be set for the selected element/s

Namespaces

Basic

If any custom namespaces are being used inside XPath expression, those should be defined as a map with those namespaces as keys and the corresponding namespace URIs as values.

Sample Use Case

In the following use case, a food item distributor receives item order requests from the retailers and after some pre-processing, the acceptor system uploads them to an SFTP server. The order system should fetch these orders and uploads them to another SFTP server used by the manufacturer of these items.

The top level element of each order (i.e. <order> element) has a child text element named <senderId> which is a unique ID given for each retailer and is used by the pre-processing stage of the distributor’s system to identify which retailer has originated this request. But the distributor also has a unique ID provided by the manufacturer and the manufacturer expects this ID to be set as the <senderId> element when the order request is forwarded to the manufacturer’s system.

Therefore the requirement is to get the order requests from the source SFTP server, replace the value of the <senderId> element with the distributor’s ID and then uploads this request to the destination SFTP server.

Prerequisites

In order to implement following use case following dependencies should be selected when an empty Ultra project is being created.

  • SFTP Connector

  • XML Processors

If the project is already created, above dependencies can be added via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list and Processors list, select above dependencies.

replace text flow

In this flow, an SFTP ingress connector is used to retrieve the order requests from the source SFTP server and its "Processor" outport is connected to the inport of the Replace Text Element processor so that the XML message received by the connector is handed over to the processor next.

The XPath property of the processor is configured as /order/senderId to select the <senderId> element of the top level <order> element to be replaced. The Value property is configured as 5467 which is the ID given for the distributor, so that the existing value of <senderId> element is replaced by this value.

If any custom namespaces are being used inside XPath expression, those should be defined as a map in the Namespaces property, with those namespaces as keys and the corresponding namespace URIs as values.

Finally the "Next" outport of the Replace Text Element processor is connected to an SFTP egress connector so that the resulting message will be uploaded to the destination SFTP server.

Example

For example, assume that the original order request contains the following XML payload.

<?xml version="1.0" encoding="UTF-8"?>
<order>
    <senderId>1234</senderId>
    <items>
        <item>
            <id>7685</id>
            <amount>400</amount>
        </item>
        <item>
            <id>2345</id>
            <amount>100</amount>
        </item>
    </items>
</order>

The value of the element <senderId> will be replace by the value 5467 as follows.

<?xml version="1.0" encoding="UTF-8"?>
<order>
    <senderId>5467</senderId>
    <items>
        <item>
            <id>7685</id>
            <amount>400</amount>
        </item>
        <item>
            <id>2345</id>
            <amount>100</amount>
        </item>
    </items>
</order>
In this topic
In this topic
Contact Us