Minimize Number of XSD Files

Minimize Number of XML Schema Files

There are many reasons why some schema sets are released using a large number of files; from a designer's perspective, it may simply reflect the logical partitioning of a model; when done for the benefit of a consumer, it may isolate dependencies, thus allow for streamlined implementations that address only portions of the model.

The problem arises when an XSD-aware tool requires users to explicitly reference the complete list of XSD files, even when the built in resolution mechanism, based on include, import and redefine, completely maps out all the required files. Other products, such as Microsoft SQL Server, would simply not accept schema sets which make use of xsd:include. Most tools do not support redefine.

Below are illustrations of some schema sets released using a large number of files, and their equivalent, using a minimum number of files.

Fast Health Interoperable Resources (hl7.org/fhir) releases XSD in both formats.

FHIR release
FHIR release
(Click to Enlarge)

 The "single" file release eliminates all the includes between the files.

FHIR
FHIR "single" file release
(Click to Enlarge)

Ordering Services For Earth Observation Products (OSEO), an Open Geospatial Consortium (OGC) standard, provides their release using 100+ schema files.

OSEO release
OSEO release
(Click to Enlarge)

 Below is a flattened release which eliminates all the includes between the files.

Flattened OSEO
Flattened OSEO
(Click to Enlarge)
All the XSR files showing how to flatten the OSEO schema are available for download at this location.

The XSR provides a mechanism that makes the process of refactoring XSD files into a minimum set intuitive and repeatable. It allows for integration in automated build flows. The XSR file set below captures the setup used to flatten the OSEO file release.


(Click to Enlarge)