我有一个类似于以下的文档类型:
<foo>
<settings>
<!-- Must be present; in any order -->
<time>abc</time>
<validRun>true</validRun>
<!-- Tool may add whatever ones it wants -->
<somethingNotCheckedFor>abc</somethingNotCheckedFor>
</settings>
</foo>
下面的文档在语义上与前面的文档相同:
<foo>
<settings>
<validRun>true</validRun>
<somethingNotCheckedFor>abc</somethingNotCheckedFor>
<time>abc</time>
</settings>
</foo>
但以下内容无效:
<foo>
<settings>
<validRun>true</validRun>
<somethingNotCheckedFor>abc</somethingNotCheckedFor>
<!-- Error: Required element "time" not present -->
</settings>
</foo>
我尝试了类似以下的方法,但这不起作用,因为<xs:all>
不允许包含<xs:any>
:
<xs:all>
<xs:element name="time" />
<xs:element name="validRun" />
<xs:any />
</xs:all>
在 W3C Schema 中是否有一些方法可以做到这一点?