I am are trying to convert an CSV (comma separated file) into XML. For this, I am coding an XSLT template and this is my 1st try at XSLT...
CSV sample:
ClaimRef,HandlerRef,ClaimType,Date,Area,SettleDate,ClaimStatus,ClaimantName
1,1/1,Liability,08-12-2013,US,23-05-2014,Closed,Mark
2,1/2,Liability,08-10-2013,UK,23-02-2014,Closed,John
Desired XML Output format:
<Claims>
<Claim>
<ClaimRef></ClaimRef>
<HandlerRef></HandlerRef>
<ClaimType></ClaimType>
<Date></Date>
<Area></Area>
<SettleDate></SettleDate>
<ClaimStatus></ClaimStatus>
<ClaimantName></ClaimantName>
</Claim>
</Claims>
I used http://blogs.msdn.com/b/kaevans/archive/2003/04/17/5780.aspx as initial start and http://xslttest.appspot.com/ to test the results. But this article mentions how to get the values as <row><elem>, etc
.
Please can you guide me how to code an XSLT to generate above XML based on sample CSV data.
Here's an XSLT 2.0 option...
CSV Input (so.csv referenced in the
csv-uri
param.)XSLT 2.0 (Use either a well-formed dummy XML doc or the stylesheet itself as input or specify
csv2xml
as the initial template.)XML Output
Update per comment...
Here is the same example, but using a variable instead of an external CSV file. You can use this XSLT to test in other online test tools that support XSLT 2.0.
Example on xsltransform.net