You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@tuscany.apache.org by Gr...@emc.com on 2008/11/04 22:11:24 UTC
SDO Newbie question
Hi guys:
Quick question about using the classes generated by XSD2JavaGenerator.
I have used this tool to generate a set of Java interfaces and impl
classes corresponding to an XSD. All seems fine.
What I am missing is the pattern that guides me how to deserialize an
XML document (from the file system or any other XMLReader) into a graph
of Java instances of the type(s) generated from my XSD by the
XSD2JavaGenerator.
The factory method generated did not have any method that looked like
"readFromXML(XMLReader foo)" or any equivalent deserialization
mechanism.
Any help, sample code snippets etc. would be appreciated.
sgg
RE: SDO Newbie question
Posted by Gr...@emc.com.
Thanks Luciano. I am not sure why I couldn't find these samples amongst
the src download.
Frank supplied the clue to get me past this problem.
sgg
-----Original Message-----
From: Luciano Resende [mailto:luckbr1975@gmail.com]
Sent: Tuesday, November 04, 2008 4:24 PM
To: user@tuscany.apache.org
Subject: Re: SDO Newbie question
You could look into the following SDO example to help with that [1] .
Looks like what you are looking for is in the sample base utility
class [2].
[1]
https://svn.apache.org/repos/asf/tuscany/java/sdo/sample/src/main/java/o
rg/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java
[2]
https://svn.apache.org/repos/asf/tuscany/java/sdo/sample/src/main/java/o
rg/apache/tuscany/samples/sdo/SampleBase.java
On Tue, Nov 4, 2008 at 1:11 PM, <Gr...@emc.com> wrote:
> Hi guys:
> Quick question about using the classes generated by XSD2JavaGenerator.
>
> I have used this tool to generate a set of Java interfaces and impl
> classes corresponding to an XSD. All seems fine.
>
> What I am missing is the pattern that guides me how to deserialize an
> XML document (from the file system or any other XMLReader) into a
graph
> of Java instances of the type(s) generated from my XSD by the
> XSD2JavaGenerator.
>
> The factory method generated did not have any method that looked like
> "readFromXML(XMLReader foo)" or any equivalent deserialization
> mechanism.
>
> Any help, sample code snippets etc. would be appreciated.
>
> sgg
>
--
Luciano Resende
Apache Tuscany, Apache PhotArk
http://people.apache.org/~lresende
http://lresende.blogspot.com/
Re: SDO Newbie question
Posted by Luciano Resende <lu...@gmail.com>.
You could look into the following SDO example to help with that [1] .
Looks like what you are looking for is in the sample base utility
class [2].
[1] https://svn.apache.org/repos/asf/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/basic/ReadPurchaseOrder.java
[2] https://svn.apache.org/repos/asf/tuscany/java/sdo/sample/src/main/java/org/apache/tuscany/samples/sdo/SampleBase.java
On Tue, Nov 4, 2008 at 1:11 PM, <Gr...@emc.com> wrote:
> Hi guys:
> Quick question about using the classes generated by XSD2JavaGenerator.
>
> I have used this tool to generate a set of Java interfaces and impl
> classes corresponding to an XSD. All seems fine.
>
> What I am missing is the pattern that guides me how to deserialize an
> XML document (from the file system or any other XMLReader) into a graph
> of Java instances of the type(s) generated from my XSD by the
> XSD2JavaGenerator.
>
> The factory method generated did not have any method that looked like
> "readFromXML(XMLReader foo)" or any equivalent deserialization
> mechanism.
>
> Any help, sample code snippets etc. would be appreciated.
>
> sgg
>
--
Luciano Resende
Apache Tuscany, Apache PhotArk
http://people.apache.org/~lresende
http://lresende.blogspot.com/
RE: SDO Newbie question
Posted by Gr...@emc.com.
Hi Frank:
Thanks for the quick response. My problem was that I was doing a new on
the generated factory, not using the singleton pattern implemented by
.INSTANCE.
sgg
-----Original Message-----
From: Frank Budinsky [mailto:frankb@ca.ibm.com]
Sent: Tuesday, November 04, 2008 4:47 PM
To: user@tuscany.apache.org
Subject: Re: SDO Newbie question
You can take a look at SimpleStaticTestCase in the tools-test project
for
a simple example:
https://svn.apache.org/repos/asf/tuscany/java/sdo/tools-test/src/test/ja
va/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
The first thing that you need to do is make sure the metadata is
registered. Your generated factory class has a register method that you
need to call:
scope = SDOUtil.createHelperContext();
SimpleFactory.INSTANCE.register(scope);
Once you've registered the metada, you can load an instance using the
standard SDO load API: XMLHelper.load().
XMLDocument xml = scope.getXMLHelper().load(source, null, null);
assertTrue("Root element is not an instance of the generated class",
xml
.getRootObject() instanceof Quote);
I hope this helps.
Frank.
Graham_Steveg@emc.com wrote on 11/04/2008 04:11:24 PM:
> Hi guys:
> Quick question about using the classes generated by XSD2JavaGenerator.
>
> I have used this tool to generate a set of Java interfaces and impl
> classes corresponding to an XSD. All seems fine.
>
> What I am missing is the pattern that guides me how to deserialize an
> XML document (from the file system or any other XMLReader) into a
graph
> of Java instances of the type(s) generated from my XSD by the
> XSD2JavaGenerator.
>
> The factory method generated did not have any method that looked like
> "readFromXML(XMLReader foo)" or any equivalent deserialization
> mechanism.
>
> Any help, sample code snippets etc. would be appreciated.
>
> sgg
Re: SDO Newbie question
Posted by Frank Budinsky <fr...@ca.ibm.com>.
You can take a look at SimpleStaticTestCase in the tools-test project for
a simple example:
https://svn.apache.org/repos/asf/tuscany/java/sdo/tools-test/src/test/java/org/apache/tuscany/sdo/test/SimpleStaticTestCase.java
The first thing that you need to do is make sure the metadata is
registered. Your generated factory class has a register method that you
need to call:
scope = SDOUtil.createHelperContext();
SimpleFactory.INSTANCE.register(scope);
Once you've registered the metada, you can load an instance using the
standard SDO load API: XMLHelper.load().
XMLDocument xml = scope.getXMLHelper().load(source, null, null);
assertTrue("Root element is not an instance of the generated class",
xml
.getRootObject() instanceof Quote);
I hope this helps.
Frank.
Graham_Steveg@emc.com wrote on 11/04/2008 04:11:24 PM:
> Hi guys:
> Quick question about using the classes generated by XSD2JavaGenerator.
>
> I have used this tool to generate a set of Java interfaces and impl
> classes corresponding to an XSD. All seems fine.
>
> What I am missing is the pattern that guides me how to deserialize an
> XML document (from the file system or any other XMLReader) into a graph
> of Java instances of the type(s) generated from my XSD by the
> XSD2JavaGenerator.
>
> The factory method generated did not have any method that looked like
> "readFromXML(XMLReader foo)" or any equivalent deserialization
> mechanism.
>
> Any help, sample code snippets etc. would be appreciated.
>
> sgg