Igor Kromin |   Consultant. Coder. Blogger. Tinkerer. Gamer.

I have to work with the CDA XML schema on a regular basis and sometimes it is easier to check things either via a tool that can visualise the schema or through hyperlinked documentation that describes the schema in a concise way. Unfortunately, as I found out, most tools can't handle a complex schema that has multiple cyclic references within it. So what's the solution? Use a tool that doesn't analyse the XSD! This is where xs3p comes in.

Quoting from the xs3p web site...
xs3p is a schema documentation generator. Basically, it is an XSLT stylesheet that will generate an XHTML document from an XSD schema. Some of its cool features are:
* It provides links that allow the user to jump to the documentation of schema components that are referenced.
* It provides a view of schema components' constraints as a sample XML instance.
* For global type definitions, it shows the super- and sub- types of the type definition.
* For global element declarations, it shows the substitution groups that the element declaration heads or belongs to.
* It can sort schema components by type and name.
* It has a glossary section which explains some XML Schema terminology.


Their wiki is also quite useful though I could not get the link generator XSLT to work.

The output looks quite nice too...
xsddoc1.png




The generated documentation is fully hyperlinked and easy to navigate. This definitely makes a XSD much easier to comprehend.

So to do this, I had to generate a links.xml file that described which XSDs map to which HTML output files. This is really straight forward, just put in the XSD file name along with its HTML file which you generate later. For example...
 links.xml
<?xml version="1.0"?>
<links xmlns="http://titanium.dstc.edu.au/xml/xs3p">
<schema file-location="CDA-AU-V1_0.xsd" docfile-location="CDA-AU-V1_0.xsd.html"/>
...
</links>


I had an entry for every XSD file in my whole schema.

Now all I had to do was to run xsltproc to generate my output. This is done for every XSD file and looks something like this (though I created a shell script to do it for me)...
 xsltproc command
xsltproc --stringparam title "My Schema Name" \
--stringparam searchIncludedSchemas true \
--stringparam searchImportedSchemas true \
--stringparam linksFile links.xml \
xs3p.xsl CDA-AU-V1_0.xsd > CDA-AU-V1_0.xsd.html


Note the naming of the output file, it's simply the XSD file name with .html at the end of it and that's exactly what the links.xml file contains as well.

Do this for all the XSD files in your schema and your documentation will be complete.

-i

A quick disclaimer...

Although I put in a great effort into researching all the topics I cover, mistakes can happen. Use of any information from my blog posts should be at own risk and I do not hold any liability towards any information misuse or damages caused by following any of my posts.

All content and opinions expressed on this Blog are my own and do not represent the opinions of my employer (Oracle). Use of any information contained in this blog post/article is subject to this disclaimer.
Hi! You can search my blog here ⤵
NOTE: (2022) This Blog is no longer maintained and I will not be answering any emails or comments.

I am now focusing on Atari Gamer.