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
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Lance MerrifieldSubject: How to handle variable input & output in xquery
Author: Lance Merrifield
Date: 06 Jun 2008 11:09 AM
I am currently working with your product to convert X12 data to xml and utilize xquery to select the required fields from the xml file and then produce a comma delimited file from the xml. I am having difficulty during the conversion from xml to delimited as there are variable occurences of certain fields within the xml file. I am getting the following error message:

Error: I/O error while converting data in ConvertFromXML node 'Convert from XML': 4,0: A new element <HI0202> was seen on a row other than the first, but the field headings have already been written to the output file

Is there a way to predefine the max number of occurences for a field and have them null filled in the delimited file if they do not occur. Thanks.

Lance

Posttop
Tony LavinioSubject: How to handle variable input & output in xquery
Author: Tony Lavinio
Date: 06 Jun 2008 03:38 PM
You don't actually need the converter to write text from XQuery.
Instead you can use
declare option ddtek:serialize "method=text";
<y> {
for $i in ('abc', 'def', 'ghi', 'jkl')
return <x>{$i}&#10;</x>
}
</y>

Then you can write whatever you want.

What the converter does, which causes the error you are seeing, is
buffer a complete line. This allows you to write the elements in any
order for a row, but they will always be output in the same order as
the first row.

So for the converter, if you write <a>123</a><b>456</b> on line one
and <b>def</b><a>abc</a> on line two, you'll actually get:

123456
abcdef

because it will reorder the fields. In order to do this, it has to
build a template based on the first line output.

But since you are controlling your output completely, you can just
write text directly from DataDirect XQuery.

 
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.