How to Turn XML Schema (XSD) to Documentation
29 Aug 2013Today, a colleague at work was trying to modify a configuration file in XML format. He wasn’t sure what were the available options for a certain attribute, so we started looking for an answer.
The XML configuration file came with a software product and had an XSD file. For me as a developer, I opened the XSD file in Visual Studio and used the XML Schema Editor (shown on the right) to browse its content.
However, for him installing Visual Studio wasn’t the best option especially if he wanted to forward more information to a client and let them modify configurations themselves. So, we did a little more digging.
Xs3p is a schema documentation generator. It’s simply an XSLT stylesheet, which generates HTML documentation from an XSD schema file.
You can download Xs3p here or direct link to version 1.1.5
Extract the content of the downloaded ZIP file and place it a folder. We’ll use the file xs3p.xsl
On Windows, you can use MSXML (Download) and the MSXSL command utility (Download).
To use MSXSL, place the downloaded EXE in the same folder as the extracted ZIP file. In the command line browse to that folder, then type a command like this:
Where: myXsd.xsd is the name of the XSD file. myXsdDocumentation.html is the name of the HTML file that will be generated by the tool. I assume that all three files (XSD, XSL, and output HTML) along with MSXSL.exe are placed in the same folder.
Here’s what the output looks like: You can download view sample HTML output.
To make things easier, I wrote a PowerShell script that find all the XSD files in the folder where it’s placed and convert them all to HTML. It assumes that both MSXSL.exe and xs3p.xsl are in the same folder. To use the script, from the command line run this command:
Here’s the script:
This ZIP file include all three files: PowerShell script, MSXSL.exe and style sheet xs3p.xsl.
Enjoy!