A powerful multi-format XML schema (XSD) documentation generator and a tool for rapid development of custom XSD documentation generators according to user needs.
"XSDDoc" Template Set
Generation of XSD diagrams
Apache Ant & Maven
DocFlex/XML is a Java-based software system for development and execution of high performance template-driven documentation generators from any data stored in XML files.
The actual doc/report generators are programmed in the form of special templates using a graphic Template Designer, which represents the templates visually in a form resembling the output they generate. Further, the templates are interpreted by a Template Processor, which takes on input the XML files and produces by them the result documentation.
This article describes an application of DocFlex/XML for the task of generation of high-quality XML schema documentation. That includes the following features of DocFlex/XML system:
- "XSDDoc" template set that implements the ready-to-use XML schema documentation generator itself.
- Template Processor makes the templates works. Currently, it provides three interchangeable output generators for HTML, RTF, TXT (plain text) formats.
- Template Designer provides a high quality GUI to design/modify templates. If you need a special XML schema doc generator, the simplest way to create it is to modify the standard XSDDoc templates. The template designer enables you to do that.
- Integrations with Altova XMLSpy and Oxygen XML Editor. If you are a user of one of those popular XML editors, you can turn it also into a dynamically linked diagramming engine for DocFlex, so that to include automatically the XSD diagrams generated by XMLSpy/OxygenXML into the XML schema documentation generated by DocFlex (with the full support of hyperlinks).
It is the implementation of XML schema documentation itself, which provides the following functionality:
- Generation of single documentation by any number of XML schema (XSD) files together, in particular:
Processing of any referenced XML schemas, in particular:
Correct processing of all
<xs:redefine>elements found across all involved XSD files.
- Automatic loading and processing (i.e. inclusion in the documentation scope) all directly/indirectly referenced XSD files.
- Correct processing of all
Sophisticated documenting of XSD components, including:
- Component diagrams (with hyperlinks to everything depicted on them; see also Integrations)
- XML Representation Summary (a textual alternative to diagrams)
- Lists of related components. For elements this includes also the List of Possible Containing Elements. (Such a list is never present in the output generated by XSLT-based doc generators).
- List of usage locations
Support of any XML schema design patterns. This comes down mainly to the following:
- Special treatment of local elements (see below)
- Support and documenting of substitution groups
- Support of importing, inclusion and redefinition of schema files
Special documenting of local elements.
Local elements are those
<xs:element>components that are declared locally within other XSD components. W3C XML schema spec allows you to declare any number of local elements that may share the same name but have different content. That's because their meaning is local and there will be no collisions with other declarations.
That, however, creates a problem for documenting, because in a documentation both global and local elements may appear simultaneously in various lists according to their common properties. If each element component is identified only by its name, you will get the lists with multiple repeating names but little clue what they mean. Moreover, some XML schemas may contain lots of identical local element declarations (that is, they have the same both name and content). So, you'll get in those lists a mess of repeating names, some of which referencing to effectively the same entities, whereas others to complete different ones.
In XSDDoc, those problems are solved in two ways:
Adding extensions to local element names.
The extension provides more information about the element (e.g. where it can be inserted or its global type or where it is defined). That makes the whole string identifying the element unique. Here is how it looks. The grey text is the name extension:
Unifying local elements by type.
On the left you can see a documentation generated with such unification. On the right, all local elements are documented straight as they are. Click on each screenshot to view the docs:
We believe the first documentation (on the left) is easier to understand and use.
- Adding extensions to local element names.
Processing of XHTML markup.
You can format your XML schema annotations with XHTML tags, which will be recognized and rendered with the appropriate formatting in both HTML and RTF output, as shown on the following screenshots (click to see more details):
Here, on the left you can see the XML source of an XML schema, whose annotations are heavily laden with XHTML markup (including insertion of images). The next is the HTML documentation generated by that schema. On the right is a page of RTF documentation also generated by that schema.
Possibility of unlimited customization:
XSDDoc is controlled by more than 400 parameters, which allow you to adjust the generated documentation
within huge range of included details.
Template parameters serve the same role as options in traditional doc generators. The difference is that DocFlex template architecture makes the support/implementation of template parameters very cheap (typically, the most of efforts takes writing their descriptions). So, there may be hundreds of parameters controlling a large template application.
- If parameters are not enough, you can modify the templates themselves using the Template Designer.
- In case of HTML output, you can also apply your own CSS styles to change how the generated documentation looks.
- XSDDoc is controlled by more than 400 parameters, which allow you to adjust the generated documentation within huge range of included details.
The template processor (also called simply "generator") makes everything work. It consists of two logical parts:
1. Template Interpreter
2. Output Generator
The output generator actually has three different implementations for each currently supported output format: HTML, RTF, TXT (plain text). The plain-text output can be used to generate documentation in formats not supported directly by DocFlex.
The template processor is started directly from Java command line with the following arguments:
● Main template
● Template parameters
● Initial XSD files to be processed (documented)
● XML catalogs (to redirect physical location of input files)
● Destination directory/file
● Output format (this selects which output generator will be used)
● Output format options (specify settings to control the selected output generator)
Actually, the number of settings may be so large that the template processor provides a special GUI to specify everything interactively (click to enlarge):
Although DocFlex templates are stored as plain-text files (with an XML-like format), they are not supposed for editing manually. Rather, a special graphic Template Designer must be used, which visualizes the templates in the form of template components they are made of. Those components are the actual constructs of the template language (not some textual statements, operators, blocks etc.)
The following screenshots show templates open in the Template Designer (click to see a lot more):
That approach has a number of advantages, among them:
- The processing structures represented by template components may be displayed in a way that visually expresses what a component does (for instance, it may resemble the output it generates). That representation may be both expressive and compact (after all, it is not just a text), which allows you easily to navigate a template, understand what it does and modify anything you need.
- As template components are visual and interactive, they may have very complex internal structure, for instance, contain lots of properties and nested components. At that, you don't need to scroll and navigate some kind of enormous text, which encodes all of this (as it would be in case of a script). Rather, you just need to invoke some property dialogs and expand/collapse some component sections.
- A template component may be easily copied, pasted and deleted as a whole. At that, you don't need to bother that the template syntax is restored after that. The template designer will also ensure that each component is created, copied or moved only in the allowed place.
- The highly structured nature of templates eliminates the need for most of various named identifiers. Many connections between different template components are also maintained by the Template Designer (i.e. modified automatically when necessary).
- As template files are stored and read only programmatically, there is no need to know and understand their syntax. There will be no syntax errors either.
- The actual syntax of template files may be optimized not for human programmers, but for faster loading and processing of templates by the Template Processor. There is no need in a compilation phase.
- The separation of template semantics from the particular structure of template files helps for faster and easier evolution of the template language. The obsolete constructs of older template versions can be automatically converted into new structures. Both old and new templates will look and work up-to-date.
DocFlex/XML is able to work with any kind of diagrams (i.e. inserting them automatically in the generated output). That is supported on the level of templates, along with the generation of hypertext imagemaps, as shown on the following screenshot (click to see a lot more):
Here is how such a documentation with diagrams looks (click on a screenshot to view the real HTML):
As a pure Java application, DocFlex/XML can be run in any environment that runs Java itself. The template processor can be easily integrated with Ant (that can be specified just in the Ant build file). In case of Maven, DocFlex/XML includes a simple Maven plugin. It is possible also to use all diagraming integrations with both Ant and Maven.
|DocFlex/XML (home page):||http://www.filigris.com/docflex-xml/|
|This original article:||http://www.filigris.com/ann/docflex-xsd/|