Subject:Dynamic CSV to XML Author:Martin Börlin Date:03 Oct 2006 10:42 AM
Hi!
I work in a project where we need to convert CSV files (no format defined yet) to a given XML format.
The CSV will have to be dynamic (yes, I know: why don't you use XML, this is like inventing another XML clone...) and an idea to make them dynamic is to prefix each line and then use a "proper" line-oriented comma separated values for each line, based on the prefix. I.e. in my example below the line starting with "order" must have no other fields on that line, the line starting with "customer" must have 8 fields where field number 2 is a first name, field 3 is a last name etc. The "order" ends when a new "order" line is found.
Is it possible to define this using Stylus Studio, and if so; how? Any comments/suggestions about my 30-seconds-dynamic-CSV-fomat is appreciated!
Subject:Dynamic CSV to XML Author:Martin Börlin Date:04 Oct 2006 02:07 AM
Hi Tony, and thanks for your reply!
I'm new to Stylus Studio so could you please expand your ideas of how to solve my problem? Can I generate Java code so I can use it on the fly from a web app?
Thanks
-Martin
>It can be done without much
>difficulty.
>
>I'd use the CSV adapter to
>read in the data, and a piece
>of
>XSLT using grouping to sort it
>out.
Subject:Dynamic CSV to XML Author:Tony Lavinio Date:09 Oct 2006 09:30 AM
Okay, here it is.
We use Convert-to-XML to read in the original file and convert it
into a 'flat' XML file.
Then we use XSLT to group the customer and various product records
under each order.
To run this, just open the .conv file in Stylus Studio and press the
green triangle. The input is already set to come through the Convert
to XML module (which you can see in the scenario editor).
martin.csv The comma-separated-value raw input file