Hi,
I'm using the schemagen Ant task to generate a set of XSD files from a
set of JAXB 2.0 mapped packages/classes. I've properly annotated the
packages/classes with the necessary XmlSchema/XmlType/XmlElement
annotation and everything works great. I'm able to control the name of
the schema files produce with the Ant task properly. The one problem I
was having was that if I had a class/complexType in package/namespace B
that derived from a base class/complexType in package/namespace A, the
B.xsd file did *not* have a xs:import line generated to import the
definitions from namespace A. It would however properly generate the
xs:import if there was a containment relationship of a type in B to a
type in A.
I dug through the source code and found what I believe is the cause of
this issue. In the class:
com/sun/xml/bind/v2/schemagen/XmlSchemaGenerator.java
at ~ line 211 is the following code:
// recurse on baseTypes to make sure that we can refer to them in the
schema
ClassInfo<T,C> bc = clazz.getBaseClass();
if (bc != null) {
add(bc);
}
I modified this as follows to fix this issue:
// recurse on baseTypes to make sure that we can refer to them in the
schema
ClassInfo<T,C> bc = clazz.getBaseClass();
if (bc != null) {
add(bc);
n.addDependencyTo(bc.getTypeName());
}
I *think* this will ensure that derivation relationships to other types
will cause imports to be generated to the other types namespace. I've
tried this out in my own environment and it did fix the issue. If you
agree that this is indeed a bug, can this fix be incorporated in your
next release?
Thanks,
Dave
--