I discovered an arguably simpler method for doing this (even with the
beta1 version I have).

What I do is Create another DO using DataObject DO  =
DataFactory.INSTANCE.createDataObject("CUSTOMER");

Then I create a sub-DO:  DO.CreateDataObject("CUSTOMERSUB");

I then modified the .xsd file to show min DO's = 1, since each row of
the result is in a DO that is a child to the main DO "DO", they are all
in the same XML file.

If it is of any use to anyone else. :)

> -----Original Message-----
> From: Amita Vadhavkar [mailto:[EMAIL PROTECTED]
> Sent: Friday, September 07, 2007 8:16 AM
> To: tuscany-user@ws.apache.org
> Subject: Re: RDB DAS read, then write XML file for data export
> 
> Please see our nightly build if you can download from there - (last
> successful is on Sep 5th)
>
http://incubator.apache.org/tuscany/tuscany-downloads-documentations.htm
l
> 
>
http://vmbuild.apache.org:8080/continuum/workingCopy.action?projectId=36
&p
>
rojectName=Apache+Tuscany+DAS+Implementation+project&userDirectory=distr
ib
> ution/binary/target
> 
> For having all customer records in one xml file -
> you are using the same stream in a loop to write each serialized data
> object. But I guess you will need to a bit of file manipulation to
remove
> repeated headers like below,
> <?xml version="1.0" encoding="ASCII"?>
>  <cust1:cust1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> 
> >  xmlns:cust1="cust1"
> >
xmlns:this="http:///org.apache.tuscany.das.rdb.test/customer.xsd";
> >  xsi:type="this:Customer">
> 
> 
> 
> Or  you can loop through all DO records as of now, but instead of
directly
> serializing each DO
> in XML, do getInt("ID"), getString("LASTNAME"),.... in a file - OR
> if you are using static SDO approach (i.e. have say customer.xsd and
use
> static SDO APIS)
> CUSTOMET.getId(), CUSTOMER.getLastName()...
> 
> But I am not sure about any simpler alternative right now.
> 
> Regards,
> Amita
> 
> On 9/7/07, Eborn, Eric D <[EMAIL PROTECTED]> wrote:
> >
> > I am using beta1.  However, the proxy I connect through disallows
> > external SVN servers.  Is there an HTTP download of the trunk
binary?
> >
> > That xml output looks good, except, is it possible to have it
display
> > all 4 customer records in the single XML file?
> >
> > > -----Original Message-----
> > > From: Amita Vadhavkar [mailto:[EMAIL PROTECTED]
> > > Sent: Thursday, September 06, 2007 11:25 PM
> > > To: tuscany-user@ws.apache.org
> > > Subject: Re: RDB DAS read, then write XML file for data export
> > >
> > > Hi ,
> > > Will you please try the example with latest SDO and DAS code from
svn
> > > trunk,
> > >
> > > There are some differences in DAS-beta1 (older releases) and the
> > current
> > > one
> > > from
> > > https://svn.apache.org/repos/asf/incubator/tuscany/java/. These
> > > differences
> > > are due to some
> > > changes in SDO. With the latest one, I am getting something like
> > below-
> > > for
> > >
> >
System.out.println(XMLHelper.INSTANCE.save(((DataObject)customers.iterat
> > or
> > > ().next()),
> > > "cust1", "cust1"));
> > >
> > > Result -
> > >
> > > <?xml version="1.0" encoding="ASCII"?>
> > > <cust1:cust1 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > xmlns:cust1="cust1"
> > >
xmlns:this="http:///org.apache.tuscany.das.rdb.test/customer.xsd";
> > > xsi:type="this:Customer">
> > >   <ID>1</ID>
> > >   <lastName>Williams</lastName>
> > >   <address>1212 foobar lane</address>
> > > </cust1:cust1>
> > >
> > > Are you using DAS-beta1?
> > >
> > > Regards,
> > > Amita
> > > On 9/6/07, Eborn, Eric D <[EMAIL PROTECTED]> wrote:
> > > >
> > > > I came across this excellent article about how to do basics with
SDO
> > > > including writing out a datagraph to an XML document.
> > > >
> > > >
> >
http://www.ibm.com/developerworks/xml/library/ws-sdoxmlschema/index.html
> > > >
> > > > What I wish to do is similar, I wish to read data from a MySQL
> > database
> > > > using RDB DAS and then store that information into an XML file
using
> > > > XMLHelper (I suppose this is the preferred way).  This XML data
will
> > > > eventually be destined for a JMS message for export to its
> > destination.
> > > >
> > > > I'm building off of the sample Customers for now until I get a
> > working
> > > > model...
> > > >
> > > > So far I've added this code to my Customer sample code:
> > > >
> > > >         private void outputXML() throws Exception {
> > > >
> > > >          Command readAll = das.getCommand("AllCustomers");
> > > >          CUSTOMER = readAll.executeQuery();
> > > >          DataObject resultSet =
> > > > DataFactory.INSTANCE.create(RES_NAMESPACE, "resultSetType");
> > > >
> > > >                 OutputStream stream = new
FileOutputStream(RES_XML);
> > > >
> > > >                 List allCustomers =
CUSTOMER.getList("CUSTOMER");
> > > >                 int i = 1;
> > > >                 for(i=0; i<allCustomers.size(); i++)
> > > >                 {
> > > >
> > > > XMLHelper.INSTANCE.save((DataObject)allCustomers.get(i),
> > RES_NAMESPACE,
> > > > "CUSTOMER", stream);
> > > >                         stream.write(13);
> > //writes
> > > > a carraige return to the XML file.
> > > >                         stream.write(10);
> > > >                 }
> > > >
> > > >         }
> > > >
> > > > This does generate an XML file, but its contents are all
wrong...  I
> > > > want it to follow the XSD:
> > > >
> > > > <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> > > >     xmlns="http://www.example.com/RESULTSET";
> > > > targetNamespace="http://www.example.com/RESRESULTSET";>
> > > >
> > > >     <xsd:element name="CUSTOMER" type="resultSetType"/>
> > > >
> > > >     <xsd:complexType name="resultSetType">
> > > >         <xsd:sequence>
> > > >             <xsd:element name="LASTNAME" type="xsd:string"/>
> > > >             <xsd:element name="ADDRESS" type="xsd:string"/>
> > > >             <xsd:element name="ID" type="xsd:positiveInteger"/>
> > > >         </xsd:sequence>
> > > >     </xsd:complexType>
> > > >
> > > > </xsd:schema>
> > > >
> > > > But my program outputs:
> > > > <?xml version="1.0" encoding="ASCII"?>
> > > > <resSS:CUSTOMER
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > > xmlns:das="http:///org.apache.tuscany.das.rdb/das";
> > > >     xmlns:resSS="http://www.example.com/resSS";
> > xsi:type="das:CUSTOMER"
> > > >     ID="1" LASTNAME="John" ADDRESS="USA"/>
> > > > <?xml version="1.0" encoding="ASCII"?>
> > > > <resSS:CUSTOMER
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > > xmlns:das="http:///org.apache.tuscany.das.rdb/das";
> > > >     xmlns:resSS="http://www.example.com/resSS";
> > xsi:type="das:CUSTOMER"
> > > >     ID="2" LASTNAME="BlueBerry" ADDRESS="INDIA"/>
> > > > <?xml version="1.0" encoding="ASCII"?>
> > > > <resSS:CUSTOMER
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > > xmlns:das="http:///org.apache.tuscany.das.rdb/das";
> > > >     xmlns:resSS="http://www.example.com/resSS";
> > xsi:type="das:CUSTOMER"
> > > >     ID="3" LASTNAME="Patrick" ADDRESS="UK"/>
> > > > <?xml version="1.0" encoding="ASCII"?>
> > > > <resSS:CUSTOMER
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > > xmlns:das="http:///org.apache.tuscany.das.rdb/das";
> > > >     xmlns:resSS="http://www.example.com/resSS";
> > xsi:type="das:CUSTOMER"
> > > >     ID="4" LASTNAME="Jane" ADDRESS="UN"/>
> > > > <?xml version="1.0" encoding="ASCII"?>
> > > > <resSS:CUSTOMER
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> > > > xmlns:das="http:///org.apache.tuscany.das.rdb/das";
> > > >     xmlns:resSS="http://www.example.com/resSS";
> > xsi:type="das:CUSTOMER"
> > > >     ID="5" LASTNAME="Jenny" ADDRESS="USA"/>
> > > >
> > > > I'm hoping that someone has done something similar and could
point
> > me in
> > > > the right direction because at the moment im generating content
for
> > 5
> > > > different xml files into one file, when I'd like to have all the
> > rows of
> > > > data contained in one xml file in the format:
> > > >
> > > > <XML>
> > > > <CUSTOMER>
> > > >         <ID>1</ID>
> > > >         <LASTNAME>John</LASTNAME>
> > > >         <ADDRESS>USA</ADDRESS>
> > > > </CUSTOMER>
> > > > <CUSTOMER>
> > > >         <ID>2</ID>
> > > >         <LASTNAME>Blueberry</LASTNAME>
> > > >         <ADDRESS>India</ADDRESS>
> > > > </CUSTOMER>
> > > >
> > > > Etc...
> > > >
> > > > Thanks
> > > > Eric
> > > >
> > > >
> >
---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> >
> >
---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to