Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to add a version to an XSD schema?

Tags:

version

xml

xsd

The application I work on has XML output that conforms to an XSD schema. As features are added to the application, the XSD changes and I would like to note the version of the schema in the XSD file.

Perhaps I'm missing something, but I haven't found a built-in way to mark the version of the schema.

How do you do it?

like image 549
elifiner Avatar asked Jan 26 '10 10:01

elifiner


People also ask

How do I change the XML Schema version?

To change the XML Schema version of the current document, use the Change XML Schema version action from the contextual menu. This is available both in the Text mode, and in the Design mode and opens the Change XML Schema version dialog box.

How do I know my XSD version?

For example, http://www.w3.org/XML/XMLSchema/v1.0 identifies XSD version 1.0 and http://www.w3.org/XML/XMLSchema/v1.1 identifies XSD version 1.1. Identifies the language described in the N -th edition of version X .

How do I add attributes to XSD?

The default and fixed attributes can be specified within the XSD attribute specification (in the same way as they are for elements). Tip: To add an Attribute in the Liquid Studio graphical XSD view, select menu item Edit->Add Child->Attribute or select the toolbar button .


2 Answers

You can use the namespace of your xsd document

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

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

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

<xs:schema version="1.0.0" ...>
  ...
</xs:schema>
like image 141
peter_raven Avatar answered Oct 06 '22 06:10

peter_raven


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 http://www.w3.org/TR/xmlschema-1/#key-schema, "3.15.2 XML Representations of Schemas"

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

like image 33
Roland Bouman Avatar answered Oct 06 '22 08:10

Roland Bouman