XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Archie CampbellSubject: 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



Postnext
Ivan PedruzziSubject: Postsales qustion - Converting from flat file to xml with repeating items
Author: Ivan Pedruzzi
Date: 13 Oct 2006 01:14 PM
Hi Archie,

If you provide a full example of input document and the desired result and we can show how to approach the transformation.

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Postnext
Archie CampbellSubject: Postsales qustion - Converting from flat file to xml with repeating items
Author: Archie Campbell
Date: 13 Oct 2006 02:33 PM
Hi Ivan
I much appreciated your offer of help.
Hopefully the attached file better describes the situation.
Thanks


UnknownInvoice.txt
Source and destination files in one file

UnknownInvoiceSource.txt
Sample Source file

UnknownInvoiceDestination.txt
Sample Destination

Postnext
Ivan PedruzziSubject: Postsales qustion - Converting from flat file to xml with repeating items
Author: Ivan Pedruzzi
Date: 13 Oct 2006 03:41 PM

See attached solution

Ivan Pedruzzi
Stylus Studio Team


Unknowninvoice.zip

Postnext
Archie CampbellSubject: 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.


Much appreciate your assistance.
Thanks

Archie

Posttop
Archie CampbellSubject: 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 .....

Any thoughts would be appreciated.
Thanks

 
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.