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.


[EMAIL PROTECTED] 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

Reply via email to