Hi there,
I have 2 jars generated with scomp. In one of them, all the class names
are postfixed to avoid clashing with class names from the other one
(because their respective schemas have the same names for top level
elements, and no namespace).
Now, trying to parse in the usual way leads to a ClassCastException, as is
described in earlier threads in this newsgroup :
TopLevelElementDocumentPostFix toplevel = TopLevelElementDocumentPostFix
.Factory.parse ( xml );
OK, so to avoid this exception I tried using a SchemaTypeLoader telling it
which jar to use, as follows :
File[ ] schemaPath = { new File (
"the-path-to-the-jar/xmltypes-postfixed.jar" ) } ;
SchemaTypeLoader stl = XmlBeans.typeLoaderForResource (
XmlBeans.resourceLoaderForPath ( schemaPath ) ) ;
stl = XmlBeans.typeLoaderUnion ( new SchemaTypeLoader [ ] {
XmlBeans.getBuiltinTypeSystem ( ), stl } ) ;
System.out.println (
TopLevelElementDocumentPostFix.type.toString ( ) ) ;
TopLevelElementDocumentPostFix toplevel = (
TopLevelElementDocumentPostFix )stl.parse ( xml ,
TopLevelElementDocumentPostFix.type , null ) ;
This last line gives a ClassCastException.
The output from the System.out is the string "D=topLevel" (i.e. the name
of the top level element in my xml document).
Does anyone see what I am doing wrong ?
thank you very much,
Heikki Doeleman