RelaxNG/publiset.rnc
author iinov
dim., 21 oct. 2018 16:02:16 +0200
changeset 465 4e3338f519f9
parent 448 9bc794bf36b0
permissions -rw-r--r--
Dictée
patrick@0
     1
patrick@0
     2
start = publiset
patrick@0
     3
patrick@0
     4
patrick@0
     5
publiset = element publiset {
patrick@0
     6
   publiset.attributes,
patrick@0
     7
   publiset.content
patrick@0
     8
}
patrick@0
     9
patrick@0
    10
publiset.attributes =
patrick@0
    11
   version.attribute
patrick@0
    12
version.attribute = attribute version { "1.0" }
patrick@0
    13
patrick@0
    14
publiset.content =
Patrick@382
    15
   composition
Patrick@382
    16
 | selection
patrick@0
    17
patrick@0
    18
patrick@0
    19
# =============================================================================
patrick@20
    20
#                                  HEAD LEVEL
patrick@0
    21
# =============================================================================
patrick@0
    22
patrick@0
    23
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    24
patrick@0
    25
title = element title { title.content }
patrick@127
    26
shorttitle = element shorttitle { title.content }
patrick@18
    27
subtitle = element subtitle { title.content }
patrick@2
    28
patrick@0
    29
title.content = inlines
patrick@0
    30
patrick@34
    31
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@34
    32
Patrick@256
    33
# ~~~~~~ identifier
Patrick@257
    34
