TIBCO XSLT Tutorial: How to transform XML in TIBCO BW

XSLT (Extensible Stylesheet Language Transformation) is used to transform XML documents from one format to other format. While developing processes in TIBCO during application’s integration, XML transformations are often required.

In this TIBCO XSLT tutorial, you will learn step by step how to transform XML from one format to another format in TIBCO using XSLT.

Step 1: Create Source XML File and XSD Schema

In order to go forward with TIBCO XSLT tutorial, first thing that we need to do is source XML file creation. In this tutorial example, we are going to use following source XML which will be transformed to another format using XSLT transformation:

Source XML File:

<?xml version=”1.0″?>
<EmployeeList>
<Employee>
<Name>Ajmal</Name>
<Age>26</Age>
</Employee>
<Employee>
<Name>David</Name>
<Age>17</Age>
</Employee>
</EmployeeList>

We need to create XSD Schema in our TIBCO BW project for this source XML File. By dropping XSD schema in your designer panel, create Schema as shown below:

source xml schema

 

Step 2: Create target Schema

In this tutorial, we want to take above XML as input and want to convert it into a new format based on the below target schema:

target xml schema

Step 3: Create XSLT for XML Transformation in TIBCO

Now that we are clear about our source XML schema and target XML Schema, we need to write XSLT code which will be used for XML transformation.

We will take Age from the source XML and give a value “Eligible” to the Status field in the target XML if age is greater than 20 years. Otherwise, our target XML will have Status as “Not Eligible“.

To achieve this XML Transformation, our XSLT will be as shown below:

<?xml version=”1.0″?>
<xsl:stylesheet  xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” version=”1.0″>
<xsl:template match=”/”>
<StatusLog>
<xsl:for-each select=”EmployeeList/Employee” >
<Name>
<xsl:value-of select=”Name” />
</Name>
<Status>
<xsl:choose>
<xsl:when test=”Age&gt;’20′”>
Eligible
</xsl:when>
<xsl:otherwise>
Not Eligible
</xsl:otherwise>
</xsl:choose>
</Status>
</xsl:for-each>
</StatusLog>
</xsl:template>
</xsl:stylesheet>

 

Step 4: Create TIBCO BW Process for XSLT Based XML Transformation

Now we need to create a process where we will be performing source XML parsing, rendering, transformation and then target XML Parsing. To keep the scenario simple, I haven’t added any exception handling in the process for now.

I have used a Read File activity to read the source XML from local file system. In the Input tab of Read File activity, file to be read is specified as shown below:

tibco xslt read xml file input

 

After reading source XML File, we need to use Parse XML activity to parse the file contents based on our source XML XSD schema that we created in Step 2.

Parse XML Input tab will be as shown below:

tibco xslt parse xml input

 

In the output editor of Parse XML activity, we choose XSD file for the source XML File as you can see in below screenshot:

tibco xslt parse xml output editor

 

Just to make you more clear and well aware about XML Parsing and XML Rendering, I have used Render XML activity which will be used to create XML string which will be later provided as Input to Transform XML activity.

Configuration tab of Render XML activity is shown below:

tibco xslt render xml configuration

In the Input Editor tab of Render XML activity, we specify the XSD schema to be used for rendering XML file. This is shown in below screenshot:

tibco xslt render xml input editor

 

And then, in the Input tab of Render XML activity, we map Parse XML output by choosing Copy-of option as shown in the below screenshot:

tibco xslt render xml input mapping

 

Now that we are done with Parsing and Rendering of our source XML File, we move towards Transform XML activity which will be used to create our target XML based on the XSLT file that we created earlier.

In the configuration tab of Transform XML activity, we have chosen XSLT file to be used, Input and Output Style and XSLT engine. Complete configuration of XML Transform activity is shown below:

tibco transform xml configuration

 

In the Input tab of Transform XML activity, we map the source XML from Render XML output as you can see in the screenshot below:

tibco transform xml input

 

After transformation of XML file from one format to another using XSLT, our next step will be to parse the new XML file for which we use Parse XML activity to which we give transformed XML as input as shown below:

tibco parse target xml input mapping

 

In the output editor tab of this Parse XML activity, we choose our target XSD schema which was created in step 2.

Output editor tab of this activity is shown in below screenshot:

tibco parse target xml output editor

 

That’s it for process development. We are done with the configuration of all the activities in our process. Validate the project and after successful validation, move to the next step where we will test our XSLT based transformation process.

 

Step 5: Test XSLT Transformation Process in TIBCO

Load the process in designer tester. As you can see in below screenshot, our process has run successfully. Everything seems fine:

tibco designer test xslt transformation

Now let’s go to different activities in tester mode and verify that everything has worked the way we wanted.

Go to the output tab of Parse Source XML activity to see if XML File read by Read File activity has been parsed correctly. As shown in the below screenshot, this parsing has gone correctly:

tibco xslt tester parse source xml output

Now go to the Output tab of Render XML activity to see if it has resulted in rendering of XML correctly as a string. Yes, below screenshot shows that Render XML activity has given the XML string rightly:

