Transform XML to XML using XSLT
Hi folks!
I need some help/pointers to solve the following problem.
I have an XML file, which I would like to convert to a different layout/format and the output will be another XML file. I want to achieve this using XSLT. The input file structure is build using C# code in .Net platform. Once the tag structure is formed, it is fed to the XSLT for transformation and the transformed output is written to a file.
The input XML file looks exactly like this:
---------------------------------------
<ExportData>
- <Terminal>
- <Element>
<SPLC>234234789</SPLC>
<Name>Terminal234</Name>
<TCN />
<Address>1000 1st street</Address>
<Address>Suite 200</Address>
<City>NYC</City>
<State>NY</State>
<Country>USA</Country>
- <Product>
<ProductCode>A25</ProductCode>
<ProductName>Aviation Fuel - New</ProductName>
</Product>
- <Consignee>
- <Element>
<Number>103008</Number>
<Name>103008</Name>
</Element>
</Consignee>
</Element>
- <Element>
<SPLC>234234789</SPLC>
<Name>Terminal234</Name>
<TCN />
<Address>1000 1st street</Address>
<Address>Suite 200</Address>
<City>NYC</City>
<State>NY</State>
<Country>USA</Country>
- <Product>
<ProductCode>A30</ProductCode>
<ProductName>Premium gasoline</ProductName>
</Product>
- <Consignee>
- <Element>
<Number>12345678998765</Number>
<Name>New consignee</Name>
</Element>
</Consignee>
</Element>
</Terminal>
</ExportData>
----------------------------------------
and I need to convert the above XML to another XML which should look like the following:
<ExportData>
-<Terminal>
-<Element>
<SPLC>234234789</SPLC>
<Name>Terminal234</Name>
<TCN />
<Address>1000 1st street</Address>
<Address>Suite 200</Address>
<City>NYC</City>
<State>NY</State>
<Country>USA</Country>
- <Product>
-<Element>
<ProductCode>A25</ProductCode>
<ProductName>Aviation Fuel - New</ProductName>
</Element>
-<Element>
<ProductCode>A30</ProductCode>
<ProductName>Premium gasoline</ProductName>
</Element>
</Product>
-<Consignee>
-<Element>
<Number>103008</Number>
<Name>103008</Name>
</Element>
-<Element>
<Number>12345678998765</Number>
<Name>New consignee</Name>
</Element>
</Consignee>
</Element>
</Terminal>
</ExportData>
---------------------------------
Please help me to write an XSLT, which can perform the above explained task.
Thanks in advance.
|