2

After days of searching, I have yet to find a decent HTML generator that I can use as a Maven reporting plugin. I've tried using JAXB and Javadoc, but it is not really a clean solution, since it forces me to use jaxb-javadoc tags and what's worse, it forces me to duplicate the documentation that is already present.

My comments look like this:

<xs:annotation>
  <xs:documentation>My comments</xs:documentation>
</xs:annotation>

I'd rather not use <xs:appinfo> tags if I can avoid it.

I don't want to install a tool/application on a specific machine to generate HTML. I am willing to use the JAXB and Javadoc approach as last-ditch effort, but it's not picking up comments unless they are tagged as:

<xs:annotation>
  <xs:appinfo>
    <jxb:class> <!-- Or :property -->
      <jxb:javadoc>My comments</jxb:javadoc>
    </jxb:class>
  <xs:appinfo>
</xs:annotation>

which is ugly and it doesn't seem to work for XSD groups (I've tried both <jxb:class> and <jxb:property>).

Is there any Maven reporting plugin out there that can do this for me? I am also willing to use Xalan or some other transformation framework (as long as it is through Maven), but I am not that keen on creating the stylesheet myself.

Any tips out there?

What I’m looking for is to simply abstract XML Schema elements as messages, which is most often the case for RESTful-WS (as an example). Generating HTML documentation which allows application developers, laymen and business developers to share a common knowledge base to understand a protocol or API. None of these are interested in the finer points of XML Schemas (targets, QNames, namespaces, etc), they just want to know:

  • What does request X look like (an XML element)?
  • What fields can/must I set (max/minOccurs)?
  • What information is available in response Y?
  • For a restricted field, what enum values are allowed?

Javadoc goes a long way to answer these questions, but in order for JAXB to pick it up, the XSD must be tagged in a certain way (using appinfo tags), as well as polluting the original XSD with JAXB namespace. By the way, I generate both C, C++ and Java bindings from the XSD, so the XSD is the master document.

WADL doesn’t quite fit the bill here because even that is too technical and its purpose is mainly to be consumed by machines, not people.

Apart from maybe changing a color schema in the generated HTML, I was baffled to learn that there isn’t a turnkey solution for this. Almost all of them require a local installation of some sort (apart from the JAXB and Javadoc Maven plugin I use now) which goes against the grain of Maven’s concept of portable builds. All organizations I worked for have either made their peace with JAXB/Javadoc or simple developed their own transformation tool to generate HTML.

Daniel
  • 4,033
  • 4
  • 24
  • 33
  • Hi Daniel. In a comment to my answer (below) you wrote: _"It just struck me as a bit odd that given the number of RESTful-WSs out there using XML/XSD, there should be an out-of-the-box HTML generator Maven plugin that, for instance, simply treats a complexType as a message and generates easy-to-read documentation"_. I guess, such a docgen doesn't exist and that intrigued me. Can you formalize, what exactly that docgen should do? What should it take on input and generate on output? Can you provide some examples of what you expect? – Leonid Rudy Sep 27 '14 at 16:02
  • Also, to generate a proper complete documentation for a RESTful-WS, it should be described as a whole, not just some XML schemas involved in it. And there are some approaches to formalize that, like WADL (which is the same for REST as WSDL for SOAP). Then, it would be clear how to document WADL (so that to represent all the involved XML schemas in a relevant way). Why not to use WADL or some alternatives to it? – Leonid Rudy Sep 27 '14 at 16:04
  • Sorry, my SO reputation is too low to fit a reply or comment explaining what I mean. I'll try again when I've earned more rep points. – Daniel Sep 30 '14 at 18:40
  • I think, that would be valuable! Can't you just edit your initial question? BTW, you can also add an answer of your own. – Leonid Rudy Sep 30 '14 at 21:12

1 Answers1

1

Did you look at: http://www.filigris.com/docflex-xml/xsddoc/ ?

