XSD “version” attribute semantics

杀马特。学长 韩版系。学妹 提交于 2019-12-13 13:17:28

问题


<schema xmlns="http://www.w3.org/2001/XMLSchema" ... version="xxx">

The XSD specification https://www.w3.org/TR/xmlschema11-1/#declare-schema does not specify the semantics for the version attribute:

The other attributes (id and version) are for user convenience, and this specification defines no semantics for them.

Nor does that the W3C versioning guide https://www.w3.org/TR/xmlschema-guide2versioning/.

Is there a consensus arising whether this attribute should be used for specifying the version of the XML Schema document (e.g. 2.3.1), or for the version of the XSD language used to write the schema document (i.e. either 1.0 or 1.1)? Or is the semantics choice still on the designers/developers?


回答1:


The xs:schema/@version attribute is used for specifying the version of the XSD being developed, not XSD 1.0 vs 1.1. Semantic versioning or any other user-defined semantics may be used. As your apropo quote indicates, it is up to the user to define.

To specify XSD 1.0 vs 1.1, XSD 1.1 provides conditional inclusion, which can be used on any XSD element, including the xsd:schema root element. For example, an XSD that requires assertions could indicate the need for XSD 1.1 like this:

<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>


来源:https://stackoverflow.com/questions/44214615/xsd-version-attribute-semantics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!