The Artima Developer Community
Sponsored Link

Java Buzz Forum
Transforming WADL Documents to Documentation

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Wilfred Springer

Posts: 176
Nickname: springerw
Registered: Sep, 2006

Wilfred Springer is a Software Architect at Xebia
Transforming WADL Documents to Documentation Posted: Sep 12, 2009 7:29 AM
Reply to this message Reply

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
Latest Java Buzz Posts
Latest Java Buzz Posts by Wilfred Springer
Latest Posts From Distributed Reflections of the Third Kind

Advertisement
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/.


<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:wadl-utils="xalan://org.jvnet.ws.wadl.xslt.WadlXsltUtils"
xmlns:wadl="http://wadl.dev.java.net/2009/02"
exclude-result-prefixes="wadl-utils">

<xsl:output method="text"/>

<xsl:template match="/">
<xsl:for-each select="//wadl:resource[@path]">
<xsl:value-of select="@path"/>
<xsl:text>: </xsl:text>
<xsl:for-each select="wadl-utils:parse(@path)/path/*">
<xsl:text>[</xsl:text>
<xsl:value-of select="local-name(.)"/>
<xsl:text>: '</xsl:text>
<xsl:value-of select="text()"/>
<xsl:text>']</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>

</xsl:stylesheet>

Read: Transforming WADL Documents to Documentation

Topic: AOL hires Yahoo's former `peanut butter manifesto' executive for new Silicon Valley post Previous Topic   Next Topic Topic: GUIdancer 3.1 supports GEF components

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use