What are the best methods for XML schema versions?

I often have to develop XML schemas for different XML database import procedures. It is clear that XML schemas will evolve over time or they may contain corrections, so it is important to fix the version of the schema and associate some mechanism with a specific version.

I currently have two scenarios:

  • An error is found in the schema, and all instances of the schema must match the fixed version.

  • The scheme has been updated and should be considered as preferred, but the old one should also be supported.

Finally, I came with saving version information in the schema namespace:

targetNamespace="http://schemas.company.com/Geodesy/2010/River.xsd" 

When fixing the error, I fix it in the same namespace, but if I am going to update the schema, I need to create a new namespace, but with the month of update added:

 targetNamespace="http://schemas.company.com/Geodesy/2010/01/River.xsd" 

And if I have more than one update per month, just add another day:

 targetNamespace="http://schemas.company.com/Geodesy/2010/01/17/River.xsd" 

Do you know any better approach?

+57
xml versioning xsd
Jan 06
source share
2 answers

This is such a difficult question that it’s not even funny, and the one that I spent years providing consulting support.

There are many best practices , but most of them do not work in all situations. For example, many advocate using "xsd: any" to allow extensions, and this is just a recipe for disaster if developers are responsible for saving the circuit, turning it into a dump.

Here are some tips for you if you are starting out:

  • Do not put in your namespace the minor version number, micro version number, date or anything else like that. Every time you change the namespace, you break all the processing applications.
  • Do put the "version" attribute in the XML instance document. This will allow the handler or version adapter service to find out what it is processing.
  • Indicate the policy of what constitutes a backward compatible change, for example: adding optional elements will not break senders and will not interrupt receivers if they use a policy to ignore elements that they do not know (JAXB and XMLBeans can be configured this way)

Good luck good luck!

+77
Jan 11 '10 at
source share

http://www.xml.com/pub/a/2004/07/21/design.html provides good recommendations, and XML Schema 1.1 allows you to "manage versions" through conditional inclusion ( http://www.w3.org/ TR / xmlschema11-1 / # cip ).

+6
Jul 22 '13 at 15:01
source share



All Articles