Note to self: XML Schema design patterns in a nutshell


This post is heavily inspired by Stephen Kaufman’s posts on XML schema design. His posts are in-depth analyses of the pros and cons of the major patterns in use. This is just a note.

There are four major flavors when it comes to designing an XML schema. These design patterns differ as to the points of definition, structure and coupling between the various schema elements (and attributes) and user-defined types. Elements and types that are global are direct children of the <schema> node.  Elements and types are considered local when they are nested within other elements and types.  If elements or types are global then they are available for reuse by other schemas using either import or include statements.  Locally defined elements and types are not available for reuse.

The Venetian Blind approach uses a single global element. All naming and type definitions are also global. All locally defined elements may or may not be namespace qualified depending on the ‘elementFormDefault’ attribute setting.

+ Types are available for reuse, namespace prefixing can be turned on or off at will.

– Verbose, not self-contained and may be tied to other schemas.

The Russian Doll approach uses a single global element. All elements and types are nested within this root element. Namespace qualification or the lack thereof does not alter the visibility of local elements to external parties.

+ Self-contained, decoupled from other schemas and changes to the schema do not affect other schemas.

– Not reusable.

The Salami Slice approach defines all elements globally but all types are defined locally.

+ Reusable

– Verbose, larger schema size, not self-contained and coupled to other schemas.

The Garden of Eden approach defines both elements and types globally. The namespace must be exposed irrespective of the value of the ‘elementFormDefault’ attribute.

+ Reusable

– Verbose, not self-contained and coupled with other schemas, no namespace hiding

Go through the original posts:

  1. Stephen Kaufman: Schema Design Patterns: Russian Doll

  2. Stephen Kaufman: Schema Design Patterns: Salami Slice

  3. Stephen Kaufman: Schema Design Patterns: Venetian Blind

  4. Stephen Kaufman: Schema Design Patterns: Garden of Eden

Also, Elliotte Rusty Harold’s XML Bible is freely available on the internet so, go look it up when in need.

Advertisements

About this entry