users@jaxb.java.net

Re: how to refer to a common schema without duplicating entries found in the common namespace

From: Jean-Marie Condom <jmc_at_meteorage.com>
Date: Mon, 07 Feb 2005 19:29:08 +0100

i have a common schema called common.xsd whose defined types
are refered (and not redefined) in other schemas such as for instance A
and B ;

my purpose is to generate only one set of classes (those from common.xsd)

the pb is that if A and B refer to common.xsd, compiling A and B will
generate
classes refered in A and B and defined in common.xsd ; i tried with
<xsd:include
i get the same duplication

for instance common.xsd contains the following type :
<!-- parity-->
<xsd:simpleType name="parityType">
  <xsd:annotation>
    <xsd:appinfo>
      <jaxb:typesafeEnumClass name="parityType">
        <jaxb:typesafeEnumMember name="NONE" value="NONE"/>
        <jaxb:typesafeEnumMember name="EVEN" value="EVEN"/>
        <jaxb:typesafeEnumMember name="ODD" value="ODD"/>
        <jaxb:typesafeEnumMember name="MARK" value="MARK"/>
        <jaxb:typesafeEnumMember name="SPACE" value="SPACE"/>
      </jaxb:typesafeEnumClass>
    </xsd:appinfo>
  </xsd:annotation>
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="NONE"/>
    <xsd:enumeration value="EVEN"/>
    <xsd:enumeration value="ODD"/>
    <xsd:enumeration value="MARK"/>
    <xsd:enumeration value="SPACE"/>
  </xsd:restriction>
</xsd:simpleType>

in A and B i may refer to parityType defining an attribute such as :

  <xsd:attribute name="parity" type="parityType" use="required"/>

whether i use <xsd:import or <xsd:include, if i compile A and B
parityType.class is generated twice

is there a way to generate classes from that common schema only once ?

Jean-Marie




Kohsuke Kawaguchi wrote:

> Jean-Marie Condom wrote:
>
>> thanks ; i had tried this instruction also but the problem is
>> the duplication of common classes under
>> meteorage/jobs/params/configuration when compiling
>> configuration_test.xsd (whose namespace is
>> meteorage/jobs/params/configuration)
>> and that imports common.xsd
>>
>> those classes are already under meteorage/jobs/params/commons
>> after having compiled common.xsd (whose namespace is
>> meteorage/jobs/params/common)
>
>
> I'm bit confused. You are saying that the same schema produces two
> sets of classes?
>
> I suspect what you might really want is to use <xsd:include> as
> opposed to <xsd:import>.
>
> Otherwise, if you intentionally defined identical schema definitions
> in two namespaces, then the JAXB has to generate two sets of classes,
> too. After all, they might look similar, but they are different ---
> they belong to different namespaces.
>
>


-- 
Jean-Marie Condom
Software development team
Sté Météorage
2 av Angot
64053 PAU
France