|
next
|
 Subject: CSV to XML conversion Author: Tony Lavinio Date: 07 Apr 2006 02:36 PM
|
Without seeing your CSV data, it's hard to say exactly, but here are
a few ideas:
1. Regions are used for separating physical parts of the file - say
a fixed-size header from the body. Probably not what you want.
2. If the data lies on differnt rows, you can use the 'match patterns'
to select the rows, and each row matching a pattern can emit a
different set of XML elements.
3. If you need to create more complicated data, the easiest way is to
use XSLT. In fact, you don't even need Convert-to-XML for this, although
you can use it. We'll do two samples here:
3a. Build your Convert-to-XML map as close as you can. Then create an
XSLT transform or XQuery program that takes that .conv and your .csv
file as input and transforms it further. For the input, you'd use
something like this:
adapter:///myconverter.conv?file:///myfile.csv
3b. If your data really is just plan CSV, you can use the built-in
CSV adapter and pump the data through XSLT or XQUery. In that case,
you'd prefix your file name with 'adapter:CSV?' like this:
adapter:CSV?file:///myfile.csv
Instead of imbuing Convert-to-XML with the capabilities of creating
every possible XML layout, we decided to design it to create the
'XML equivalent' of the input format, and let XSLT and/or XQuery do
what _they're_ really good at.
If you'd like us to take a look at it, you could send a sample of the
.csv and the expected output to stylus-field-report@progress.com.
Does this help?
|
|
|