Hello,
I'm struggling to extend the types defined in a schema. I've searched
this group (and others) with no luck so far. I have the following two
schemas:
<!-- foobar.xsd -->
<!-- A 'base' schema which will be 'extended' by customer specific ones
-->
<xs:schema ...>
<xs:complexType name="foo">
<xs:sequence>
<xs:element name="fooName" type="xs:string"/>
<xs:element name="bar" type="bar"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="bar">
<xs:sequence>
<xs:element name="barName" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<!-- customerA-foobar.xsd -->
<!-- A version of the base schema for customer A -->
<xs:schema ...>
<xs:complexType name="customerAFoo">
<xs:complexContent>
<xs:extension base="foo">
<xs:sequence>
<xs:element name="fooCode" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="customerABar">
<xs:complexContent>
<xs:extension base="bar">
<xs:sequence>
<xs:element name="barCode" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
I need to redefine the 'bar' element in 'customerAFoo' so that it's
type is a 'customerABar', but that isn't allowed for 'xs:extension'
unless I use 'xs:redefines'. 'xs:redefines' isn't working for me
because I'm using the XMLBeans tool to generate Java classes from these
schema, and when I use 'xs:redefines', XMLBeans doesn't understand that
customerAFoo extends foo, etc.
Is there another way to express the fact that, for a customerAFoo, the
'bar' element should be a 'customerABar'? Should I be using
substitution groups or xsi:type somewhere?
Thanks for your help.