I often have to design XML schemas for different XML-bases import routines. It is clear that XML schemas will evolve over time or they could contain bugs to be fixed, so it is important to capture the schema's version and to have some mechanism to bind against a specific version.
Currently I have two scenarios:
The bug is found within the schema and all schema instances must comply with the fixed version.
The schema upgraded and should be considered as preferable but an old one should be also supported.
Finally I came up with storing version information within the namespace of schema:
targetNamespace="http://schemas.company.com/Geodesy/2010/River.xsd"
When fixing a bug I fix it in the same namespace but if I'm about to upgrade a schema then I need to create a new namespace but with upgrade month added:
targetNamespace="http://schemas.company.com/Geodesy/2010/01/River.xsd"
And if I have more than one upgrade in a month then just append a day too:
targetNamespace="http://schemas.company.com/Geodesy/2010/01/17/River.xsd"
Do you know any better approach?
XML schemas are written in XML while DTD are derived from SGML syntax. XML schemas define datatypes for elements and attributes while DTD doesn't support datatypes. XML schemas allow support for namespaces while DTD does not. XML schemas define number and order of child elements, while DTD does not.
The purpose of an XML Schema is to define the legal building blocks of an XML document: the elements and attributes that can appear in a document. the number of (and order of) child elements. data types for elements and attributes.
This is such a difficult subject that it's not even funny, and one that I have spent years providing consultancy support for.
There are many best practices out there, but a most of them do not work in all situations. For example, many advocate the use of "xsd:any" to allow extensions, and that is just a recipe for disaster if developers are in charge of maintaining the schema, turning it into a dump.
Here are some tips for you if you're getting started:
Dood luck!
http://www.xml.com/pub/a/2004/07/21/design.html provides good guidelines and XML Schema 1.1 enables 'versioning' through conditional inclusion (http://www.w3.org/TR/xmlschema11-1/#cip).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With