How to generate simple documentation from XSD using XSLT

3.5k Views Asked by At

We have several XSD files and one of them has the root element and others are imported or included. These XSD files represents an XML service request... for documentation reason, I need to extract all the element names and attributes under the root element.

What I need is to produce something like this:

<table>
  <tr>
     <td>ELELEMENT OR ATTRIBUTE NAME</td> 
     <td>Whether or not mandatory - by checking minOccurs="0"</td>
     <td>EMPTY OR THE TEXT VALUE under annotation/documentation IF AVAILABLE</td>
  </tr> 
</table>
3

There are 3 best solutions below

0
Simon On BEST ANSWER

I made an xslt stylesheet that does exactly what you asked for: https://github.com/S2-/xsddoc

1
Michael Kay On

You might like to consider rendering the schema using Michael Sperberg-McQueen's stylesheet at http://www.w3.org/2008/09/xsd.xsl, or adapting this to your requirements. It works best when the schema contains extensive XHTML-formatted documentation.

0
C. M. Sperberg-McQueen On

There are several tools to generate HTML from sets of XSD schema documents; some are listed at the W3C page on XSD. The page is increasingly out of date, but many of the tools it lists are still available.