XSD:在 XML 模式中测试

XSD: Test in XML schema

我得到了一个 XML 架构,其中包含类似于以下几行的内容。

这些测试线是什么意思?
他们是否以某种方式描述了文档?

...
<xs:element name="Document" 
            type="BaseDocument">
  <xs:alternative test="(@doc_face eq 'init') 
                        and 
                        (@doc_op eq 'included')" 
                  type="SystemInit"/>
  <xs:alternative test="(@doc_face eq 'Z')" 
                  type="Zreport"/>
</xs:element>
...

参见Type Alternatives

Type alternatives can be used by an Element Declaration to specify a condition ({test}) under which a particular type ({type definition}) is used as the ·governing type definition· for element information items governed by that Element Declaration.

它们(正如 Alexander Petrov 已经指出的那样)是 XSD 1.1 模式中的替代类型。 test 属性按顺序求值:

  • 如果 Document 元素的 doc_facedoc_op 属性的值分别为 'init' 和 'included',则第一个测试的计算结果为真Document 元素的管理类型是默认命名空间中名为 SystemInit 的类型(如果有 none,则没有命名空间值)。
  • 否则,如果 Document 元素具有值为 'Z' 的 doc_face 属性,则 Document 元素的管理类型是名为 ZReport 在默认命名空间中(或者没有命名空间值,如果有 none)。
  • 否则(即如果替代测试的 none 的计算结果为真),元素的声明类型,此处默认命名空间中的 BaseDocument(或 none)变为Document 元素的控制类型。