-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathIIP-schematron-testing.sch
224 lines (194 loc) · 12.4 KB
/
IIP-schematron-testing.sch
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<?xml version="1.0" encoding="UTF-8"?>
<sch:schema xmlns:sch="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
xmlns:t="http://www.tei-c.org/ns/1.0">
<sch:ns uri="http://www.tei-c.org/ns/1.0" prefix="t"
xmlns:sch="http://purl.oclc.org/dsdl/schematron"
xmlns:sqf="http://www.schematron-quickfix.com/validator/process"
xmlns:iso="http://purl.oclc.org/dsdl/schematron"
xmlns:oxy="http://www.oxygenxml.com/schematron/validation"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:saxon="http://saxon.sf.net/"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:t="http://www.tei-c.org/ns/1.0"
oxy:elementURI="file:/Users/ellimylonas/Projects/iip/2016XSLConversions/iip-git/IIP-schematron-testing.sch"/>
<!--*******
This provides validation for encoders while working on their transcriptions.Itis based on the work
done by Scott DiGiulio for USEP. From his notes:
"The transcription-oriented are drawn from the sample schematron provided on the
EpiDoc sourceforge, with several customizations for the US Epigraphy Project added, especially
with respect to bibliography and metadata."
**Change log:
2018-10-27 EM copied from USEP and started customization for IIP
-->
<!-- Variable declaration -->
<!-- <sch:let name="region" value="/t:TEI/t:teiHeader/t:fileDesc/t:sourceDesc/t:msDesc/t:msIdentifier/t:region"/>-->
<sch:pattern>
<sch:title>Test machine readable name</sch:title>
<sch:rule context="/">
<sch:assert diagnostics="docName" test=" contains(document-uri(/), /@xml:id)">Machine-Readable ID must match filename</sch:assert>
<!-- I'm cheating here, just looking to see if the ID is in the fn. Usually people have
completely wrong ID so this will catch most of those -->
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Letter height dimensions</sch:title>
<sch:rule context="//t:dimensions[@type='letter']">
<sch:report test="(@quantity and @atLeast and @atMost)">Conflict: Letter height dimensions should either @quantity or @atLeast and @atMost</sch:report>
<sch:report test="(@atleast) and not(@atMost)">If the letter height has only one value, it should be @quantity not @atLeast</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty genre</sch:title>
<sch:rule context="//t:msContents">
<sch:report test="//t:msItem[@class='#xx']">Every inscription must have a valid genre</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty support material</sch:title>
<sch:rule context="//t:physDesc">
<sch:report test="//t:supportDesc[@ana='#xx']">Every inscription must have a valid material</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty condition</sch:title>
<sch:rule context="//t:physDesc/t:objectDesc/t:supportDesc/t:condition">
<sch:report test="//t:condition[@ana='#xx']"></sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for multiple ps under supportDesc</sch:title>
<sch:rule context="//t:physDesc">
<sch:report test="//t:supportDesc/t:support/t:p[2]">Cannot have two p-elements contained under support</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty objectDesc</sch:title>
<sch:rule context="//t:physDesc">
<sch:report test="//t:objectDesc[@ana='#xx']">Every entry must contain a valid object type</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty handNote</sch:title>
<sch:rule context="//t:physDesc/t:handDesc">
<sch:report test="//t:handNote[@ana='#xx']">Every entry must contain a valid writing description; if unknown, mark as such</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty date fields</sch:title>
<sch:rule context="//t:history/t:origin">
<sch:report test="//t:date='Date to be displayed'">Enter a date for the inscription</sch:report>
<sch:report test="(//t:date[@notBefore='0001'] and //t:date[@notAfter='0002'])">Enter a range of dates for the inscription</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty place names</sch:title>
<sch:rule context="//t:history/t:origin">
<sch:report test="t:placeName[@ref='xx']">Inscription must have a valid place ref (e.g. europe.italy.rome)</sch:report>
<sch:report test="t:placeName='Detailed place name'">Inscription must have a location; if it is unknown, mark as such</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty bibl</sch:title>
<sch:rule context="//t:listBibl">
<sch:report test="normalize-space(.)=''">Every entry must include bibliography, even if it is unpublished</sch:report>
<sch:report test="t:bibl/t:ptr[@target='#xx']">Every entry must include a page or inscription number; use "unpub" for unpublished inscriptions</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for empty unclear</sch:title>
<sch:rule context="//t:unclear">
<sch:report test="normalize-space(child::node())">unclear cannot be an empty element</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test for change log attribution</sch:title>
<sch:rule context="//t:revisionDesc">
<sch:report test="t:change[@who='xx']">Input your name in the change log</sch:report>
</sch:rule>
</sch:pattern>
<!-- <sch:pattern>
<sch:title>Image name test</sch:title>
<sch:rule context="//t:facsimile">
<sch:report test="starts-with(//t:graphic[@url], //t:publicationStmt/idno[@xml:id])">Image names should match the USEP ID (unless the image is a detail or alternate view, or the image is external)</sch:report>
</sch:rule>
</sch:pattern>-->
<!-- <sch:pattern>
<sch:title>Test for image formatting</sch:title>
<sch:rule context="//t:facsimile">
<sch:report test="//t:surface/t:graphic[2]">Each image must have its own surface element; do not put multiple graphic elements under the same surface</sch:report>
</sch:rule>
</sch:pattern>-->
<sch:pattern>
<sch:title>Test gap attributes</sch:title>
<sch:rule context="//t:gap">
<sch:report test="(@extent and @quantity)">Conflict: @quantity and @extent both present on gap</sch:report>
<sch:report test="(@reason='lost' or @reason='omitted') and not(@extent or @quantity or (@atLeast and @atMost))">gap needs one of @extent, @quantity or both @atLeast and @atMost</sch:report>
<sch:report test="(@reason='lost' or @reason='omitted') and not(@unit)">Gap - lost or omitted needs @unit</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Test space attributes</sch:title>
<sch:rule context="//t:space">
<sch:report test="(@extent and @quantity)">conflict: @quantity and @extent both present on space</sch:report>
<sch:report test="(@reason='lost' or @reason='omitted') and not(@extent or @quantity or (@atleast and @atMost))">space needs one of @extent, @quantity or both @atLeast and @atMost</sch:report>
<sch:report test="(@reason='lost' or @reason='omitted') and not(@unit)">space - lost or omitted needs @unit</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Check for gaps in supplied</sch:title>
<sch:rule context="//t:div[@type='edition']//t:gap[not(@reason='ellipsis')]">
<sch:report test="ancestor::t:supplied[not(@reason='undefined')]">Supplied may not contain gap</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Checking for Leiden sigla</sch:title>
<!-- the regexes below will only work if you have Schematron set to XPATH version 2.0 in your local environment -->
<!-- in Oxygen: Options > Preferences > XML > XML Parser > Schematron -->
<sch:rule context="//t:div[@type='edition']">
<sch:report test="descendant::text()[not(ancestor::t:desc or ancestor::t:note)][matches(.,'[\[\]\(\)]')]">Brackets and parentheses in epigraphic text</sch:report>
<sch:report test="descendant::text()[not(ancestor::t:desc or ancestor::t:note)][matches(.,'̣|')]">Underdots in epigraphic text</sch:report>
<sch:report test="descendant::text()[not(ancestor::t:desc or ancestor::t:note)][matches(.,'<|>')]">Angle brackets in epigraphic text</sch:report>
</sch:rule>
</sch:pattern>
<!-- <sch:pattern>
<sch:title>Check for untagged words</sch:title>
<sch:rule context="//t:div[@type='edition']">
<sch:report test="descendant::text()[not(ancestor::t:w or ancestor::t:name or ancestor::t:placeName or ancestor::t:geogName or ancestor::t:num or ancestor::t:surplus
or ancestor::t:orig or ancestor::t:desc or ancestor::t:note or ancestor::t:head or ancestor::t:g or ancestor::t:abbr[not(ancestor::t:expan)])][not(translate(normalize-space(translate(.,',.;··:','')),' ','')='')]">
Character content needs to be tagged as word or name or number or undefined etc.
</sch:report>
</sch:rule>
</sch:pattern>-->
<sch:pattern>
<sch:title>Check for problems with names and persnames</sch:title>
<sch:rule context="//t:div[@type='edition']//t:name">
<sch:report test="not(ancestor::t:persName or ancestor::t:placeName)">name needs to be inside persName or placeName</sch:report>
</sch:rule>
<sch:rule context="//t:div[@type='edition']//t:persName">
<sch:report test="not(@type=('divine','emperor','ruler','consul','attested','other'))">persName @type needs to be one of 'divine','emperor','ruler',consul','attested','other'</sch:report>
</sch:rule>
</sch:pattern>
<sch:pattern>
<sch:title>Problems with abbreviations/expansions</sch:title>
<sch:rule context="//t:ex">
<sch:report test="not(ancestor::t:expan)">ex should only appear inside expan</sch:report>
<sch:report test="parent::t:abbr">ex should not be a child of abbr</sch:report>
</sch:rule>
<sch:rule context="//t:expan">
<!--<report test="not(descendant::t:ex)">expan should contain ex</report><-->
<sch:report test="descendant::text()[not(translate(normalize-space(.),' ','')='')][not(ancestor::t:ex or ancestor::t:abbr)]">all text in expan should be in abbr or ex</sch:report>
</sch:rule>
<sch:rule context="//t:expan">
<!--<report test="not(descendant::t:ex)">expan should contain ex</report><-->
<sch:report test="child::t:am">am should not be a child of expan.</sch:report>
</sch:rule>
</sch:pattern>
<sch:diagnostics>
<sch:diagnostic id="docName">
<sch:value-of select="substring-before(document-uri(/), '.xml')"/>
</sch:diagnostic>
</sch:diagnostics>
</sch:schema>