users@jaxb.java.net

Problems with multiple root elements in same package

From: Russell Johns <johns_at_LANL.GOV>
Date: Wed, 23 Apr 2003 12:57:26 -0600

I have a jaxb project that uses 4 Schemas. 3 schemas each provide 1 root element; the fourth schema provides definitions of non root elements and
is included in the others. All of the schemas are in the same target namepace(xmlFoo), as are the java files(Xml.foo). the root elements are
 <foo-root1>
 <foo-root2>
 <foo-root3>

I recieve a SAXParseException for unexpected root 'foo-root1'when trying to load a file:
    ...
    JAXBContext fooCtxt= JAXBContext.newInstance("Xml.foo");
    Unmarshaller fooUnmarshaller = fooCtxt.createUnmarshaller();
    fooRoot1Doc = (FooRoot1) fooUnmarshaller.unmarshal(new FileInputStream(ROOT1_FILE_PATH));

    ...

the XJC is invoked through ant for all of the schemas simultaneously and the Xml.foo.ObjectFactory contains create methods for all roots:
    createFooRoot1()
    createFooRoot2()
    createFooRoot3()

Am I missing something here? do i need to make each root in its own package?

Thanks for any information or help you may have-