Version: 17.07
Supported Since: 17.07
A Retain Element as Payload processor is a processing element which accepts a message with an XML payload, selects an element of that by evaluating a provided XPath expression, and then retains only that selected element as the payload of the message.
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. |
Next |
The message will be sent to this outport if the operation is executed successfully |
On Exception |
The message will be sent to this outport if the operation due to some reason |
XPath * |
Basic |
The XPath expression to select the element to be retained |
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. |
In the following use case, a message with an XML payload will be received from a source JMS queue and it should be
delivered to a target system through SFTP. Each message payload contains information of a person and the target system
expects the root element of the document to be this <person>
element. But the source system always sends this person
element wrapped inside another element named <info>
.
The requirement is to get the message from the source JMS queue, extract only the <person>
element and send it as the
message to the target SFTP location.
Prerequisites
In order to implement following use case following dependencies should be selected when an empty Ultra project is being created.
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. |
In this flow, a Spring JMS ingress connector is used to retrieve the message from the source queue and its "Processor" outport is connected to the inport of the Retain Element as Payload 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 /info/person
and as a result, the processing element will
extract the element <person>
, set it as the payload of the message and then handover it to the SFTP Egress Connector.
It will upload the message to a configured remote server.
For example, assume that the message contains the following XML payload.
<?xml version="1.0" encoding="UTF-8"?>
<info>
<person id="1">
<name>Aladdin Strickland</name>
<email>rhoncus@laciniaorciconsectetuer.ca</email>
<company>At LLP</company>
<country>Slovenia</country>
</person>
</info>
The element selected with the given XPath expression i.e. <person>
element will be extracted and will be set as the
payload, which will look as below.
<?xml version="1.0" encoding="UTF-8"?>
<person id="1">
<name>Aladdin Strickland</name>
<email>rhoncus@laciniaorciconsectetuer.ca</email>
<company>At LLP</company>
<country>Slovenia</country>
</person>
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. |