Hi Kevin Schema doesn't allow "multiple inheritance" i.e. when you do <restriction base="XXX" > or <extension base="XXX" > there is only 1 XXX. So I don''t think there's any way to immediately "inherit" both Type1 and Type2.
Also <all> causes problems. You are not allowed to put one <all> inside another <all> (see http://www.w3.org/TR/xmlschema-1/#cos-particle-extend). And <all> must be the top level compositor (see http://www.w3.org/TR/xmlschema-1/#cos-all-limited). The closest I could get was to have Type1 and Type2 be restrictions of Type3: <complexType name="Type3"> <all> <element name="foo1" type="string" minOccurs="0" /> <element name="bar1" type="NMTOKEN" minOccurs="0" /> <element name="foo2" type="string" minOccurs="0" /> <element name="bar2" type="decimal" minOccurs="0" /> </all> </complexType> <complexType name="Type1"> <complexContent> <restriction base="tns:Type3"> <all> <element name="foo1" type="string" /> <element name="bar1" type="NMTOKEN" /> </all> </restriction> </complexContent> </complexType> <complexType name="Type2"> <complexContent> <restriction base="tns:Type3"> <all> <element name="foo2" type="string" /> <element name="bar2" type="decimal" /> </all> </restriction> </complexContent> </complexType> You have to put minOccurs="0" on the elements in Type3 otherwise the restrictions are not valid. The Java you get for this is not brilliant as Java doesn't lend itself well to inheritance by restriction. But it's probably good enough and at least both Type1's parent and Type2's parent is now Type3. If you're willing to have the <all>'s be <sequence>'s instead there are other choices such as model groups that may work for you. Don't know if any of that helps but FWIW. Cheers, Lawrence > -----Original Message----- > From: Kevin Y. Kim (Lists) [mailto:[EMAIL PROTECTED] > Sent: Tuesday, November 01, 2005 8:41 PM > To: user@xmlbeans.apache.org > Subject: semi-related schema question > > Hi, > > I am new to xmlbeans - and I think it will do what I want. > But I'm having trouble defining my schema properly to represent > what I want. > > If I have two types: > <type name="Type1"> > <all> > <element name="foo1" type="string" /> > <element name="bar1" type="NMTOKEN" /> > </all> > </type> > > <type name="Type2"> > <all> > <element name="foo2" type="string" /> > <element name="bar2" type="decimal" /> > </all> > </type> > > Now I also need a third type that combines these two types: > <type name="Type3"> > <all> > <element name="foo1" type="string" /> > <element name="bar1" type="NMTOKEN" /> > <element name="foo2" type="string" /> > <element name="bar2" type="decimal" /> > </all> > </type> > > Now, I can explicitly defined them as I have done above, and scomp > works fine. Is there a way I can define Type3 to inherit from > Type1 and Type2, so that scomp won't fail? > > Type1 and Type2 are NOT abstract. > > Thanks, > -kevin > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]