XSD “version” attribute semantics

2019-07-02 14:01发布

<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条回答
成全新的幸福
2楼-- · 2019-07-02 14:36

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>
查看更多
登录 后发表回答