-
Notifications
You must be signed in to change notification settings - Fork 2
/
biblio.rnc
491 lines (401 loc) · 12.4 KB
/
biblio.rnc
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
# instantiations of this grammar may replace leaf strings
# with more elaborated types; e.g. title (text) replaced with
# title-main, title-intro, title-part; type replaced with
# enum.
#
# some renaming at leaf nodes is permissible
#
# obligations can change both from optional to mandatory,
# and from mandatory to optional; optional elements may
# be omitted; freely positioned alternatives may be replaced
# with strict ordering
#
# DO NOT introduce a namespace here. We do not want a distinct namespace
# for these elements, and a distinct namespace for any grammar inheriting
# these elements; we just want one namespace for any child grammars
# of this.
grammar {
# https://www.myintervals.com/blog/2009/05/20/iso-8601-date-validation-that-doesnt-suck/
# iso8601date = xsd:string { pattern = "([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?" }
# Somewhat dumbed down for XSD regex:
ISO8601DateTime = xsd:string { pattern = "([\+\-]?\d{4})((-?)((0[1-9]|1[0-2])((-?)([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([\.,]\d+)?)?((:?)[0-5]\d([.,]\d+)?)?([zZ]|([\+\-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?" }
ISO8601Date = xsd:string { pattern = "([\+\-]?\d{4})((-?)((0[1-9]|1[0-2])((-?)([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6]))))?" }
start = bibitem
status =
element status {
( stage, substage?, iteration? )
}
stage = element stage {
attribute abbreviation { text }?,
text
}
substage = element substage {
attribute abbreviation { text }?,
text
}
iteration = element iteration { text }
language = element language { text }
## ISO-639
script = element script { text }
## ISO-15924: Latn
edition = element edition {
attribute number { text }?,
text
}
LocalizedString1 =
# multiple languages and scripts possible: comma delimit them if so
attribute language { text }?,
attribute script { text }?,
text
LocalizedString =
LocalizedString1 |
element variant { LocalizedString1 }+
# Unlike UML, change type to format: type is overloaded
# Would be need if plain were default value and could omit the attribute
# Added LocalizedStringOrXsAny
FormattedString =
# attribute format { ( "plain" | "html" | "docbook" | "tei" | "asciidoc" | "markdown" ) }?,
attribute format { ( "text/plain" | "text/html" | "application/docbook+xml" |
"application/tei+xml" | "text/x-asciidoc" | "text/markdown" | "application/x-metanorma+xml" | text ) }?,
LocalizedStringOrXsAny
LocalizedStringOrXsAny1 =
# multiple languages and scripts possible: comma delimit them if so
attribute language { text }?,
attribute script { text }?,
( text | AnyElement )+
LocalizedStringOrXsAny =
LocalizedStringOrXsAny1 |
element variant { LocalizedStringOrXsAny1 }+
contributor =
element contributor {
role*,
ContributorInfo
}
role =
element role {
attribute type { ( "author" | "performer" | "publisher" | "editor" | "adapter" | "translator" | "distributor" ) }?,
roledescription*
}
ContributorInfo =
( person | organization )
roledescription =
element description { FormattedString }
person =
element person {
fullname?, affiliation*, person-identifier*, contact*, uri*
}
fullname =
element name { FullNameType }
FullNameType =
(( prefix*, forename*, initial*, surname, addition* ) | completeName ),
biblionote*, variantname*
prefix = element prefix { LocalizedString }
initial = element initial { LocalizedString }
addition = element addition { LocalizedString }
surname = element surname { LocalizedString }
forename = element forename { LocalizedString }
completeName = element completename { LocalizedString }
variantname = element variant {
attribute type { text },
FullNameType
}
affiliation =
element affiliation {
affiliationname?, affiliationdescription*, organization
}
affiliationname = element name { LocalizedString }
affiliationdescription = element description { FormattedString }
organization =
element organization {
orgname+, subdivision*, abbreviation?, uri*, org-identifier*, contact*
}
orgname = element name { LocalizedString | NameWithVariants }
subdivision = element subdivision { LocalizedString | NameWithVariants }
NameWithVariants =
element primary { LocalizedString },
element variant { NameWithVariants1 }*
NameWithVariants1 =
attribute type { text },
element primary { LocalizedString },
element variant { NameWithVariants1 }*
abbreviation =
element abbreviation { LocalizedString }
uri =
element uri {
attribute type { text }?,
xsd:anyURI
}
# TODO may change
contact =
( address | phone | email | uri )
phone = element phone {
attribute type { text }?,
text }
email = element email { text }
address =
element address {
# iso191606 TODO
(street+, city, state?, country, postcode? ) | formattedAddress
}
street = element street { text }
city = element city { text }
state = element state { text }
country = element country { text }
postcode = element postcode { text }
formattedAddress = element formattedAddress { text }
person-identifier =
element identifier {
attribute type { ("isni" | "orcid" | "uri") },
text
}
org-identifier =
element identifier {
attribute type { string },
text
}
citation =
element citation { CitationType }
CitationType =
attribute bibitemid { xsd:IDREF },
(locality* | localityStack*), date?
date = element date { ISO8601Date }
locality =
element locality { BibItemLocality }
localityStack =
element localityStack { locality* }
sourceLocality =
element sourceLocality { BibItemLocality }
sourceLocalityStack =
element sourceLocalityStack { sourceLocality* }
BibItemLocality =
attribute type { LocalityType },
referenceFrom?, referenceTo?
LocalityType = xsd:string { pattern = "section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|list|example|volume|issue|time|anchor|locality:[a-zA-Z0-9_]+" }
referenceFrom = element referenceFrom { text }
referenceTo = element referenceTo { text }
# unlike UML, has id attribute; that results from including bibitem in a docmodel
bibitem =
element bibitem {
attribute id { xsd:ID },
BibliographicItem
}
bibitem_no_id =
element bibitem {
BibliographicItem
}
relaton_collection =
element relaton-collection {
attribute type { text }?,
btitle, contributor*,
docrelation*
}
BibItemType |=
( "article" | "book" | "booklet" | "manual" |
"proceedings" | "presentation" | "thesis" | "techreport" |
"standard" | "unpublished" | "map" | "electronic resource" |
"audiovisual" | "film" | "video" | "broadcast" | "software" |
"graphic_work" | "music" | "patent" | "inbook" | "incollection" |
"inproceedings" | "journal" | "website" |"webresource"| "dataset" | "archival" |
"social_media" | "alert" | "message" | "conversation" | "misc" )
BibliographicItem =
attribute type { BibItemType }?,
fetched?,
(btitle+ | formattedref), bsource*, docidentifier*, docnumber?, bdate*, contributor*,
edition?, version?, biblionote*, language*, script*,
bibabstract*, status?, copyright*, docrelation*, series*, medium?, bplace*, bprice*,
extent*, accesslocation*, license*, bclassification*, bkeyword*, validity?
btitle = element title { TypedTitleString }
bsource = element uri { TypedUri }
formattedref = element formattedref { FormattedString }
license = element license { text }
fetched = element fetched { ISO8601DateTime }
validity = element validity {
validityBegins?, validityEnds?, validityRevision?
}
validityBegins = element validityBegins { ISO8601DateTime }
validityEnds = element validityEnds { ISO8601DateTime }
validityRevision = element revision { ISO8601DateTime }
TypedTitleString =
attribute type { text }?,
FormattedString
# TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" )
TypedUri =
attribute type { text }?,
xsd:anyURI
DateType =
attribute text { text }?,
( ISO8601Date )?
BibliographicDateType =
"published" | "accessed" | "created" | "implemented" | "obsoleted" | "confirmed" | "updated" | "issued" | "transmitted" | "copied" | "unchanged" | "circulated" | "adapted" | "vote-started" | "vote-ended" | "announced"
bdate = element date {
attribute type { ( BibliographicDateType | text ) },
attribute text { text }?,
(
(
element from { ISO8601Date },
element to { ISO8601Date }?
) |
element on { ISO8601Date }
)?
}
docidentifier = element docidentifier {
attribute type { text }?,
attribute scope { text }?,
text
}
docnumber = element docnumber { text }
bclassification = element classification {
attribute type { text }?,
text
}
bplace = element place {
attribute uri { xsd:anyURI }?,
attribute region { text }?,
text
}
bprice = element price {
attribute currency { text },
text
}
medium = element medium {
bcontent?, genre?, form?, carrier?, size?, scale?
}
bcontent = element content { text }
genre = element genre { text }
form = element form { text }
carrier = element carrier { text }
size = element size { text }
scale = element scale { text }
accesslocation = element accesslocation { text }
extent = element extent { BibItemLocality }
series = element series {
attribute type { SeriesType }?,
(formattedref |
(btitle, bplace?, seriesorganization?,
abbreviation?,
seriesfrom?, seriesto?,
seriesnumber?, seriespartnumber?, seriesrun?))
}
SeriesType = ( "main" | "alt" | text )
seriesorganization = element organization { text }
seriesfrom = element from { ISO8601Date }
seriesto = element to { ISO8601Date }
seriesnumber = element number { text }
seriespartnumber = element partnumber { text }
seriesrun = element run { text }
biblionote = element note {
attribute type { text }?,
FormattedString
}
bibabstract = element abstract { FormattedString }
copyright =
element copyright {
from, to?, owner+, copyright_scope?
}
copyright_scope = element scope { text }
from = element from { xsd:gYear }
to = element to { xsd:gYear }
owner =
element owner { ContributorInfo }
DocRelationType =
"includes" |
"includedIn" |
"hasPart" |
"partOf" |
"merges" |
"mergedInto" |
"splits" |
"splitInto" |
"instance" |
"hasInstance" |
"exemplarOf" |
"hasExemplar" |
"manifestationOf" |
"hasManifestation" |
"reproductionOf" |
"hasReproduction" |
"reprintOf" |
"hasReprint" |
"expressionOf" |
"hasExpression" |
"translatedFrom" |
"hasTranslation" |
"arrangementOf" |
"hasArrangement" |
"abridgementOf" |
"hasAbridgement" |
"annotationOf" |
"hasAnnotation" |
"draftOf" |
"hasDraft" |
"editionOf" |
"hasEdition" |
"updates" |
"updatedBy" |
"derivedFrom" |
"derives" |
"describes" |
"describedBy" |
"catalogues" |
"cataloguedBy" |
"hasSuccessor" |
"successorOf" |
"adaptedFrom" |
"hasAdaptation" |
"adoptedFrom" |
"adoptedAs" |
"reviewOf" |
"hasReview" |
"commentaryOf" |
"hasCommentary" |
"related" |
"complements" |
"complementOf" |
"obsoletes" |
"obsoletedBy" |
"cites" |
"isCitedIn"
docrelation =
element relation {
attribute type { DocRelationType },
element description { FormattedString }?,
element bibitem { BibliographicItem },
(locality* | localityStack*),
(sourceLocality* | sourceLocalityStack*)
}
version =
element version {
revision-date?, draft*
}
vedition = element edition { xsd:int }
revision-date = element revision-date { ISO8601Date }
draft = element draft { text }
bkeyword = element keyword {
LocalizedString |
(
element vocab { LocalizedString },
vocabid+
) |
(
element taxon { LocalizedString }+,
vocabid+
)
}
vocabid = element vocabid {
attribute type { text },
attribute uri { xsd:anyURI }?,
element code { text }?,
element term { text }?
}
#Anycontents = mixed {
# https://github.com/relaxng/jing-trang/issues/211
# https://lists.oasis-open.org/archives/office/200808/msg00024.html
# https://lists.oasis-open.org/archives/office/200808/msg00099.html
# For this to work, we will actually strip any attributes in the Anycontents before
# passing it for validation. Horrible I know, but there are no good alternatives
# that also allow us to do grammar inheritance
# (attribute * { text } | Any)*
# Any*
#}
AnyElement = element * { ( text | AnyElement)+ }
}