identifier = element identifier {
Patrick@257
    35
   (attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"})
Patrick@257
    36
 | (attribute type { "uri" }, for.attribute?, xsd:anyURI)
Patrick@257
    37
}
Patrick@257
    38
Patrick@258
    39
for.attribute = attribute for { xsd:NCName }
Patrick@258
    40
Patrick@257
    41
# ~~~~~~ identifier.ean
Patrick@257
    42
identifier.ean = element identifier {
Patrick@257
    43
   attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"}
Patrick@257
    44
}
patrick@34
    45
Patrick@256
    46
# ~~~~~~ identifier.uri
Patrick@257
    47
identifier.uri = element identifier {
Patrick@257
    48
   attribute type { "uri" }, for.attribute?, xsd:anyURI
Patrick@257
    49
}
patrick@34
    50
patrick@39
    51
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@39
    52
patrick@39
    53
copyright = element copyright { copyright.content }
patrick@39
    54
Patrick@288
    55
copyright.content = simple.inlines
patrick@39
    56
Patrick@155
    57
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ collection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@155
    58
Patrick@155
    59
collection = element collection { collection.content }
Patrick@155
    60
Patrick@288
    61
collection.content = simple.inlines
Patrick@155
    62
patrick@66
    63
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
    64
patrick@66
    65
# ~~~~~~ contributors
patrick@66
    66
contributors = element contributors { contributors.content }
patrick@5
    67
patrick@66
    68
contributors.content =
patrick@66
    69
   contributor+
patrick@34
    70
patrick@66
    71
# ~~~~~~ contributor
patrick@66
    72
contributor = element contributor { contributor.content }
patrick@66
    73
patrick@66
    74
contributor.content =
Patrick@263
    75
   identifier.uri?,
patrick@66
    76
   (((firstname, secondname?)?, lastname) | label),
patrick@66
    77
   address?,
patrick@66
    78
   link?,
patrick@101
    79
   role+
patrick@5
    80
patrick@66
    81
# ~~~~~~ firstname, secondname, lastname, label
patrick@5
    82
firstname = element firstname { firstname.content }
patrick@66
    83
secondname = element secondname { secondname.content }
patrick@66
    84
lastname = element lastname { lastname.content }
patrick@66
    85
label = element label { label.content }
patrick@5
    86
Patrick@288
    87
firstname.content = simple.inlines
Patrick@288
    88
secondname.content = simple.inlines
Patrick@288
    89
lastname.content = simple.inlines
Patrick@288
    90
label.content = simple.inlines
patrick@5
    91
patrick@66
    92
# ~~~~~~ address
patrick@66
    93
address = element address { address.content }
patrick@5
    94
Patrick@288
    95
address.content = simple.inlines
patrick@5
    96
patrick@34
    97
# ~~~~~~ role
patrick@66
    98
role = element role { role.content }
patrick@34
    99
Patrick@444
   100
role.content = "author" | "illustrator" | "photographer" | "publisher"
Patrick@444
   101
    | "packager" | "translator"
patrick@38
   102
Patrick@259
   103
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@259
   104
Patrick@259
   105
source = element source {
Patrick@259
   106
   (  (attribute type { "book" }, source.content.book)
Patrick@259
   107
    | (attribute type { "file" }, source.content.file))
Patrick@259
   108
}
Patrick@259
   109
Patrick@259
   110
source.content.book =
Patrick@259
   111
   identifier.ean?
Patrick@259
   112
 & title
Patrick@259
   113
 & subtitle?
Patrick@259
   114
 & copyright?
Patrick@259
   115
 & collection?
Patrick@259
   116
 & folio?
Patrick@259
   117
 & pages?
Patrick@350
   118
Patrick@259
   119
source.content.file =
Patrick@259
   120
   identifier.uri
Patrick@259
   121
Patrick@259
   122
# ~~~~~~ folio
Patrick@259
   123
folio = element folio { folio.content }
Patrick@259
   124
Patrick@259
   125
folio.content = xsd:positiveInteger | xsd:token {pattern = "[DLXVI]+"}
Patrick@259
   126
Patrick@259
   127
# ~~~~~~ pages
Patrick@259
   128
pages = element pages { pages.content }
Patrick@259
   129
Patrick@259
   130
pages.content = xsd:positiveInteger
Patrick@259
   131
Patrick@189
   132
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keyword & subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@98
   133
patrick@98
   134
# ~~~~~~ keywordset
patrick@98
   135
keywordset = element keywordset { keywordset.content }
patrick@98
   136
patrick@98
   137
keywordset.content = keyword+
patrick@98
   138
patrick@98
   139
# ~~~~~~ keyword
patrick@98
   140
keyword = element keyword { keyword.content }
patrick@98
   141
Patrick@288
   142
keyword.content = simple.inlines
patrick@98
   143
Patrick@189
   144
# ~~~~~~ subjectset
Patrick@189
   145
subjectset = element subjectset { subjectset.content }
Patrick@189
   146
Patrick@189
   147
subjectset.content = subject+
Patrick@189
   148
Patrick@189
   149
# ~~~~~~ subject
Patrick@189
   150
subject = element subject { subject.content }
Patrick@189
   151
Patrick@288
   152
subject.content = simple.inlines
Patrick@288
   153
Patrick@288
   154
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ index ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@288
   155
Patrick@361
   156
# ~~~~~~ indexset
Patrick@361
   157
indexset = element indexset { indexset.content }
Patrick@361
   158
Patrick@361
   159
indexset.content = head.index+
Patrick@361
   160
Patrick@288
   161
# ~~~~~~ index
Patrick@288
   162
head.index = element index { head.index.content }
Patrick@288
   163
Patrick@288
   164
head.index.content =
Patrick@288
   165
   index.entry, index.entry?
Patrick@288
   166
Patrick@288
   167
# ~~~~~~ index.entry
Patrick@288
   168
index.entry = element entry { simple.inlines }
Patrick@189
   169
yvon@52
   170
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yvon@52
   171
yvon@52
   172
abstract = element abstract { abstract.content }
yvon@52
   173
yvon@52
   174
abstract.content =
yvon@52
   175
   p+
yvon@52
   176
patrick@35
   177
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@35
   178
patrick@35
   179
cover = element cover { cover.content }
patrick@35
   180
patrick@35
   181
cover.content =
patrick@35
   182
   cover.image
patrick@35
   183
patrick@35
   184
cover.image = element image { cover.image.attributes }
patrick@35
   185
patrick@35
   186
cover.image.attributes =
Patrick@288
   187
   media.id.attribute
Patrick@288
   188
media.id.attribute = attribute id { xsd:NMTOKEN }
patrick@35
   189
Patrick@362
   190
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ element ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@362
   191
Patrick@362
   192
\element = element element { element.attributes, element.content }
Patrick@362
   193
Patrick@362
   194
element.attributes =
Patrick@362
   195
   name.attribute
Patrick@362
   196
name.attribute = attribute name { xsd:NCName }
Patrick@362
   197
   
Patrick@362
   198
element.content =
Patrick@362
   199
   (inlines | \element+)
Patrick@362
   200
patrick@0
   201
patrick@0
   202
# =============================================================================
Patrick@310
   203
#                                  TOP LEVEL
Patrick@310
   204
# =============================================================================
Patrick@310
   205
Patrick@310
   206
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   207
Patrick@310
   208
# ~~~~~~ composition
Patrick@310
   209
composition = element composition {
Patrick@310
   210
   composition.attributes,
Patrick@310
   211
   composition.content
Patrick@310
   212
}
Patrick@310
   213
Patrick@310
   214
composition.attributes =
Patrick@382
   215
   composition.id.attribute?
Patrick@317
   216
 & lang.attribute?
Patrick@323
   217
 & path.attribute?
Patrick@418
   218
 & pi-fid.attribute?
Patrick@317
   219
 & pi-source.attribute?
Patrick@310
   220
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   221
 & remap.attributes
Patrick@310
   222
composition.id.attribute = attribute id { xsd:NMTOKEN }
Patrick@317
   223
lang.attribute = attribute xml:lang { xsd:language }
Patrick@323
   224
path.attribute = attribute path { xsd:anyURI }
Patrick@418
   225
pi-fid.attribute = attribute pi-fid { xsd:boolean }
Patrick@317
   226
pi-source.attribute = attribute pi-source { xsd:boolean }
Patrick@323
   227
xpath.attribute = attribute xpath { text }
Patrick@310
   228
xslt.attribute = attribute xslt { xsd:anyURI }
Patrick@310
   229
Patrick@310
   230
composition.content =
Patrick@310
   231
   composition.head?,
Patrick@310
   232
   (composition.division | composition.file)+
Patrick@310
   233
Patrick@310
   234
# ~~~~~~ composition.head
Patrick@310
   235
composition.head = element head {
Patrick@310
   236
   composition.head.attributes, composition.head.content }
Patrick@310
   237
Patrick@310
   238
composition.head.attributes =
Patrick@310
   239
   remap.attributes
Patrick@310
   240
Patrick@310
   241
composition.head.content =
Patrick@384
   242
   (title & shorttitle? & subtitle*)?
Patrick@310
   243
 & identifier*
Patrick@310
   244
 & copyright*
Patrick@310
   245
 & collection?
Patrick@310
   246
 & contributors?
Patrick@310
   247
 & date?
Patrick@310
   248
 & (source, source?)?
Patrick@310
   249
 & keywordset?
Patrick@310
   250
 & subjectset?
Patrick@361
   251
 & indexset?
Patrick@310
   252
 & abstract?
Patrick@310
   253
 & cover?
Patrick@362
   254
 & \element*
Patrick@310
   255
Patrick@310
   256
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   257
Patrick@310
   258
# ~~~~~~ selection
Patrick@310
   259
selection = element selection {
Patrick@310
   260
   selection.attributes,
Patrick@310
   261
   selection.content
Patrick@310
   262
}
Patrick@310
   263
Patrick@310
   264
selection.attributes =
Patrick@382
   265
   selection.id.attribute?
Patrick@317
   266
 & lang.attribute?
Patrick@310
   267
 & path.attribute?
Patrick@310
   268
selection.id.attribute = attribute id { xsd:NMTOKEN }
Patrick@310
   269
Patrick@310
   270
selection.content =
Patrick@310
   271
   selection.head?,
Patrick@310
   272
   (selection.division | selection.file | link)+
Patrick@310
   273
Patrick@310
   274
# ~~~~~~ selection.head
Patrick@310
   275
selection.head = element head { composition.head.content }
Patrick@310
   276
Patrick@310
   277
Patrick@310
   278
# =============================================================================
Patrick@310
   279
#                                DIVISION LEVEL
Patrick@310
   280
# =============================================================================
Patrick@310
   281
Patrick@310
   282
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   283
Patrick@310
   284
# ~~~~~~ division
Patrick@310
   285
composition.division = element division {
Patrick@310
   286
   composition.division.attributes,
Patrick@310
   287
   composition.division.content
Patrick@310
   288
}
Patrick@310
   289
selection.division = element division {
Patrick@310
   290
   selection.division.attributes,
Patrick@310
   291
   selection.division.content
Patrick@310
   292
}
Patrick@310
   293
Patrick@310
   294
composition.division.attributes =
Patrick@310
   295
   path.attribute?
Patrick@310
   296
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   297
 & remap.attributes
Patrick@400
   298
 & argument.attribute?
Patrick@405
   299
 & mode.attribute?
Patrick@310
   300
selection.division.attributes =
Patrick@310
   301
   path.attribute?
Patrick@400
   302
 & argument.attribute?
Patrick@405
   303
 & mode.attribute?
Patrick@310
   304
Patrick@310
   305
composition.division.content =
Patrick@310
   306
   composition.head?,
Patrick@310
   307
   (composition.division | composition.file)+
Patrick@310
   308
selection.division.content =
Patrick@310
   309
   selection.head?,
Patrick@310
   310
   (selection.division | selection.file | link)+
Patrick@310
   311
Patrick@310
   312
Patrick@310
   313
# =============================================================================
Patrick@310
   314
#                                  FILE LEVEL
Patrick@310
   315
# =============================================================================
Patrick@310
   316
Patrick@310
   317
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   318
Patrick@310
   319
composition.file = element file { composition.file.attributes, file.content }
Patrick@310
   320
selection.file = element file { selection.file.attributes, file.content }
Patrick@310
   321
Patrick@310
   322
composition.file.attributes =
Patrick@310
   323
   path.attribute?
Patrick@310
   324
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   325
 & argument.attribute?
Patrick@405
   326
 & mode.attribute?
Patrick@446
   327
 & title.attribute?
Patrick@310
   328
selection.file.attributes =
Patrick@310
   329
   path.attribute?
Patrick@310
   330
argument.attribute = attribute argument { text }
Patrick@405
   331
mode.attribute = attribute mode { text }
Patrick@446
   332
title.attribute = attribute title { text }
Patrick@350
   333
Patrick@310
   334
file.content = xsd:anyURI
Patrick@310
   335
Patrick@310
   336
Patrick@310
   337
# =============================================================================
Patrick@310
   338
#                                 BLOCK LEVEL
Patrick@310
   339
# =============================================================================
Patrick@310
   340
Patrick@310
   341
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   342
Patrick@310
   343
p = element p { p.content }
Patrick@310
   344
Patrick@310
   345
p.content =
Patrick@310
   346
   inlines
Patrick@310
   347
Patrick@310
   348
Patrick@310
   349
# =============================================================================
patrick@20
   350
#                                 INLINE LEVEL
patrick@0
   351
# =============================================================================
patrick@0
   352
patrick@0
   353
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   354
Patrick@288
   355
simple.inlines = mixed {
patrick@0
   356
   sup*
patrick@0
   357
 & sub*
Patrick@288
   358
}
Patrick@288
   359
Patrick@293
   360
inlines = mixed {
Patrick@293
   361
   sup*
Patrick@293
   362
 & sub*
Patrick@293
   363
patrick@126
   364
 & highlight*
Patrick@288
   365
 & emphasis*
Patrick@350
   366
 & name*
Patrick@293
   367
}
patrick@0
   368
patrick@0
   369
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   370
Patrick@288
   371
sup = element sup { simple.inlines }
patrick@0
   372
patrick@0
   373
sub = element sub { inlines }
patrick@0
   374
patrick@126
   375
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@126
   376
patrick@126
   377
highlight = element highlight { highlight.content }
patrick@126
   378
patrick@126
   379
highlight.content = inlines
patrick@126
   380
Patrick@288
   381
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ emphasis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@288
   382
Patrick@288
   383
emphasis = element emphasis { emphasis.content }
Patrick@288
   384
Patrick@288
   385
emphasis.content = inlines
Patrick@288
   386
Patrick@350
   387
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@350
   388
Patrick@350
   389
name = element name { name.attributes, name.content }
Patrick@350
   390
Patrick@350
   391
name.attributes =
Patrick@350
   392
   name.of.attribute?
Patrick@350
   393
name.of.attribute = attribute of {
Patrick@350
   394
   "person" | "company" | "book" | "newspaper" | "party" | "movie"
Patrick@350
   395
 | "painting" }
Patrick@350
   396
Patrick@350
   397
name.content = mixed { sup* }
Patrick@350
   398
Patrick@350
   399
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@350
   400
Patrick@350
   401
date = element date { date.attributes, date.content }
Patrick@350
   402
Patrick@350
   403
date.attributes =
Patrick@350
   404
   date.value.attribute
Patrick@350
   405
date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
Patrick@350
   406
Patrick@350
   407
date.content = mixed { sup* }
Patrick@350
   408
patrick@36
   409
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@36
   410
patrick@36
   411
link = element link { link.attributes, link.content }
patrick@36
   412
patrick@36
   413
link.attributes =
patrick@36
   414
   uri.attribute
patrick@36
   415
uri.attribute = attribute uri { xsd:anyURI }
patrick@36
   416
Patrick@288
   417
link.content = simple.inlines
patrick@36
   418
patrick@0
   419
patrick@0
   420
# =============================================================================
patrick@20
   421
#                               REMAP ATTRIBUTES
patrick@0
   422
# =============================================================================
patrick@0
   423
patrick@0
   424
remap.attributes =
patrick@0
   425
   as.attribute?
patrick@0
   426
 & attributes.attribute?
patrick@97
   427
 & transform.attribute?
patrick@0
   428
as.attribute = attribute as { xsd:QName }
patrick@0
   429
attributes.attribute =
patrick@0
   430
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}
patrick@97
   431
transform.attribute = attribute transform { xsd:anyURI }