I've thought about how we could simplify the ViewPlatform and its
various plugins, as they are getting more and more complicated and
harder to maintain.
To keep things short: I've come back to the initial idea of using XSLT
stylesheets to do the conversion. This means that the
PrintSelectionPlugin (which currently has two responsibilities - node
ordering and string generation) and WhitespacePlugin would all be
merged together. In a stylesheet all 3 responsibilities will be handled
by each template. Here's the current list of pros and cons for XSLT
usage. If you know of any further reasons please add them to the list on
http://www.uni-ulm.de/~s_fraise/cgi-bin/moin.cgi/ToDo
* Pros for XSLT:
o No need to learn details about the ViewPlatform, whereas many developers are already familiar with XSLT/XPath
o Allows easy adjustment of output even for people not very familiar with the inner workings
o Removes the distinction of print selection, printed strings and whitespace and ties it all into one small template
* Cons for XSLT:
o Can be harder to write than java for complicated tasks
o XSLT/XPath as additional languages must be known to the programmer
o Subclassing plugins is not possible. Instead the whole stylesheet has to be copied and modified.
I'm currently working on a sample implementation and here's a small part
of how such a stylesheet would look like:
<xsl:template match="method">
<xsl:apply-templates select="comment|javadoc"><xsl:with-param name="indent" select="$indent"/></xsl:apply-templates>
<xsl:apply-templates select="modifiers"><xsl:with-param name="indent" select="$indent"/></xsl:apply-templates>
<xsl:apply-templates select="type"><xsl:with-param name="indent" select="$indent"/></xsl:apply-templates>
<xsl:if test="@type != 'constructor'"><xsl:text> </xsl:text></xsl:if>
<xsl:value-of select="@name"/>
<!-- TODO parameterization-->
<xsl:text>(</xsl:text>
<xsl:apply-templates select="parameters"><xsl:with-param name="indent" select="$indent"/></xsl:apply-templates>
<xsl:text>)</xsl:text>
<xsl:apply-templates select="throws"><xsl:with-param name="indent" select="$indent"/></xsl:apply-templates>
<xsl:text> </xsl:text>
<xsl:apply-templates select="block"><xsl:with-param name="indent" select="$indent"/></xsl:apply-templates>
<xsl:text> </xsl:text>
</xsl:template>
<xsl:template match="modifiers">
<xsl:call-template name="WS"><xsl:with-param name="indent" select="$indent"/></xsl:call-template>
<xsl:for-each select="modifier">
<xsl:value-of select="@name"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
--
Raiser, Frank
Student @ University of Ulm (www.uni-ulm.de)
parsing strings with commands designed to parse strings is the worlds
leading killer of poorly written scripts. -- unknown
|