Wednesday, February 14, 2024

XML Palette Activities

The XML palette provides activities for parsing XML strings into schemas and rendering schemas into XML strings

Parse XML:

Parse XML  is used when you have an XML document stored in a string or binary field. This activity produces a tree representation of the XML that can be used by following activities in the business flow.

Render XML:

Render XML activity does exactly opposite to Parse XML activity. Which means, it takes an XML tree for a specified schema and converts it to a string or binary element that contains the XML document.

Transform XML:

Transform XML is a synchronous activity that invokes the built-in XSLT processor to apply an XSLT stylesheet to an XML source document and produce a result document. Which means, Transform XML converts from XML format to another XML format.

We will see how Parse XML and Render XML works with the help of small example..


First, create a XSD  as shown below..
XSD - schema
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.example.org/Students" xmlns:tns="http://www.example.org/Students" elementFormDefault="qualified">


    <element name="Students" type="tns:StudentsType"></element>
    
    <complexType name="StudentsType">
    <sequence>
    <element ref="tns:Student" minOccurs="1" maxOccurs="unbounded"></element>
    </sequence>
    </complexType>
    
    <element name="Student" type="tns:StudentType"></element>


    <complexType name="StudentType">
    <sequence>
    <element ref="tns:FirstName" minOccurs="0" maxOccurs="1"></element>
    <element ref="tns:LastName" minOccurs="0" maxOccurs="1"></element>
    <element ref="tns:RollNumber" minOccurs="0" maxOccurs="1"></element>
    </sequence>
    </complexType>
    
    <element name="FirstName" type="string"></element>

    <element name="LastName" type="string"></element>

    <element name="RollNumber" type="int"></element>
</schema>

Parse XML:
Drag and drop parse XML on canvas and configure as shown below..

Point the required XSD 
Map source data

Render XML:
Point the required XSD


Map the fields..

Test the application from Postman..

<Students xmlns="http://www.example.org/Students">
<Student>
<FirstName>Paul</FirstName>
<LastName>Pi</LastName>
<RollNumber>200</RollNumber>
</Student>
<Student>
<FirstName>George</FirstName>
<LastName>RG </LastName>
<RollNumber>9001434</RollNumber>
</Student>
</Students>

And check the output..
<?xml version="1.0" encoding="UTF-8"?>
<tns3:Student xmlns:tns3="http://www.example.org/Students"> <tns3:FirstName>Paul</tns3:FirstName> <tns3:LastName>Pi </tns3:LastName> <tns3:RollNumber>200</tns3:RollNumber> </tns3:Student>

Thanks for reading :-)

XML Palette Activities

The XML palette provides activities for parsing XML strings into schemas and rendering schemas into XML strings Parse XML: Parse XML  is use...