Fine Tune XML Samples from XSD

How to Fine Tune XML Sample Generation from XML Schema

An XML sample is an effective way to convey the structure defined by an XML Schema (XSD); it is more so when advanced XSD features are used to describe complex type hierarchies, using abstract types and elements, substitution groups, etc.

Virtually every XSD authoring tool provides the ability to generate an XML sample; most provide limited means to control the outcome in a meaningful way, or fail all together when multiple XSD files are involved. This often defeats the purpose of automatically generating a sample, using minimum or, at least, intuitive ways of doing it.

This topic shows how QTAssistant provides a method to fine tune an XML sample generation using an eXtensible Traceability Matrix (XTM); choices, abstract complex types and type hierarchies, and substitution groups can be easily tackled using point and click and drag and drop, no matter how many XSD files make up the working set of files.

 

Step 1: Organize your XSD files

The best way to understand an XML Schema set is through an XML Schema Refactoring (XSR) project. For the scenario covered by this topic, an XSR provides the entry point for the XTM editor as well as it helps to define the scope of the search for eligible types and substitution group members.

 

XSR Setup
XSR Setup
(Click to Enlarge)

Step 2: Define the paths, values and documentation for the sample XML

Use the XSR's Documenter feature to create an XTM. In the Schema Set panel, browse the XSD to the elements and/or attributes to show in the sample XML. Drag and drop them on the XTM. Using the Documenter Details panel, enter any specific value to show in the sample XML. Comments can be generated using the Documentation at the entry level and/or at the data level. Once completed, click Generate Sample XML command to create the sample XML files; one XML file will be generated for each distinct top level element in the selected paths.

Documenter Setup
Documenter Setup
(Click to Enlarge)

The generated XML shows the selected paths using the data and documentation captured.

Customizing an abstract complex type
Customizing an abstract complex type
(Click to Enlarge)