Thursday, November 17, 2011

How to convert CSV file to XML file using XSLT

Whenever the source system is sending the data in the mode of .csv files then for transformation purpose if the target expects in xml format, the below mentioned technique can be used.
In the sample code attached with this post , xslt code is given where it take csv input('file:///d:/abc.csv') and converts it into xml format. This is generic xslt which can be used to convert csv to xml format.
To download the XSLT please click here.

How to Pass XML as a parameter to XSLT in TIBCO

XSLT is extensively used in the areas where XML transformation is needed. Generally it is used to transfer one xml form to another. However if there are multiple XML’s and the output xml needs to be derived from the set of values in more than one xml’s then XSLT provides you the provision to pass the multiple XML’s as parameter to XSLT.
In this post we will take two XML’s and the output will be generated based on the values from both the XML.
Before implementing it in BW, in order to test in and debug properly let’s see how this can be done using any XSLT editor like Altova XML SPY. The two XML files used in the example are:-
Employee_Personal_Details.xml
Employee_Professional_Details.xml
The XSLT file ‘Transform_Editor.xslt’ is the XSLT used to transform the XML.
In order to do it in Tibco you will need a little modification in XSLT i.e. you need not to pass the parameter as ‘document’.
I have shared the sample BW code.
To download all the artifacts use in this post as a single zip file, click here.

Friday, November 11, 2011

How to Read a CSV file in Tibco BW having a Header, Body and trailer

Tibco BW provides a ‘Data format’ in order to parse/render the text data. However the palette has a limitation that it can read the file only if file has a fixed sequence.
However in general the CSV file contains a Header section which has the basic information like file creation date/time, number of records etc. The actual data will be present in the section called “Body” and then the last section known as “trailer”.
In order to read such a file in Tibco a small trick is needed.
Please note that you need to create three different data formats one for each header, body and trailer.
I have included the sample file and the BW project in this post. Download the zip file and import the same into BW. Let me know if you have any doubts in the sample included.
Comments/Questions are welcome.

Click here to download sample