Skip to content

Commit eadc13a

Browse files
committed
Update bundled XSpec to v3.2.2
- New VERSION file - New CSS files and various modifications for color themes - Contents section of XSLT code coverage report - Schematron properties - Schematron fix from XSpec v3.1.3 (#2027) - Updated SchXslt
1 parent e74c028 commit eadc13a

17 files changed

+1024
-48
lines changed

frameworks/xspec/build.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,8 @@
487487
<param name="force-focus" expression="${xspec.force.focus}"
488488
if="xspec.force.focus" />
489489
<param name="inline-css" expression="true" />
490+
<param name="report-theme" expression="${xspec.html.report.theme}"
491+
if="xspec.html.report.theme" />
490492
<param name="report-css-uri" expression="${xspec.result.html.css.url}"
491493
if="xspec.result.html.css.url" />
492494
</xslt-elements>
@@ -515,6 +517,8 @@
515517
<pathelement location="${xspec.project.dir}/java" />
516518
</classpath>
517519
<param name="inline-css" expression="true" />
520+
<param name="report-theme" expression="${xspec.html.report.theme}"
521+
if="xspec.html.report.theme" />
518522
<param name="report-css-uri" expression="${xspec.coverage.html.css.url}"
519523
if="xspec.coverage.html.css.url" />
520524
</xslt-elements>

frameworks/xspec/lib/schxslt/1.0/version.xsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
xmlns:skos="http://www.w3.org/2004/02/skos/core#">
88
<dct:creator>
99
<dct:Agent>
10-
<skos:prefLabel>SchXslt/1.10 (XSLT 1.0)</skos:prefLabel>
10+
<skos:prefLabel>SchXslt/1.10.1 (XSLT 1.0)</skos:prefLabel>
1111
</dct:Agent>
1212
</dct:creator>
1313
</rdf:Description>

frameworks/xspec/lib/schxslt/2.0/compile/compile-2.0.xsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@
6464
</xsl:call-template>
6565
</xsl:variable>
6666

67-
<xsl:variable name="version" as="element(rdf:Description)">
67+
<xsl:variable name="version" as="element(rdf:Description)?">
68+
<xsl:if test="$schxslt.compile.metadata">
6869
<xsl:call-template name="schxslt:version">
6970
<xsl:with-param name="xslt-version" as="xs:string" tunnel="yes" select="$xslt-version"/>
7071
</xsl:call-template>
72+
</xsl:if>
7173
</xsl:variable>
7274

7375
<transform version="{$xslt-version}">

frameworks/xspec/lib/schxslt/2.0/version.xsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</xsl:template>
1919

2020
<xsl:function name="schxslt:user-agent" as="xs:string">
21-
<xsl:variable name="schxslt-ident" as="xs:string">SchXslt/1.10</xsl:variable>
21+
<xsl:variable name="schxslt-ident" as="xs:string">SchXslt/1.10.1</xsl:variable>
2222
<xsl:variable name="xslt-ident" as="xs:string">
2323
<xsl:value-of separator="/" select="(system-property('xsl:product-name'), system-property('xsl:product-version'))"/>
2424
</xsl:variable>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.2.2

frameworks/xspec/src/reporter/coverage-compute-status.xsl

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
is in the trace. Other logic builds upon this information. -->
1414
<xsl:accumulator name="category-based-on-trace-data" as="xs:string*" initial-value="()">
1515
<xsl:accumulator-rule match="element() | text()">
16-
<xsl:variable name="hits-on-node"
16+
<xsl:variable name="hits-on-node" as="element(hit)*"
1717
select="local:hits-on-node(.)"/>
1818
<xsl:choose>
1919
<xsl:when test="exists($hits-on-node)">
@@ -76,16 +76,28 @@
7676
7777
| XSLT:output-character
7878
79-
| text()[normalize-space() = '' and not(parent::XSLT:text)]
8079
| processing-instruction()
81-
| comment()
8280
| document-node()"
8381
mode="coverage"
8482
as="xs:string"
8583
priority="30">
8684
<xsl:sequence select="'ignored'"/>
8785
</xsl:template>
8886

87+
<xsl:template match="text()[normalize-space() = '' and not(parent::XSLT:text)]"
88+
mode="coverage"
89+
as="xs:string"
90+
priority="30">
91+
<xsl:sequence select="'whitespace'"/>
92+
</xsl:template>
93+
94+
<xsl:template match="comment()"
95+
mode="coverage"
96+
as="xs:string"
97+
priority="30">
98+
<xsl:sequence select="'comment'"/>
99+
</xsl:template>
100+
89101
<!-- A node within a top-level non-XSLT element -->
90102
<!-- In case a descendant is an XSLT element, priority makes us match this
91103
template instead of one that handles ordinary XSLT instructions outside
@@ -218,9 +230,13 @@
218230
<!-- Global variables effectively follow the Use Trace Data rule. -->
219231
<xsl:sequence select="'missed'"/>
220232
</xsl:when>
221-
<xsl:otherwise>
233+
<xsl:when test="following-sibling::*[not(self::XSLT:variable)]">
222234
<xsl:apply-templates select="following-sibling::*[not(self::XSLT:variable)][1]"
223235
mode="#current"/>
236+
</xsl:when>
237+
<xsl:otherwise>
238+
<!-- Local variable with no following siblings except other local variables -->
239+
<xsl:sequence select="'missed'"/>
224240
</xsl:otherwise>
225241
</xsl:choose>
226242
</xsl:template>
@@ -323,7 +339,7 @@
323339

324340
<!-- Low-priority fallback template rule -->
325341
<xsl:template match="node()" mode="untraceable-in-instruction"
326-
priority="-10">
342+
as="xs:string" priority="-10">
327343
<xsl:sequence select="'traceable executable'"/>
328344
</xsl:template>
329345

@@ -362,7 +378,8 @@
362378
| XSLT:when
363379
| XSLT:where-populated
364380
| XSLT:with-param"
365-
mode="untraceable-in-instruction">
381+
mode="untraceable-in-instruction"
382+
as="xs:string">
366383
<!--
367384
Some of the elements listed in the match attribute are not strictly needed
368385
in order to achieve the caller's objective, because the elements have a

frameworks/xspec/src/reporter/coverage-report.xsl

Lines changed: 175 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
<xsl:param name="inline-css" as="xs:string" select="false() cast as xs:string" />
3636

3737
<xsl:param name="report-css-uri" as="xs:string?" />
38+
<!-- See also report-theme parameter, which is defined in format-utils.xsl -->
3839

3940
<!-- @use-character-maps for inline CSS -->
4041
<xsl:output method="xhtml" use-character-maps="fmt:disable-escaping" />
@@ -45,6 +46,35 @@
4546
<xsl:variable name="xspec-doc" as="document-node(element(x:description))"
4647
select="doc($xspec-uri)" />
4748

49+
<!-- Get the *-result.xml file. It contains the date/time the test was run. -->
50+
<xsl:variable name="result-uri" as="xs:string"
51+
select="replace(base-uri(), '-coverage\.xml', '-result.xml')" />
52+
<xsl:variable name="result-doc" as="document-node(element(x:report))">
53+
<xsl:choose>
54+
<xsl:when test="doc-available($result-uri)">
55+
<xsl:sequence select="doc($result-uri)"/>
56+
</xsl:when>
57+
<xsl:otherwise>
58+
<!-- End-to-end coverage tests don't have access to *-result.xml.
59+
We could make the *-result.xml file available by modifying
60+
<xsl:variable as="element(reports)" name="reports">
61+
in test/end-to-end/ant/base/worker/generate.xsl, but then
62+
we'd have many *-result.xml files to maintain with little benefit.
63+
Instead, the end-to-end coverage HTML reports use the date from
64+
mock-result.xml. -->
65+
<xsl:variable name="mock-result-uri" as="xs:anyURI"
66+
select="resolve-uri('../mock-result.xml', $xspec-uri)"/>
67+
<xsl:sequence select="doc($mock-result-uri)"/>
68+
</xsl:otherwise>
69+
</xsl:choose>
70+
</xsl:variable>
71+
72+
<xsl:accumulator name="computed-status" as="xs:string?" initial-value="()">
73+
<xsl:accumulator-rule match="node()" phase="start">
74+
<xsl:apply-templates select="." mode="coverage"/>
75+
</xsl:accumulator-rule>
76+
</xsl:accumulator>
77+
4878
<xsl:variable name="stylesheet-uri" as="xs:anyURI"
4979
select="$xspec-doc/x:description/resolve-uri(@stylesheet, base-uri())" />
5080

@@ -69,6 +99,39 @@
6999
-->
70100
<xsl:mode name="coverage-report" on-multiple-match="fail" on-no-match="fail" />
71101

102+
<!-- Collect stats data in this variable for all modules. -->
103+
<xsl:variable name="coverage-stats" as="element(module)*">
104+
<!-- Collect from all stylesheet modules -->
105+
<xsl:for-each select="$stylesheet-trees/xsl:*">
106+
<!-- Produce local variables for stylesheet-lines and number-of-lines -->
107+
<xsl:variable name="stylesheet-uri" as="xs:anyURI"
108+
select="base-uri()" />
109+
<xsl:variable name="stylesheet-string" as="xs:string"
110+
select="unparsed-text($stylesheet-uri)" />
111+
<xsl:variable name="stylesheet-lines" as="xs:string+"
112+
select="local:split-lines($stylesheet-string)" />
113+
<xsl:variable name="number-of-lines" as="xs:integer"
114+
select="count($stylesheet-lines)" />
115+
<xsl:variable name="module-id" as="xs:integer?"
116+
select="accumulator-before('module-id-for-node')" />
117+
<!-- Create module element with attributes that will be used later -->
118+
<module uri="{$stylesheet-uri}" number-of-lines="{$number-of-lines}"
119+
formatted-uri="{fmt:format-uri($stylesheet-uri)}" module-id="{$module-id}" xmlns="">
120+
<xsl:if test="not(empty($module-id))">
121+
<xsl:for-each select="
122+
doc($stylesheet-uri)/(
123+
descendant::node() except
124+
descendant::text()[normalize-space() = '' and not(parent::xsl:text)]
125+
)">
126+
<coverage xmlns="">
127+
<xsl:sequence select="accumulator-before('computed-status')"/>
128+
</coverage>
129+
</xsl:for-each>
130+
</xsl:if>
131+
</module>
132+
</xsl:for-each>
133+
</xsl:variable>
134+
72135
<xsl:template match="document-node(element(trace))" as="element(xhtml:html)"
73136
mode="coverage-report">
74137
<html>
@@ -81,19 +144,116 @@
81144
<xsl:with-param name="uri" select="$report-css-uri" />
82145
</xsl:call-template>
83146
</head>
84-
<body>
147+
<body id="coverageReport">
85148
<h1>Test Coverage Report</h1>
86149
<p>
87150
<xsl:text>Stylesheet: </xsl:text>
88151
<a href="{$stylesheet-uri}">
89152
<xsl:value-of select="fmt:format-uri($stylesheet-uri)" />
90153
</a>
154+
<!-- Commented out until XSpec version is available
155+
<span class="byline">Generated by XSpec v<xsl:value-of select="'x.y.z'" /> using Saxon <xsl:value-of select="system-property('xsl:product-version')" /></span>
156+
-->
157+
</p>
158+
<p>
159+
<xsl:text>XSpec: </xsl:text>
160+
<a href="{$xspec-uri}">
161+
<xsl:value-of select="fmt:format-uri($xspec-uri)" />
162+
</a>
91163
</p>
164+
<p>
165+
<xsl:text>Tested: </xsl:text>
166+
<xsl:value-of select="format-dateTime($result-doc/x:report/@date, '[D] [MNn] [Y] at [H01]:[m01]')" />
167+
</p>
168+
<!-- The Contents table -->
169+
<h2>Contents</h2>
170+
<xsl:call-template name="contents-table"/>
92171
<xsl:apply-templates select="$stylesheet-trees/xsl:*" mode="#current" />
93172
</body>
94173
</html>
95174
</xsl:template>
96175

176+
<!-- Generate Contents table at top of coverage report -->
177+
<!-- In production, always use the global $coverage-stats variable.
178+
The template parameter is for unit testing this template. -->
179+
<xsl:template name="contents-table" as="element(xhtml:table)">
180+
<xsl:param name="coverage-stats" select="$coverage-stats"
181+
as="element(module)*"/>
182+
<table class="xspec">
183+
<colgroup>
184+
<col style="width:68.75%"/>
185+
<col style="width:6.25%"/>
186+
<col style="width:6.25%"/>
187+
<col style="width:6.25%"/>
188+
<col style="width:6.25%"/>
189+
<col style="width:6.25%"/>
190+
</colgroup>
191+
<thead>
192+
<tr>
193+
<th/>
194+
<th/>
195+
<th colspan="3" class="totals nodesHead">nodes</th>
196+
<th/>
197+
</tr>
198+
<tr>
199+
<th/>
200+
<th class="totals">used</th>
201+
<th class="totals">
202+
<xsl:text>hit</xsl:text>
203+
<br/>
204+
<xsl:value-of select="count($coverage-stats/coverage[. eq 'hit'])"/>
205+
</th>
206+
<th class="totals emphasis">
207+
<xsl:text>missed</xsl:text>
208+
<br/>
209+
<xsl:value-of select="count($coverage-stats/coverage[. eq 'missed'])"/>
210+
</th>
211+
<th class="totals">
212+
<xsl:text>unknown</xsl:text>
213+
<br/>
214+
<xsl:value-of select="count($coverage-stats/coverage[. eq 'unknown'])"/>
215+
</th>
216+
<th class="totals">
217+
<xsl:text>lines</xsl:text>
218+
<br/>
219+
<xsl:value-of select="sum($coverage-stats/@number-of-lines)"/>
220+
</th>
221+
</tr>
222+
</thead>
223+
<tbody>
224+
<!-- Use the coverage-stats data -->
225+
<xsl:for-each select="$coverage-stats">
226+
<tr class="{if (@module-id eq '') then 'failed' else 'successful'}">
227+
<th>
228+
<a href="#module{position()}">
229+
<xsl:text expand-text="yes">module: {@formatted-uri}</xsl:text>
230+
</a>
231+
</th>
232+
<th class="totals">
233+
<xsl:value-of select="
234+
if (@module-id eq '') then
235+
'no'
236+
else
237+
'yes'"/>
238+
</th>
239+
<th class="totals">
240+
<xsl:value-of select="count(coverage[. eq 'hit'])"/>
241+
</th>
242+
<th class="totals">
243+
<xsl:value-of select="count(coverage[. eq 'missed'])"/>
244+
</th>
245+
<th class="totals">
246+
<xsl:value-of select="count(coverage[. eq 'unknown'])"/>
247+
</th>
248+
<th class="totals">
249+
<xsl:value-of select="@number-of-lines"/>
250+
</th>
251+
</tr>
252+
</xsl:for-each>
253+
</tbody>
254+
</table>
255+
</xsl:template>
256+
97257
<xsl:template match="xsl:stylesheet | xsl:transform" as="element()+" mode="coverage-report">
98258
<xsl:variable name="stylesheet-uri" as="xs:anyURI"
99259
select="base-uri()" />
@@ -109,15 +269,24 @@
109269
select="string-join(for $i in 1 to $number-width return '0')" />
110270
<xsl:variable name="module-id" as="xs:integer?"
111271
select="accumulator-before('module-id-for-node')"/>
112-
<h2>
113-
<xsl:text expand-text="yes">module: {fmt:format-uri($stylesheet-uri)}; {$number-of-lines} lines</xsl:text>
272+
<!-- div allows the :target CSS style to cover the heading and stylesheet lines -->
273+
<div id="module{position()}">
274+
<h2 class="{if (empty($module-id)) then 'failed' else 'successful'}">
275+
<xsl:text expand-text="yes">module: {fmt:format-uri($stylesheet-uri)}</xsl:text>
276+
<span class="scenario-totals">
277+
<xsl:variable name="main-module-stats" as="element(module)*"
278+
select="$coverage-stats[@uri eq $stylesheet-uri]"/>
279+
<xsl:text expand-text="yes">hit: {count($main-module-stats/coverage[. eq 'hit'])} / </xsl:text>
280+
<xsl:text expand-text="yes">missed: {count($main-module-stats/coverage[. eq 'missed'])} / </xsl:text>
281+
<xsl:text expand-text="yes">unknown: {count($main-module-stats/coverage[. eq 'unknown'])}</xsl:text>
282+
</span>
114283
</h2>
115284
<xsl:choose>
116285
<xsl:when test="empty($module-id)">
117286
<p><span class="missed">not used</span></p>
118287
</xsl:when>
119288
<xsl:otherwise>
120-
<pre>
289+
<pre class="xspecCoverage">
121290
<xsl:value-of select="format-number(1, $number-format)" />
122291
<xsl:text>: </xsl:text>
123292
<xsl:call-template name="output-lines">
@@ -127,6 +296,7 @@
127296
</pre>
128297
</xsl:otherwise>
129298
</xsl:choose>
299+
</div>
130300
</xsl:template>
131301

132302
<xsl:variable name="attribute-regex" as="xs:string">
@@ -253,7 +423,7 @@
253423
<xsl:variable name="coverage" as="xs:string">
254424
<xsl:choose>
255425
<xsl:when test="$matches">
256-
<xsl:apply-templates select="$node" mode="coverage"/>
426+
<xsl:sequence select="$node/accumulator-before('computed-status')"/>
257427
</xsl:when>
258428
<xsl:otherwise>
259429
<xsl:sequence select="'ignored'"/>

0 commit comments

Comments
 (0)