<schema xmlns="http://www.w3.org/2001/XMLSchema" ... version="xxx">
XSD 规范 https://www.w3.org/TR/xmlschema11-1/#declare-schema没有指定 version
属性的语义:
The other attributes (
id
andversion
) are for user convenience, and this specification defines no semantics for them.
W3C 版本控制指南也没有 https://www.w3.org/TR/xmlschema-guide2versioning/ .
这个属性应该用于指定 XML 架构文档的版本(例如 2.3.1
),还是用于编写架构的 XSD 语言的版本,是否达成共识?文档(即 1.0
或 1.1
)?还是语义选择仍在设计者/开发者手中?
最佳答案
xs:schema/@version
属性用于指定正在开发的 XSD 的版本,而不是 XSD 1.0 与 1.1。 Semantic versioning或者可以使用任何其他用户定义的语义。正如您的引用所表明的那样,由用户来定义。
为了指定 XSD 1.0 与 1.1,XSD 1.1 提供了 conditional inclusion ,可用于任何 XSD 元素,包括 xsd:schema
根元素。例如,需要断言的 XSD 可以指示需要 XSD 1.1,如下所示:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:vc="http://www.w3.org/2007/XMLSchema-versioning"
vc:minVersion="1.1">
<!-- -->
</xs:schema>
关于xml - XSD "version"属性语义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44214615/