diff options
-rw-r--r-- | rcynic/rcynic.xsl | 70 |
1 files changed, 38 insertions, 32 deletions
diff --git a/rcynic/rcynic.xsl b/rcynic/rcynic.xsl index d038c927..ebe854d4 100644 --- a/rcynic/rcynic.xsl +++ b/rcynic/rcynic.xsl @@ -19,12 +19,20 @@ <!-- - XSL stylesheet to render rcynic's xml-summary output as basic (X)HTML. + - + - This is a bit more complicated than strictly necessary, because I wanted + - the ability to drop out columns that are nothing but zeros. + - There's probably some clever way of using XPath to simplify this, + - but I don't expect the data sets to be large enough for performance + - to be an issue here. Feel free to show me how to do better. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output omit-xml-declaration="yes" indent="yes" method="xml" encoding="US-ASCII"/> + <xsl:param name="suppress-zero-columns" select="1"/> + <xsl:template match="/"> <html> <head> @@ -33,42 +41,40 @@ <body> <h1>rcynic summary</h1> <br/> - <xsl:apply-templates/> + <table rules="all"> + <thead> + <tr> + <xsl:for-each select="rcynic-summary/labels/*"> + <xsl:variable name="name" select="local-name()"/> + <xsl:if test="$suppress-zero-columns = 0 or count(/rcynic-summary/host/*[local-name() = $name and . != 0]) > 0"> + <td> + <b> + <xsl:apply-templates/> + </b> + </td> + </xsl:if> + </xsl:for-each> + </tr> + </thead> + <tbody> + <xsl:for-each select="rcynic-summary/host"> + <tr> + <xsl:for-each select="*"> + <xsl:variable name="name" select="local-name()"/> + <xsl:if test="$suppress-zero-columns = 0 or count(/rcynic-summary/host/*[local-name() = $name and . != 0]) > 0"> + <td> + <xsl:apply-templates/> + </td> + </xsl:if> + </xsl:for-each> + </tr> + </xsl:for-each> + </tbody> + </table> </body> </html> </xsl:template> - <xsl:template match="/rcynic-summary"> - <table rules="all"> - <thead> - <xsl:apply-templates select="labels"/> - </thead> - <tbody> - <xsl:apply-templates select="host"/> - </tbody> - </table> - </xsl:template> - - <xsl:template match="/rcynic-summary/*"> - <tr> - <xsl:apply-templates/> - </tr> - </xsl:template> - - <xsl:template match="/rcynic-summary/labels/*"> - <td> - <b> - <xsl:apply-templates/> - </b> - </td> - </xsl:template> - - <xsl:template match="/rcynic-summary/host/*"> - <td> - <xsl:apply-templates/> - </td> - </xsl:template> - </xsl:stylesheet> <!-- |