This post originated from an RSS feed registered with Java Buzz
by Wilfred Springer.
Original Post: Transforming WADL Documents to Documentation
Feed Title: Distributed Reflections of the Third Kind
Feed URL: http://blog.flotsam.nl/feeds/posts/default/-/Java
Feed Description: Anything coming to my mind having to do with Java
Two years ago, Mark Nottingham published an XSLT stylesheet to transform a WADL document into a human readable document. When I tried to create something similar a year ago, I immediately ran into a problem when trying to split a resource path into text and parameter parts. I'm sure you can get something done by calling a template recursively, but I wondered how hard it would be to do it using an XSLT extension function.
I figured I would give it a go, and created a function that will return a Nodset with the different parts of the path attribute. The stylesheet down below is using it. It will iterate over all resources with a path attribute, and then for each resource apply the wadl-utils:parse() function to its @path attribute. This function will return a new document, and since it is an XML document, we can apply an XPath expression on it. In this case, the XPath expression is /path/*. So, inside of the for-each loop visiting all resources, there is another for-each loop visiting all parts of the @path attribute.
Looking back, it's questionable if something like this couldn't have been done using plain old XSLT, but it was an interesting excercise anyway. The code is in the WADL repository at http://wadl.dev.java.net/.