3
假设你有一个架构如下:是否有可能每个元素类型有多个替代组?
<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>
然后可以通过引用该组的像添加替换组这样
<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 ref="shape"/>
这部分不是问题。
但是,如果我还希望能够(在另一部分)允许圈和它的子类型呢?
是否可以添加多个替代组以便在模式中模拟正确的继承?我尝试添加另一种元素类型,如:
<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"/>
但我宁愿没有改变取决于什么我期待的预期元素的名称。
有没有更好的方法来做到这一点?
疯狂 - 我可以发誓我曾尝试过。谢谢 – Marc 2010-03-15 14:49:12