[ACCEPTED]-Where to add a version to an XSD schema?-version

Accepted answer
Score: 20

You can use the namespace of your xsd document

<xs:schema targetNamespace="http://yourcompany/yourapp/1.0" ... >
  ...
</xs:schema>

As 10 an example look at the xsd's defined by 9 w3.org, this is how they do it. Do note 8 that changing the version number here would usually 7 by definition be a breaking change for any 6 consumers of your xsd (no matter how small 5 the actual change was, or which part of 4 the version number you changed).

For less 3 impacting versioning, there seems to be 2 an agreement about putting a version attribute 1 at your root element:

<xs:schema version="1.0.0" ...>
  ...
</xs:schema>
Score: 10

According to the schema element itself has a version attribute:

<schema
  attributeFormDefault = (qualified | unqualified) : unqualified
  blockDefault = (#all | List of (extension | restriction | substitution))  : ''
  elementFormDefault = (qualified | unqualified) : unqualified
  finalDefault = (#all | List of (extension | restriction | list | union))  : ''
  id = ID
  targetNamespace = anyURI
  version = token
  xml:lang = language
  {any attributes with non-schema namespace . . .}>
  Content: ((include | import | redefine | annotation)*, (((simpleType | complexType | group | attributeGroup) | element | attribute | notation), annotation*)*) 
</schema>

See 6 http://www.w3.org/TR/xmlschema-1/#key-schema, "3.15.2 XML Representations of Schemas"

However, if 5 you published the schema, then I think the 4 best way to deal with it would be to use 3 the target namespace. This would enforce 2 the right version being used (but break 1 compatibility)

More Related questions