| 1 |
<?xml version='1.0' encoding='utf-8'?><!-- -*- indent-tabs-mode: nil -*- --> |
| 2 |
|
| 3 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 4 |
version="1.0"> |
| 5 |
|
| 6 |
<xsl:template match="/report"> |
| 7 |
<html> |
| 8 |
<head> |
| 9 |
<title>Stylesheet Report</title> |
| 10 |
<style type="text/css"> |
| 11 |
body { font-family: sans-serif; } |
| 12 |
th { text-align: left; } |
| 13 |
td { vertical-align: top; padding: 0.2em; } |
| 14 |
tr[class="odd"] { background-color: #EEEEEE; } |
| 15 |
span[class="file"] { color: #102070; } |
| 16 |
span[class="mode"] { color: #702010; } |
| 17 |
a { color: #945904; text-decoration: none; } |
| 18 |
a:hover { text-decoration: underline; } |
| 19 |
</style> |
| 20 |
</head> |
| 21 |
<body> |
| 22 |
<p> |
| 23 |
<xsl:variable name="total" select="count(element)"/> |
| 24 |
<xsl:variable name="matched" |
| 25 |
select="count(element[@name = |
| 26 |
/report/file/template[not(@mode)]/@match])"/> |
| 27 |
<xsl:variable name="unmatched" select="$total - $matched"/> |
| 28 |
|
| 29 |
<xsl:value-of select="$unmatched"/> |
| 30 |
<xsl:text> unmatched elements</xsl:text> |
| 31 |
<br/> |
| 32 |
<xsl:value-of select="$matched"/> |
| 33 |
<xsl:text> matched elements</xsl:text> |
| 34 |
<br/> |
| 35 |
<xsl:value-of select="$total"/> |
| 36 |
<xsl:text> total elements</xsl:text> |
| 37 |
<br/> |
| 38 |
<xsl:number value="($matched div $total) * 100"/> |
| 39 |
<xsl:text>% of elements matched</xsl:text> |
| 40 |
</p> |
| 41 |
<table> |
| 42 |
<tr> |
| 43 |
<th>Element</th> |
| 44 |
<th>Simple Matches</th> |
| 45 |
<th>Mode Matches</th> |
| 46 |
</tr> |
| 47 |
<xsl:for-each select="element"> |
| 48 |
<tr> |
| 49 |
<xsl:if test="position() mod 2 = 1"> |
| 50 |
<xsl:attribute name="class"> |
| 51 |
<xsl:text>odd</xsl:text> |
| 52 |
</xsl:attribute> |
| 53 |
</xsl:if> |
| 54 |
<td> |
| 55 |
<span class="element"> |
| 56 |
<a href="{concat('http://www.docbook.org/tdg/en/html/', |
| 57 |
@name, '.html')}"> |
| 58 |
<xsl:value-of select="@name"/> |
| 59 |
</a> |
| 60 |
</span> |
| 61 |
</td> |
| 62 |
<td> |
| 63 |
<xsl:for-each select=" |
| 64 |
/report/file/template[not(@mode)][@match=current()/@name]"> |
| 65 |
<xsl:if test="position() != 1"> |
| 66 |
<br/> |
| 67 |
</xsl:if> |
| 68 |
<span class="file"> |
| 69 |
<xsl:value-of select="../@href"/> |
| 70 |
</span> |
| 71 |
</xsl:for-each> |
| 72 |
</td> |
| 73 |
<td> |
| 74 |
<xsl:for-each select=" |
| 75 |
/report/file/template[@mode][@match=current()/@name]"> |
| 76 |
<xsl:if test="position() != 1"> |
| 77 |
<br/> |
| 78 |
</xsl:if> |
| 79 |
<span class="file"> |
| 80 |
<xsl:value-of select="../@href"/> |
| 81 |
</span> |
| 82 |
<xsl:text> in </xsl:text> |
| 83 |
<span class="mode"> |
| 84 |
<xsl:value-of select="@mode"/> |
| 85 |
</span> |
| 86 |
</xsl:for-each> |
| 87 |
</td> |
| 88 |
</tr> |
| 89 |
</xsl:for-each> |
| 90 |
</table> |
| 91 |
</body> |
| 92 |
</html> |
| 93 |
</xsl:template> |
| 94 |
|
| 95 |
<xsl:template match="/_report"> |
| 96 |
<report> |
| 97 |
<xsl:apply-templates/> |
| 98 |
</report> |
| 99 |
</xsl:template> |
| 100 |
|
| 101 |
<xsl:template match="_element"> |
| 102 |
<element name="{@name}"/> |
| 103 |
</xsl:template> |
| 104 |
|
| 105 |
<xsl:template match="_file"> |
| 106 |
<file href="{@href}"> |
| 107 |
<xsl:apply-templates/> |
| 108 |
</file> |
| 109 |
</xsl:template> |
| 110 |
|
| 111 |
<xsl:template match="_template"> |
| 112 |
<xsl:call-template name="tokenize.template"> |
| 113 |
<xsl:with-param name="string" select="normalize-space(@match)"/> |
| 114 |
<xsl:with-param name="mode" select="@mode"/> |
| 115 |
</xsl:call-template> |
| 116 |
</xsl:template> |
| 117 |
|
| 118 |
<xsl:template name="tokenize.template"> |
| 119 |
<xsl:param name="mode" select="false()"/> |
| 120 |
<xsl:param name="depth" select="0"/> |
| 121 |
<xsl:param name="before" select="''"/> |
| 122 |
<xsl:param name="string"/> |
| 123 |
<xsl:variable name="firstchar"> |
| 124 |
<xsl:choose> |
| 125 |
<xsl:when test="contains($string, '[') and |
| 126 |
not(contains(substring-before($string, '['), '|')) and |
| 127 |
not(contains(substring-before($string, '['), ']')) "> |
| 128 |
<xsl:text>[</xsl:text> |
| 129 |
</xsl:when> |
| 130 |
<xsl:when test="contains($string, ']') and |
| 131 |
not(contains(substring-before($string, ']'), '|')) and |
| 132 |
not(contains(substring-before($string, ']'), '[')) "> |
| 133 |
<xsl:text>]</xsl:text> |
| 134 |
</xsl:when> |
| 135 |
<xsl:when test="contains($string, '|') and |
| 136 |
not(contains(substring-before($string, '|'), '[')) and |
| 137 |
not(contains(substring-before($string, '|'), ']')) "> |
| 138 |
<xsl:text>|</xsl:text> |
| 139 |
</xsl:when> |
| 140 |
<xsl:otherwise> |
| 141 |
<xsl:text></xsl:text> |
| 142 |
</xsl:otherwise> |
| 143 |
</xsl:choose> |
| 144 |
</xsl:variable> |
| 145 |
<xsl:choose> |
| 146 |
<xsl:when test="not(contains($string, '|'))"> |
| 147 |
<template match="{normalize-space(concat($before, $string))}"> |
| 148 |
<xsl:if test="$mode"> |
| 149 |
<xsl:attribute name="mode"> |
| 150 |
<xsl:value-of select="$mode"/> |
| 151 |
</xsl:attribute> |
| 152 |
</xsl:if> |
| 153 |
</template> |
| 154 |
</xsl:when> |
| 155 |
<xsl:when test="$firstchar = '['"> |
| 156 |
<xsl:call-template name="tokenize.template"> |
| 157 |
<xsl:with-param name="mode" select="$mode"/> |
| 158 |
<xsl:with-param name="depth" select="$depth + 1"/> |
| 159 |
<xsl:with-param name="before" |
| 160 |
select="concat($before, |
| 161 |
substring-before($string, '['), |
| 162 |
'[')"/> |
| 163 |
<xsl:with-param name="string" select="substring-after($string, '[')"/> |
| 164 |
</xsl:call-template> |
| 165 |
</xsl:when> |
| 166 |
<xsl:when test="$depth != 0"> |
| 167 |
<xsl:call-template name="tokenize.template"> |
| 168 |
<xsl:with-param name="mode" select="$mode"/> |
| 169 |
<xsl:with-param name="depth" select="$depth - 1"/> |
| 170 |
<xsl:with-param name="before" |
| 171 |
select="concat($before, |
| 172 |
substring-before($string, ']'), |
| 173 |
']')"/> |
| 174 |
<xsl:with-param name="string" select="substring-after($string, ']')"/> |
| 175 |
</xsl:call-template> |
| 176 |
</xsl:when> |
| 177 |
<xsl:otherwise> |
| 178 |
<template match="{normalize-space( |
| 179 |
concat($before, substring-before($string, '|')))}"> |
| 180 |
<xsl:if test="$mode"> |
| 181 |
<xsl:attribute name="mode"> |
| 182 |
<xsl:value-of select="$mode"/> |
| 183 |
</xsl:attribute> |
| 184 |
</xsl:if> |
| 185 |
</template> |
| 186 |
<xsl:call-template name="tokenize.template"> |
| 187 |
<xsl:with-param name="mode" select="$mode"/> |
| 188 |
<xsl:with-param name="depth" select="0"/> |
| 189 |
<xsl:with-param name="before" select="''"/> |
| 190 |
<xsl:with-param name="string" select="substring-after($string, '|')"/> |
| 191 |
</xsl:call-template> |
| 192 |
</xsl:otherwise> |
| 193 |
</xsl:choose> |
| 194 |
</xsl:template> |
| 195 |
|
| 196 |
</xsl:stylesheet> |