This repository has been archived by the owner on Jun 6, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
svrl-to-html.xsl
executable file
·89 lines (84 loc) · 2.86 KB
/
svrl-to-html.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
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:svrl="http://purl.oclc.org/dsdl/svrl"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:j4r="http://jats4r.org/ns"
version="2.0" exclude-result-prefixes="svrl">
<xsl:output method="html" omit-xml-declaration="yes" standalone="no" indent="yes"/>
<xsl:template match="svrl:schematron-output">
<xsl:result-document href="#schematron-results">
<div>
<p>Checks performed:</p>
<ul>
<xsl:apply-templates select="svrl:active-pattern"/>
</ul>
<xsl:variable name='problems' select='svrl:failed-assert|svrl:successful-report'/>
<xsl:choose>
<xsl:when test="$problems">
<table class='results'>
<thead>
<tr>
<th>Location</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<xsl:for-each select="$problems">
<xsl:call-template name='problem-report'/>
</xsl:for-each>
</tbody>
</table>
</xsl:when>
<xsl:otherwise>
<p>No problems were found.</p>
</xsl:otherwise>
</xsl:choose>
</div>
</xsl:result-document>
</xsl:template>
<xsl:template match="svrl:active-pattern">
<li>
<xsl:value-of select="@name"/>
</li>
</xsl:template>
<xsl:template name='problem-report'>
<xsl:variable name='active-pattern'
select='preceding-sibling::svrl:active-pattern[1]/@name'/>
<xsl:variable name='topic'
select='replace($active-pattern, "(.*)-.*", "$1")'/>
<xsl:variable name='level'>
<xsl:choose>
<xsl:when test="contains($active-pattern, 'errors')">
<xsl:value-of select="'error'"/>
</xsl:when>
<xsl:when test="contains($active-pattern, 'warnings')">
<xsl:value-of select="'warn'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'info'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:variable name='rec' select='.//j4r:meta/@rec'/>
<tr>
<td class='{$level}'>
<!-- Insert zero-width spaces to allow the browser to wrap the location cell -->
<span class='xpath-display'>
<xsl:value-of select="replace(@location, '/', '​/​')"/>
</span>
<span class='xpath-location'>
<xsl:value-of select='@location'/>
</span>
</td>
<td class='{$level}'>
<xsl:apply-templates select="svrl:text"/>
<xsl:if test='$rec'>
(<a href='../recommendations/{$topic}.html#{$rec}' target="_blank">
<img src='assets/Icon_External_Link.png'/>
</a>)
</xsl:if>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>