<?xml version="1.0" encoding="utf-8"?> check.xsl - An XML stylesheet for transforming checks xml output Copyright (C) 2007-2008 Gary Kramlich <grim@reaperworld.com> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. <xsl:stylesheet version="1.1" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:check="http://check.sourceforge.net/ns" <!-- default parameters --> <xsl:param name="project"/> <xsl:param name="version"/> doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" <!-- number of tests, number of passes, passed percentage --> <xsl:variable name="tests" select="count(/check:testsuites/check:suite/check:test)"/> <xsl:variable name="passes" select="count(/check:testsuites/check:suite/check:test[@result='success'])"/> <xsl:variable name="percent" select="($passes div $tests)"/> <xsl:variable name="script"> element
=
document.getElementById(div);
if(element.style.display
==
'block')
{
element.style.display
=
'none';
element.style.display
=
'block';
elements
=
document.getElementsByTagName('div');
for(i
=
0,
l
=
elements.length;
i
< l;
i++)
{
elements[i].style.display
=
'block';
elements
=
document.getElementsByTagName('div');
for(i
=
0,
l
=
elements.length;
i
< l;
i++)
{
elements[i].style.display
=
'none';
<xsl:variable name="css"> td
{
vertical-align:
top;
}
div
{
display:
none;
padding:
0px;
margin:
0px;
}
div.header
{
display:
block;
}
div.passed-message
{
margin:
2px
0px;
background-color:
#cfffcf;
border:
solid
1px
#7fff7f;
color:
#000000;
}
div.failed-message
{
margin:
2px
0px;
background-color:
#ffcfcf;
border:
solid
1px
#ff7f7f;
color:
#000000;
}
<xsl:variable name="title"> <xsl:when test="$project"> <xsl:value-of select="$project"/> <xsl:text>Unnamed
Project
</xsl:text> <xsl:text> -
Check
Results
</xsl:text> <xsl:variable name="architect"> <xsl:value-of select="$arch"/> <xsl:text>Unknown
</xsl:text> <xsl:variable name="project_version"> <xsl:when test="$version"> <xsl:value-of select="$version"/> <xsl:text>Unknown
</xsl:text> <!-- meat and ... here, where the fuck are my potatoes!?!?! --> <xsl:template match="check:testsuites"> <html xmlns="http://www.w3.org/1999/xhtml"> <script type="text/javascript"> <xsl:copy-of select="$script"/> <xsl:copy-of select="$css"/> <title><xsl:copy-of select="$title"/></title> <h1><xsl:copy-of select="$title"/></h1> <td><strong><xsl:text>Version:
</xsl:text></strong></td> <td><xsl:copy-of select="$project_version"/></td> <td><strong><xsl:text>Architect:
</xsl:text></strong></td> <td><xsl:copy-of select="$architect"/></td> <td><strong><xsl:text>Ran
on:
</xsl:text></strong></td> <td><xsl:value-of select="check:datetime"/></td> <td><strong><xsl:text>Duration:
</xsl:text></strong></td> <td><xsl:value-of select="format-number(check:duration, '###.##')"/><xsl:text> seconds
</xsl:text></td> <td><strong>Results:
</strong></td> <xsl:copy-of select="$passes"/> <xsl:text> of
</xsl:text> <xsl:copy-of select="$tests"/> <xsl:value-of select="format-number($percent, '###.##%')"/> <xsl:text>)
tests
passed
</xsl:text> <a href="javascript:show_all()">Show
all
messages
</a> <a href="javascript:hide_all()">Hide
all
messages
</a> <xsl:for-each select="check:suite"> <xsl:if test="check:test"> <td colspan="2"><h2><xsl:value-of select="check:title"/></h2></td> <xsl:for-each select="check:test"> <xsl:attribute name="href"> <xsl:text>javascript:toggle('
</xsl:text> <xsl:value-of select="check:id"/> <xsl:value-of select="translate(check:id, '_', ' ')"/> <xsl:when test="@result='success'"> <img src="passed.png" alt="passed"/> <img src="failed.png" alt="failed"/> <xsl:attribute name="id"> <xsl:value-of select="check:id"/> <xsl:attribute name="class"> <xsl:when test="@result='success'"> <xsl:text>passed-message
</xsl:text> <xsl:text>failed-message
</xsl:text> <pre><xsl:value-of select="check:message"/></pre>