How NOT To Design XML Schemas

If you are designing XML schemas, do any of the following things to make your schemas a real pain in the ass to use:

  1. Make sure every schema uses a different target namespace, even if all schemas contain types that are meant to be used together.
  2. Use the same type name for different types in different schemas (will only work if you also do 1).
  3. Invent your own versioning and extension mechanism for the resulting XML documents, because “must ignore” has never worked well in the history of the Web. Preferrably, create a “V2″ element (and, within that, a V3 element, etc.) to contain all elements added at later versions of the schema. Make these elements optional, so that it becomes real hard to access an element value present only in version 4 of the schema.
  4. Make sure to absolutely never run your schemas through a data binding code generator before you publish them, so you don’t see the ugly code that gets generated from your schema (if the data binding tool can process your schema at all).
  5. Ensure that all schemaLocation attributes in your import/include elements contain absolute paths or HTTP/FTP URIs, so that local fixes to your schemas will be overridden.
  6. Allow for unlimited extensibility by adding unbounded any elements to every sequence.

    About Günter Obiltschnig
    Software engineer, founder and managing director of Applied Informatics, founder and lead developer of the POCO C++ Libraries open source project, husband, father, sailor.

    Comments are closed.