下面是嵌套任何級別的選項...
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="score">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="option"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="ignore"/>
</xs:sequence>
<xs:attribute name="numeric" use="optional" type="xs:integer"/>
<xs:attribute name="seq" use="required" type="xs:integer"/>
<xs:attribute name="type" use="required" type="xs:NCName"/>
</xs:complexType>
</xs:element>
<xs:element name="option">
<xs:complexType mixed="true">
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="score"/>
</xs:sequence>
<xs:attribute name="id" use="optional"/>
<xs:attribute name="lbound" use="optional"/>
<xs:attribute name="ubound" use="optional"/>
</xs:complexType>
</xs:element>
<xs:element name="ignore"/>
</xs:schema>
這適用於這兩個例子你已經給出:
例1
<score seq="1" type="test" numeric="23">
<option lbound="0" ubound="">
<score seq="1" type="app" numeric="575">
<option lbound="" ubound="0">0</option>
</score>
</option>
</score>
例2(從評論)
<score seq="1" type="IN">
<option id="1">10</option>
<ignore/>
</score>
這是不可能來自一個實例的實例制定出要在模式強加什麼限制。例如,分數/選項對的嵌套級別是否允許,或者是否要將其限制爲一個嵌套級別? –