-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmake-html-tables.xsl
109 lines (101 loc) · 3.02 KB
/
make-html-tables.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/REC-html40">
<xsl:output indent="yes" method="html" version = "4.0"/>
<xsl:template match="/">
<html>
<head>
<title>Postgres benchmarking results</title>
</head>
<style type="text/css">
td {
text-align: right
}
tr td:first-child {
text-align: left
}
tr th {
text-align: center
}
</style>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="benchmarking/run">
<h3>Benchmarking run started at <xsl:value-of select="@started"/>
<xsl:if test="@ended">, ended at <xsl:value-of select="@ended"/></xsl:if>
</h3>
<div>
<xsl:apply-templates/>
</div>
</xsl:template>
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="with" select="$with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="benchmark">
<table border="1" cellspacing="0">
<caption>Benchmark <xsl:value-of select="@id"/></caption>
<thead><tr><th>Instance</th>
<xsl:for-each select="instance/metric/@id[not(. = ../../preceding-sibling::instance/metric/@id)]">
<xsl:sort data-type="number" order="descending" />
<th>
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="."/>
<xsl:with-param name="replace" select="'_'" />
<xsl:with-param name="with" select="'_​'"/>
</xsl:call-template>
</th>
</xsl:for-each>
</tr></thead>
<tbody>
<xsl:for-each select="instance">
<xsl:variable name="inst" select="."/>
<tr><td><xsl:value-of select="@id"/></td>
<xsl:for-each select="../instance/metric/@id[not(. = ../../preceding-sibling::instance/metric/@id)]">
<xsl:sort data-type="number" order="descending" />
<td>
<xsl:variable name="mid" select="." />
<xsl:variable name="val" select="$inst/metric[@id=$mid]/@value" />
<xsl:choose>
<xsl:when test="$val!=''">
<xsl:choose>
<xsl:when test="$mid='version'">
<xsl:value-of select="$val"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="format-number($val, '0.00')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
 
</xsl:otherwise>
</xsl:choose>
</td>
</xsl:for-each>
</tr>
</xsl:for-each>
</tbody>
</table>
<br />
</xsl:template>
</xsl:stylesheet>