users@jaxb.java.net

Re: Schemagen issue with type in one namespace depending on base types in another namespace

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 25 Sep 2006 16:06:20 -0700

Thanks! The change looks good. To incorporate this to the source code, I
need to ask you to sign the SCA.

Please take a look at [1], send it to us, and let me know so that I can
proceed.


[1] https://glassfish.dev.java.net/public/GovernancePolicy.html#SCA_Policy

David White wrote:
> 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
>
> --
>
>
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com