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 10 11 12 13 14 15 16 17 18 19 20 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Vic ManfrediSubject: another csv conversion
Author: Vic Manfredi
Date: 23 Jun 2009 01:35 PM
Originally Posted: 23 Jun 2009 01:33 PM
Hello
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.

Thanks for your help.


Vic


Unknown2009-06-22_DSDI_Order_Activity.csv
csv order file

Unknownsalesorder.xml

Postnext
Alberto MassariSubject: another csv conversion
Author: Alberto Massari
Date: 26 Jun 2009 06:52 AM
Hi Vic,
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.

Hope this helps,
Alberto

Postnext
Vic ManfrediSubject: another csv conversion
Author: Vic Manfredi
Date: 26 Jun 2009 07:24 AM
Alberto

Yes it does. thanks. How would I handle the multiple line items? There is nothing to tell me in the file that the line item belongs to the same po as the previous line??

Thanks
Vic

Postnext
Alberto MassariSubject: another csv conversion
Author: Alberto Massari
Date: 26 Jun 2009 08:20 AM
Hi Vic,
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

<root>
{
for $po in distinct-values(/table/row/Purchase_Order)
return
<order number="{$po}">
{
for $line in /table/row[Purchase_Order=$po]
return $line/Product_Name
}
</order>
}
</root>

Hope this helps,
Alberto

Postnext
Vic ManfrediSubject: another csv conversion
Author: Vic Manfredi
Date: 26 Jun 2009 08:42 AM
Thanks again I tried it and get this error
[DataDirect][XQuery][err:XPDY0002]Error at line 3, column 28. No value has been bound to the context item.

Postnext
Alberto MassariSubject: another csv conversion
Author: Alberto Massari
Date: 26 Jun 2009 08:48 AM
Hi Vic,
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.

Alberto

Posttop
Vic ManfrediSubject: another csv conversion
Author: Vic Manfredi
Date: 26 Jun 2009 08:49 AM
Thanks again I tried it and get this error
[DataDirect][XQuery][err:XPDY0002]Error at line 3, column 28. No value has been bound to the context item.

 
Topic Page 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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.