I just started using XSD today to bear with me if this a kind of a dumb question. I have an XML schema where three root elements, A, B, and C, are defined. Each of these elements may have a child of type 'example'. The 'example' type has three different attributes. While A, B, and C may only have a child of type 'example', the requirements for the different attributes are not the same for each. For instance, A requires the first attribute to be defined but C does not. Here's some sample code illustrating this:
<xs:element name="A">
<xs:complexType>
<xs:all>
<xs:element name="example">
<xs:complexType>
<xs:attribute name="attr1" use="required"/>
<xs:attribute name="attr2" use="required"/>
<xs:attribute name="attr3" use="required"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="B">
<xs:complexType>
<xs:all>
<xs:element name="example">
<xs:complexType>
<xs:attribute name="attr1" use="required"/>
<xs:attribute name="attr2" use="required"/>
<xs:attribute name="attr3" use="optional"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
<xs:element name="C">
<xs:complexType>
<xs:all>
<xs:element name="example">
<xs:complexType>
<xs:attribute name="attr1" use="optional"/>
<xs:attribute name="attr2" use="optional"/>
<xs:attribute name="attr3" use="required"/>
</xs:complexType>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
Can I create a general 'example' complex type and override its usages in each of my elements? In other words, is there any way to avoid copying and pasting so much?
Thanks.