strategicdevelopment logo StrategicDevelopment.io
formerly xmlHelpline.com Consulting

(with SchemaFlattener and WSDLFlattener)


What is the XML SchemaLightener?

The XML SchemaLightener is a tool designed to help you prune unnecessary elements, attributes and data types from your XML Schema. Sometimes referred to as "LiteBODs", "Schema subsets", "constrained Schemas", or "pruned Schemas." This tool helps you create a simplified XML Schema that conforms to an original. In a literal sense, the XML SchemaLightener is an XSLT stylesheet that is applied to your Schema.

Definitions:

Lighten
The process of removing components that are never used from an XML Schema. Any global component can be removed such as elements, attributes, types, attributeGroups, and groups. The lightening process retains the syntax and data model of the original Schema, but with unused components removed. The result is a valid XML Schema which mirrors the original XML Schema's data model, but with selected components omitted. In this manner, a very large XML Schema data model can be reduced to a usable size while still conforming to the original.

Flatten
The process of consolidating all dependencies of an XML Schema into a single file. In short, all xsd:include files are merged into a single Schema. The SchemaFlattener will merge all xsd:includes together in a selected Schema. In addition, it will do the same for each xsd:import dependency. NOTE: XML Schema does not allow files from different namespaces to be merged together. This means files connected via xsd:import cannot be merged. These import relationships are retained and put into the result. Each file's xsd:includes however are merged. This has the effect of consolidating a group of XML Schemas into the fewest possible files. If there are no xsd:imports, then it will result in a single, stand alone Schema.

What is the SchemaLightener?

How does it work?

Why would I need it?

FAQs:
Does it come with the SchemaFlattener?

What do users say about it?

Does it have a GUI?

How much of a benefit do I get?

Has it been rigorously tested?

How does this relate to other solutions?

What do I get?

What are the requirements for using this utility?

How can I get it?



How does it work?

An XSLT stylesheet is applied to the original XML Schema. It takes as input an XML instance which is valid against that Schema. The instance contains the subset desired in the result. The XSLT prunes the Schema, removing elements, attributes and data types that are not needed to validate the given XML instance.

When you Include all the data that you want in the instance, the Lightener creates a Schema that only validate nodes in that instance.

The image below illustrates how the XML SchemaLightener works.

Click to enlarge

Why would I need it?

Consider these scenarios.

In any of these scenarios, you require a simplified XML Schema to be consistent with the original. Specifically, you want an XML instance that is valid against the subset to also validate against the original. But how can this be done? Previously, there were only 2 principle solutions for this; First, edit the original schema. This works but is tedious and risks hand editing errors. Second, you could implement Schematron technology. This also works, but may not always be possible (see How does this relate to Schematron?).

The XML SchemaLightener helps you create a subset / LiteBOD / pruned Schema from any original Schema. The image below illustrates how this tool fits into an XML management context.

Click to enlarge


Frequently Asked Questions

Does it come with the SchemaFlattener?

Yes, the XML SchemaLightener comes bundled with the SchemaFlattener. This also free application allows you to create stand alone versions of your Schema.

Often times, Schemas are developed modularly using xsd:include statements to enable the reuse of components. The SchemaFlattener takes a Schema and merges all xsd:includes into a single stand alone result.

Even further - if there are any xsd:imports, they in turn each have their xsd:include dependencies merged as well. The result is a valid Schema with the absolute least number of files. (If there are no xsd:imports, then it results in only a single file.)

The heart of the SchemaFlattener is an XSLT transformation. This means it can be used in applications and batch files in the same manner as the Lightener.

Top

What do users say about it?

Users have been giving some great feedback. The most detailed reaction can be read here. In addition, numerous other comments can be found here.

Top

Does it have a GUI?

A Graphical User Interface (GUI) is included for both the Lightener and Flattener. The GUI allows you to simply point and click. Select a Schema, select an XML instance, select a destination folder, and then push a button. It's that simple!

Click to enlarge

Click to enlarge

Top

How much of a benefit do I get?