It does everything you want:

  • It generates first-class HTML documentation (both single-file and framed multi-file) by any number of XML schemas of any complexity
  • It also can generate the same documentation in RTF
  • It inserts in the generated docs all the comments/annotations found in your XML schemas (including even those preformatted with XHTML, which can be rendered in both HTML and RTF output)
  • It does have a Maven plug-in
  • It appears on the first page in Google on every search query related to XML schema/XSD documentation generator
  • There is even a support forum where you can ask any specific questions and receive the answer the same day: http://www.filigris.com/forum/

So, what's wrong with all this?

BTW, if you don't like to pay for it, you can use it for free. Not all features will be available, however, the Maven plug-in will work.

I am also willing to use Xalan or some other transformation framework (as long as it is through Maven), but I am not that keen on creating the stylesheet myself.

I suggest to take a look at these threads:

  1. How to convert xsd to human readable documentation? -- the comprehensive discussion of the matter; there is little one can add to all mentioned there.
  2. Can XML be documented using Doxygen, Sandcastle, or other documentation generators? -- strange question but correct reply
  3. Using xslt to transform multiple xml schema documents -- here, the XML schema guru (Michael Kay) also suggests that "manipulating raw schema documents using XSLT is difficult because there are so many different ways of writing the same thing in XSD"
Community
  • 1
  • 1
Leonid Rudy
  • 255
  • 4
  • 5
  • Yes, I actually did see it before, but passed it over for two reasons: it requires a local installation and the generated HTML (although customizable) is a bit too technical, even more technical than Javadoc. Otherwise, I'm sure I would have used it for other purposes. But I do appreciate the tips och links you provided; excellent reading. – Daniel Sep 24 '14 at 17:35
  • I haven't given up on it though, I'm having more of a problem figuring out how to work with the templates. – Daniel Sep 24 '14 at 17:41
  • It cannot be simple. DocFlex/XML XSDDoc is the universal XML schema docgen that covers any XML schemas imaginable, even when the final XML schema is made of lots of XSD files defining (or redefining) thousands of components. Some XML schemas may be extremely complex, at that. (XSD itself is one of the most complex computer languages I've ever learnt!) But our XSDDoc can be customized very much and made to generate user friendly docs for particular tasks. Please, send your questions direct to our contact email or in the support forum. Here is not a good place for such discussions. – Leonid Rudy Sep 24 '14 at 19:58
  • Concerning templates, please read my reply in this thread: http://www.stackoverflow.com/questions/22088541/docflex-document-designer . It is about another our product, but the principle is the same. The templates must be edited in the Template Designer. Also, I suggest to take a look at this promo: http://java.dzone.com/announcements/docflexxml-xml-schema – Leonid Rudy Sep 24 '14 at 20:02
  • Thanks, I will take a look at those. I couldn't agree with you more on the complexity of XSD. It just struck me as a bit odd that given the number of RESTful-WSs out there using XML/XSD, there should be an out-of-the-box HTML generator Maven plugin that, for instance, simply treats a complexType as a message and generates easy-to-read documentation (without the clutter of namespaces, targets, QNames, etc. Laymen usually have no interest in that) about available fields, enumerations and their meaining, which is already documented in the XSD. – Daniel Sep 25 '14 at 05:54
  • Don't get me wrong, you are absolutely right that DocFlex can do all off that (and more), I just didn't think I would have to put in that much work to get what I want, with the templates and all. I just thought that someone had already done the job, given that it's not an unusual use-case. – Daniel Sep 25 '14 at 06:08
  • Well, there are couple more docgens for web-services: http://www.innovasys.com and http://www.adivo.com . They seem to hide all the XSD stuff and generate something looking as Javadoc. We also provide a WSDL docgen: http://www.filigris.com/docflex-xml/wsdldoc/ . In fact, it is also possible to customize it so that to hide most of XSD stuff. – Leonid Rudy Sep 25 '14 at 07:23
  • Concerning simplicity, we started working on our XSDDoc as a demo app for DocFlex/XML, which was supposed to be a main product. But it turned out that that 'demo' took couple of years to finish. In general, the generation of documentation for XSD is much more difficult than for Java. What's more, in some cases the general approach doesn't fit to particular requirements at all. So, a quite different XSD docgen must be developed. – Leonid Rudy Sep 25 '14 at 07:29