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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
- Stylus Studio Code Samples & Utilities (364)
-> + create an xml document with ex... (2)
-> + Default xml converter from com... (2)
-> + Transforming Data With XSLT (5)
-> + Error when creating pdf file (5)
-> + Got Shkespear XML Doc from web... (3)
-> + VFP 8 (2)
-> + CSV import (7)
-> + Generating X12 from XML (4)
-> - How to handle variable input &... (2)
-> ->How to handle variable in...
-> + Grab html to xml (2)
-> + XML To X12 conversion using in... (3)
-> + XSLT mapping help required (2)
-> + convert XML to JAVA (2)
-> + Insert a carriage return or li... (3)
-> + Automatation for comparing two... (2)
-> - Filter records (1)
-> + BIT Fields (3)
-> + Restricted Mixed Content (4)
-> - Freelance Project - Mapping di... (1)
-> + flat file to xml conversion (10)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio Announcements (113)
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.

   
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.