我想定义一个支持这样的元素的模式:
<one att1="foo" att2="bar"/>
<two att1="foo" att2="bar">TEXT</two>
<three att1="Foo" att2="bar" att3="baz"/>
如何定义类型层次结构以包含att1和att2?
<complexType name="Att">
<attribute name="att1" type="string"/>
<attribute name="att2" type="string"/>
</complexType>
<complexType name="One">
<complexContent>
<extension base="tns:Att"/>
</complexContent>
</complexType>
<complexType name="Two">
<simpleContent>
<extension base="tns:Att"/>
</simpleContent>
</complexType>
<complexType name="Three">
<complexContent>
<extension base="tns:Att">
<attribute name="att3" type="string"/>
</extension>
</complexContent>
</complexType>
这对于Two不起作用,并且我在使用simpleContent扩展complexContent时遇到错误
这有效:
<complexType name="Att" mixed="true">
<attribute name="att1" type="string"/>
<attribute name="att2" type="string"/>
</complexType>
...
<complexType name="Two">
<simpleContent>
<restriction base="tns:Att">
<simpleType>
<restriction base="string"/>
</simpleType>
</restriction>
</simpleContent>
</complexType>