Skip to content

Commit 6ddec1c

Browse files
committed
Flag errant timezone indicators in dateline attrs
… where "+00:00" is appended without basis
1 parent 6bc36dc commit 6ddec1c

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

schema/frus-dates.sch

+14-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<p>This schematron file contains date-related rules augmenting frus.sch. This file is
1010
appropriate for evaluating vendor deliveries and first review of a volume for date encoding
1111
and values.</p>
12-
12+
1313
<xsl:include href="frus-dates.xsl"/>
1414

1515
<ns prefix="tei" uri="http://www.tei-c.org/ns/1.0"/>
@@ -151,6 +151,19 @@
151151
<assert role="warning" test="empty($warn)"><value-of select="$warn"/>: <value-of
152152
select="normalize-space(.)"/></assert>
153153

154+
<let name="timezone-attributes" value="$actual-attributes[matches(., '[-+]00:00$')]"/>
155+
156+
<!-- Flag timezone indicators +00:00 or -00:00 -->
157+
<assert id="zulu-timezone-mismatch" role="warning" test="
158+
if (exists($timezone-attributes)) then
159+
(matches(., '\d{4}Z|Zulu') or exists(@ana))
160+
else
161+
true()">Time zone indicator <value-of
162+
select="string-join($timezone-attributes ! analyze-string(., '[-+]00:00$')/fn:match, ', ')"
163+
/> is not expected in: <value-of
164+
select="$timezone-attributes ! serialize(., map {'method': 'adaptive'})"
165+
/></assert>
166+
154167
<!-- Schematron Quick Fix to replace any existing date attributes with the expected ones -->
155168
<sqf:fix id="fix-date-attributes">
156169
<sqf:description>

tests/frus-dates-sch.xspec

+27
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,31 @@
3030
<x:expect-not-assert id="date-matches-attributes" label="Skip undated"
3131
location="/tei:dateline/tei:date"/>
3232
</x:scenario>
33+
<x:scenario label="Unexpected Zulu timezone indicator raises warning">
34+
<x:context>
35+
<dateline xmlns="http://www.tei-c.org/ns/1.0">
36+
<date when="1986-06-04T09:55:00+00:00">June 4, 1986, 9:55 a.m.</date>
37+
</dateline>
38+
</x:context>
39+
<x:expect-assert id="zulu-timezone-mismatch"
40+
label="Unexpected timezone indicator is correctly flagged"/>
41+
</x:scenario>
42+
<x:scenario label="Expected Zulu indicator passes check">
43+
<x:context>
44+
<dateline xmlns="http://www.tei-c.org/ns/1.0">
45+
<date when="1986-06-04T09:55:00+00:00">June 4, 1986, 0955Z</date>
46+
</dateline>
47+
</x:context>
48+
<x:expect-not-assert id="zulu-timezone-mismatch" label="Expected Zulu indicator passes check"/>
49+
</x:scenario>
50+
<x:scenario label="Zulu indicator with justification passes check">
51+
<x:context>
52+
<dateline xmlns="http://www.tei-c.org/ns/1.0">
53+
<date ana="#good-reason" when="1986-06-04T09:55:00+00:00">June 4, 1986, 9:55
54+
a.m.</date>
55+
</dateline>
56+
</x:context>
57+
<x:expect-not-assert id="zulu-timezone-mismatch"
58+
label="Zulu indicator with justification passes check"/>
59+
</x:scenario>
3360
</x:description>

0 commit comments

Comments
 (0)