tibco xslt tester render xml output

Now we need to check and verify that Transform XML activity has created output properly based on our XSLT File. Go to the output tab of Transform XML activity. As you can see below, this activity has created output XML correctly based on the XSLT file that we had specified:

tibco tester transform xml output

And the last thing to test is the Parse XML activity to verify that our target XML file created by XSLT transform activity has been parsed correctly based on our target XML schema.

As shown below, parsing of target XML is successful:

tibco tester parse target xml output

Ajmal Abbasi

Ajmal Hussain Abbasi is Integration Consultant By Profession with 13+ years experience in Integration domain mainly with TIBCO products. He has extensive practical knowledge of TIBCO Business Works, TIBCO Cloud, TIBCO Flogo, TIBCO Mashery, TIBCO Spotfire, EMS and TIBCO ActiveSpaces. He has worked on a number of highly critical integration projects in various sectors by using his skills in TIBCO Flogo, TIBCO API Management (Mashery), TCI, Tibco Designer, TIBCO Business Studio, Adapters, TIBCO EMS, RV, Administrator, TIBCO BE, TIBCO ActiveSpaces etc. Ajmal Abbasi has experience with MuleSoft ESB as well. Ajmal Abbasi is also experienced in the area of API Management particularly with WSO2 API management platforms. Ajmal Abbasi is also experienced in developing solutions using Core Java and J2EE Technologies. You can contact Ajmal Abbasi for Consultancy, Technical Assistance and Technical Discussions.

More Posts - Website - Facebook - LinkedIn - YouTube

11 thoughts on “TIBCO XSLT Tutorial: How to transform XML in TIBCO BW

  1. Amit Anand

    How can we use the styleSheet input field to mention the stylesheet name ?

    Reply
    1. Ronnie

      I completed the tutorial but I ran into one issue. When I validated my process, I get an error with the XML transform activity. The message is “java.lang.IllegalArgumentException: not an error or warning message code: BW-XML-100001” and/or “The resource: EmployeeXSLT.xslt cannot be validated as its palette is not installed.”. These are strange messages and I am not getting good results from internet. Do you have any insight?

      Reply
      1. bhabesh

        Hello ,

        The xslt has special characters, try to format the xslt using a xml editor and try again.

        Cheers

        Reply
  2. Raja

    Hi,

    For one of my project I have done the XML Transformation using XSLT and deployed.
    But unfortunately the expected result is through designer only i.e it runs successfully with the expected result in designer and not in the deployed code in the environment.
    Is there a chance that the behaviour varies in design time and run time ? Is there a chance an extra step is required to build the EAR ?

    Thanks,
    Raja

    Reply
    1. DEv

      It now working…

      pls tell me how to use below XSLT.

      Eligible

      Not Eligible

      Reply
  3. sagar

    it not working ,
    every time tiring to run, i`m getting the BW-XML-100001 error in the transform XML .
    I have already tired all the things mentioned below and things mentioned on the community,checked thoroughly the XSLT in the notepad,even tired “>” symbol as well but nothing seems to working .Is there something wrong with my machine.if somebody can look into it or have overcome this issue ,please let me know.

    Reply
  4. PATI

    Thanks Ajmal. Very Helpful.

    Quick question now that I am able to achieve my requirements on xslt, I wanted to work on my deployment process. Is there a way that I can load my XSLT on demand in bw. Like if I use XSLT File available in bw palette. Then for each time If I have to change color or value of my html report table I will end up updating my code and create build and deploy it.

    Is there a way I can update my XSLT each time so that I can avoid deployment. (Start and stop is fine as we have access to do that in prod). Please let me know. Thanks in advance

    Reply
  5. smit

    Hello,
    I’m getting error at Parse Source XML.
    BW-XML-100013 Job-37000 Error in [XMLTransformInTibco/Process Definition.process/Parse Source XML]
    A validation occurred while parsing: validation error: no declaration for element “EmployeeList” ({com.tibco.xml.validation}COMPLEX_E_MISSING_ELEMENT_DECLARATION) at /EmployeeList[1]
    com.tibco.xml.validation.exception.MissingDeclarationException: no declaration for element “EmployeeList”
    .
    caused by: org.xml.sax.SAXException: validation error: no declaration for element “EmployeeList” ({com.tibco.xml.validation}COMPLEX_E_MISSING_ELEMENT_DECLARATION) at /EmployeeList[1]
    com.tibco.xml.validation.exception.MissingDeclarationException: no declaration for element “EmployeeList”

    i dont know why its giving error of declaration.
    any help will be grateful.
    Thnaks

    Reply
    1. Daniel Barron

      Hola Smit,
      Tu error se debe a que te falta declarar el schema en tu documento xml, por ejemplo:

      saludos.

      Reply
  6. Sateesh

    Hi
    I have a requirement to escape json from the xml which would be like ” (double quotes) should be replaced by “\ and / should get replaced with \/, please confirm if any solution present in tibco bw 6x to implement this logic ??
    Thanks in advance

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *