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
Phillip AnkersonSubject: convert text to xml from more than one source?
Author: Phillip Ankerson
Date: 21 Aug 2008 12:12 PM
I have watched the video tutorial on how to create a customer xml converter for a text file, and have done that with a relatively simple text file. I need to read from more than one source (perhaps two text files - one for customers and one for addresses) or a database file, and create and xml file according to a spec I was given. Is this something that must be done with XQuery, or can it be done at all? We are creating an interface with Websphere...is there a pre-defined connector for this?

Example:
source 1 - customer
name1,status,logonID1,companyName
name2,status,logonID2,companyName
name3,status,logonID3,companyName

source 2 - address
addresstype,zipcode,phone1,email1,firstName,LastName,address1,city,state
addresstype,zipcode,phone1,email1,firstName,LastName,address1,city,state
addresstype,zipcode,phone1,email2,firstName,LastName,address1,city,state
addresstype,zipcode,phone1,email3,firstName,LastName,address1,city,state

logonId = email; notice there could be more than one address per user


Posttop
Minollo I.Subject: convert text to xml from more than one source?
Author: Minollo I.
Date: 21 Aug 2008 12:47 PM
You can do that with XQuery, yes; joining data across multiple XML and/or non-XML files and/or database tables. In your case, something similar to this (using the built-in CSV converter; if the format is CSV, you don't need to create a custom one):
<root> {
for $row1 in doc("converter:CSV?c:/file1.csv")//row,
$row2 in doc("converter:CSV?c:/file2.csv")//row
where $row1/column.2 = $row2/column.3
return
<data>
<somedata>{$row1/column.0/text()}</somedata>
<moredata>{$row2/column.0/text()}</moredata>
</data>
} </root>

If the first row of the CSV contains "field names", then it's even easier, and you can get better element names in the output using "converter:CSV:first=yes?...". If you want to share some real example, we can create a sample XQuery for you.

You can integrate DataDirect XQuery/XML Converters in any Java application; so, you can surely integrate that in your WebSphere application. We do have an XQuery based servlet implementation (with sources available) that can expose virtually any XQuery as a Web service without any additional code; and it's compatible with WebSphere (see http://www.xquery.com/examples/web-service-example/xquerywebservice/).

 
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.