Subject:another csv conversion Author:Vic Manfredi Date:23 Jun 2009 01:35 PM Originally Posted: 23 Jun 2009 01:33 PM
Great program. If it does what I am trying to accomplish I have my credit card out and am ready to buy. The attached CSV is what I need to convert. Can I convert it to an existing XML format or do i need to convert it to xml first then do an xquery map. Which would be fine. The big issue is that there are multiple line items on this order how would i set that up in the converter.
Subject:another csv conversion Author:(Deleted User) Date:26 Jun 2009 06:52 AM
the usual path is to have the CSV converted into XML by using the DataDirect XML Converter module and then rearrange it and complete it by using either XSLT or XQuery.
So, in Stylus Studio, create a new XSLT or XQuery, then specify the input source by doing:
- open the File Open Dialog by clicking on the "..." button
- locate and select the CSV file
- check the Open Using XML Converter
- press OK
- select the "Comma Separated Values (CSV)" entry in the left pane, change the value for the property "First row contains field names" to "yes"
- press OK
At this point you can write the mapping code (by using the text editor or the Mapper interface) as the CSV were a normal XML document.
Subject:another csv conversion Author:(Deleted User) Date:26 Jun 2009 08:20 AM
in a CSV file every line is assumed to be a single record; there is no support for specifying that they are part of a bigger structure, unless the data itself has a way to say that.
In your case, the first column contains the Purchase Order number; the last three entries share the same value, so you can group them.
As an example, this XQuery will lists the products in the CSV grouped by their order number
for $po in distinct-values(/table/row/Purchase_Order)
for $line in /table/row[Purchase_Order=$po]
Subject:another csv conversion Author:(Deleted User) Date:26 Jun 2009 08:48 AM
you need open the Scenario Dialog, click on the "..." button next to the "Main Input" edit box and do the steps outlined before so that the converted CSV is loaded and assigned to the default context item.