jaxb; 2 schemas with common xs:import
Posted on 2006-07-08
I am using JAXB in my j2ee project.
I have two XML Schemas; Report.xsd and Graph.xsd
Both of these schemas import a common element defined in Query.xsd
I can generate the Java classes to represent these schemas using Jaxb an manipulate DOMs an so on, no problem.
The probelm is; I thought by having both Report and Graph import Query, that when I called:
graph.getQuery().get( 0 );
report.getQuery().get( 0 );
that I'd get back an object of type:
but what I actually get back is a:
depending on which object I called on.
This is frustrating because I expected both Report and Graph to use objects with the same interface so I could process the Query irrespective of whether it was a Report query or a Graph query.
The generated report.Query and graph.Query don't even implement any interface in common.
Could someone advise me how to achieve what I'm trying to do? Is there a way to tweak JAXB to do this?