Say that the circuit has the following:
<xsd:complexType name="shape"/>
<xsd:complexType name="circle">
<xsd:complexContent>
<xsd:extension base="shape">
<xsd:attribute name="radius" type="xsd:double"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="arc">
<xsd:complexContent>
<xsd:extension base="circle">
<xsd:attribute name="startAngle" type="xsd:double"/>
<xsd:attribute name="endAngle" type="xsd:double"/>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Then you can add a lookup group such as
<xsd:element name="shape" type="shape" abstract="true"/>
<xsd:element name="circle" type="circle" substitutionGroup="shape"/>
<xsd:element name="arc" type="arc" substitutionGroup="shape"/>
and then take any of these types, referring to the group, for example:
<xsd:element ref="shape"/>
This part is not a problem.
But what if I also want to be able to resolve (in another section) just a circle and its subtype?
Can I add multiple substitution groups to emulate the correct inheritance in the schema? I tried to add another type of element, for example:
<xsd:element name="shape" type="shape" abstract="true"/>
<xsd:element name="circle" type="circle" substitutionGroup="shape"/>
<xsd:element name="arc" type="arc" substitutionGroup="shape"/>
<xsd:element name="arc2" type="arc" substitutionGroup="circle"/>
But I better not change the name of the expected element depending on what I expect.
Is there a better way to do this?
source
share