Subject:Postsales qustion - Converting from flat file to xml with repeating items Author:Archie Campbell Date:13 Oct 2006 12:57 PM
I would like to create an XSLT file that will convert from XML to XML where:
the destination looks like
<invoiceLine>
<description>5 All Season Tires</description>
<amount>400.02</amount>
</invoiceLine>
<invoiceLine>
<description>A car with 5 wheels</description>
<amount>20400.00</amount>
</invoiceLine>
and the source looks like
<description01>5 All Season Tires</description01>
<amount01>400.02</amount01>
<desription02>A car with 5 wheels</description02>
<amount02>20400.00</amount02>
The invoice can have up to 15 lines.
Questions:
1. Can this type of conversion be done with XSLT?
2. Any suggestions of what I can look at to learn how to do this?
Thanks
ps I am now a happy owner of StylusStudio Enterprise Edition
Subject:Postsales qustion - Converting from flat file to xml with repeating items Author:Archie Campbell Date:13 Oct 2006 05:17 PM
Thanks Ivan
To handle the maximum of 15 lines I suppose I would define all 15 and then if there were only 3 there would be a lot of tags with null values - no problem.
Is there any way of saying that the fields that end in nn where nn is 01 or 02 or .. are a group so that it would generate the <InvoiceLine> ... </InvoiceLine> tags as required. This way you would define one set and it would output as many as occur in the source.
My guess is not, but I just have to ask.
Subject:Postsales qustion - Converting from flat file to xml with repeating items Author:Archie Campbell Date:14 Oct 2006 01:35 AM
I used the InvoiceSource and InvoiceDestination file I used StylusStudio to create the xsl file same as the one you created. It worked real nice. Once I noticed that I could right-Click on the Destination "InvoiceLine" item and click "Duplicate Node" it was all downhill from there. Quite click actually. I was impressed.
Then I tried to do a transformation in the opposite direction, where the "Source Document" was "InvoiceDestination.xml" and the "Destination Document" was "InvoiceSource.xml".
I tried to right-Click on the now Source "InvoiceLIne" item and there was no "Duplicate Node" option.
I am thinking that I want some sort of repeat thing but .....