Statistically, the reduction in the Schema is dependent on the XML instance. The instance contains XML nodes to be included in the result. The smaller the XML instance, the smaller the Schema because it contains fewer elements, attributes and data types. (Testing was done on the release libraries OAGIS version 9.1 and HR-XML version 2.5.)

The latest public release of the HR-XML library of Schemas was used for analysis, to illustrate how much benefit could be gained. A total of 128 unique XML instances were used from that release. The Schemas which governed them were run through the SchemaLightener and the resulting Schema was used to compare how much of a reduction in components was achieved.

The results:

  • Number of original Schemas: ..... 128

  • Number of result "lite" Schemas created: ..... 128

  • Percent of result Schemas passing validity: ..... 100%

  • Percent of XML instances that validate against result "lite" Schemas: ..... 100%


  • Average reduction in number of global elements: ..... 75.3%

  • Average reduction in number of global simpleTypes: ..... 67.3%

  • Average reduction in number of global complexTypes: ..... 62.6%

Click to see spreadsheet data detail

Top

Has it been rigorously tested?

The Lightener and Flattener have both been tested using numerous XMLl Consortia Schemas. Here is a blog post detailing the testing. The libraries include releases from:

  • HR-XML (Human Resources XML) v. 2_5


  • HR-XML (Human Resources XML) v. 3.0 (draft)


  • OAGi (Open Applications Group) v. 9.2


  • STAR (Standards for Technology in Automotive Retail) v. 5.1.4


  • CIDX (Chemical Industry Data eXchange) v. 4.0


  • ACORD (Insurance Data Standards) v. 2.9


  • OTA (Open Travel Alliance) v. 2003-05


  • TWIST (Transaction Workflow Innovation Standards Team) v 3.1
Top

How does this relate to other solutions?

The Lightener is meant to compliment other methods of creating constrained Schemas. There are software tools that can help, including Hypermodel and Gefeg as well as the Schematron specification.

Schematron is a technology that enables additional constraints to be added on top of an XML Schema. It is a more robust solution to the scenarios described in this FAQ, and xmlHelpline supports the Schematron effort.

The Lightener is intended for contexts where Schematron is not possible. For whatever reason, there may be technology constraints that prevent full implementation of Schematron.

The Lightener is also intended for use where a resulting XML Schema is a requirement. Validating Schematron constraints requires additional technology at validation time. The Lightener, while it uses XSLT to create the subset Schema, does not require any new technology at validation time.

Top

What do I get?

  1. The core of the SchemaLightener which is an XSLT stylesheet. This can be used with any XSLT 2.0 processor.

  2. A bonus: The Lightener comes with an XSLT which flattens Schemas, called a SchemaFlattener. This can also be used with any XSLT 2.0 processor.

  3. For your convenience, it comes bundled with Saxon, an XSLT processor created by Michael Kay. An open source version of Saxon is included in this product. http://saxon.sourceforge.net. See Saxon notices in this package for legal notes on its usage.

  4. A user interface (UI). The UI can invoke both the Flattener and Lightener XSLT stylesheets. It also provides full logging with stack trace. It is cross-platform java and has been tested on Windows and Ubuntu Llinux.

  5. The complete source code for the user interface (UI). Written in java, a simple swing application.

  6. Sample data. Selected XML Schemas and XML instances from numerous standards consortia are included.

  7. Batch files that invoke the Lightener and Flattener across many files. (While the UI allows you to apply the stylesheets one at a time, the batch files combined with the XSLT processor allow you to create as many results as needed.) The batch files included use Saxon to process the sample data.

  8. Now you also get the WSDLFlattener too. It does for WSDL what the SchemaFlattener does for Schemas.
Top

What are the requirements for using this utility?

  • Using the stylesheets: an XSLT 2.0 processor


  • Operating system: The SchemaLightener XSLTs and UI have been tested on Windows Vista, XP, and Linux.


  • For the Graphical User Interface (GUI): java runtime jre 1.6 or greater

Top

How can I get it?

The SchemaLightener set of tools is now on github!

Top