Hi Roman, that should work out of the box. When you used the XML code generator to generate the Java classes from your XML schema, it produced (so-called) descriptor classes as well. Did you compile those as well, and are these available on your classpath as well ?
Regards Werner Guttmann Roman Klaehne wrote: > Hi, > > > I am using the Castor Source Code Generator together with Castor > Unmarshaller. > > For the simple XML schema: > > ******************************************************************* > <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" > elementFormDefault="qualified" attributeFormDefault="unqualified"> > <xs:element name="root"/> > <xs:element name="element"/> > </xs:schema> > ******************************************************************* > > I have such a binding file: > > ************************************************** > <binding defaultBindingType="type"> > <elementBinding name="root"> > <java-class name="RootXml"/> > </elementBinding> > <elementBinding name="element"> > <java-class name="ElementXml"/> > </elementBinding> > </binding> > ************************************************** > > After generating the source code for the schema using the binding file > above I want to unmarshall XML sources to the repective Java classes. > > When doing > > *************************************************** > Unmarshaller u = new Unmarshaller(RootXml.class) > Object o = u.unmarshal(reader) > *************************************************** > > the object o is correctly unmarshalled and is an instance of class > RootXml (as it should be). > > But when using the default constructor of Unmarshaller (without giving > the root class RootXml.class) I get the following error message: > > "The class for the root element 'root' could not be found." > > My intention is to have XML documents with root elements "<root>" or > "<element>" and when calling Unmarshaller.unmarshal() I don't know the > type of the XML source (root or element). That means I want to do the > following: > > **************************************** > Unmarshaller u = new Unmarshaller(); > Object o = u.unmarshal(); > > if(o instanceof RootXml) { > doRoot(); > } > else if(o instanceof ElementXml) { > doElement(); > } > **************************************** > > Do you have any ideas to get this working? > > > Thanks in advance and best regards > /Roman Klähne > (ZIB Berlin) > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

