Showing posts with label XSLT. Show all posts
Showing posts with label XSLT. Show all posts

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.