RelaxNG/publiset.rnc
author Patrick PIERRE
jeu., 19 juin 2014 11:44:25 +0200
changeset 315 1f1e5638ed6d
parent 313 e4f154ea2837
child 317 78fcb5b0d156
permissions -rw-r--r--
Changement d'adresse
patrick@0
     1
# $Id$
patrick@0
     2
patrick@0
     3
start = publiset
patrick@0
     4
patrick@0
     5
patrick@0
     6
publiset = element publiset {
patrick@0
     7
   publiset.attributes,
patrick@0
     8
   publiset.content
patrick@0
     9
}
patrick@0
    10
patrick@0
    11
publiset.attributes =
patrick@0
    12
   version.attribute
patrick@0
    13
version.attribute = attribute version { "1.0" }
patrick@0
    14
patrick@0
    15
publiset.content =
patrick@0
    16
   (composition | 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@101
   100
role.content = "author" | "illustrator" | "publisher" | "packager"
patrick@38
   101
Patrick@259
   102
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@259
   103
Patrick@259
   104
source = element source {
Patrick@259
   105
   (  (attribute type { "book" }, source.content.book)
Patrick@259
   106
    | (attribute type { "file" }, source.content.file))
Patrick@259
   107
}
Patrick@259
   108
Patrick@259
   109
source.content.book =
Patrick@259
   110
   identifier.ean?
Patrick@259
   111
 & title
Patrick@259
   112
 & subtitle?
Patrick@259
   113
 & copyright?
Patrick@259
   114
 & collection?
Patrick@259
   115
 & folio?
Patrick@259
   116
 & pages?
Patrick@259
   117
 
Patrick@259
   118
source.content.file =
Patrick@259
   119
   identifier.uri
Patrick@259
   120
Patrick@259
   121
# ~~~~~~ folio
Patrick@259
   122
folio = element folio { folio.content }
Patrick@259
   123
Patrick@259
   124
folio.content = xsd:positiveInteger | xsd:token {pattern = "[DLXVI]+"}
Patrick@259
   125
Patrick@259
   126
# ~~~~~~ pages
Patrick@259
   127
pages = element pages { pages.content }
Patrick@259
   128
Patrick@259
   129
pages.content = xsd:positiveInteger
Patrick@259
   130
Patrick@189
   131
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ keyword & subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@98
   132
patrick@98
   133
# ~~~~~~ keywordset
patrick@98
   134
keywordset = element keywordset { keywordset.content }
patrick@98
   135
patrick@98
   136
keywordset.content = keyword+
patrick@98
   137
patrick@98
   138
# ~~~~~~ keyword
patrick@98
   139
keyword = element keyword { keyword.content }
patrick@98
   140
Patrick@288
   141
keyword.content = simple.inlines
patrick@98
   142
Patrick@189
   143
# ~~~~~~ subjectset
Patrick@189
   144
subjectset = element subjectset { subjectset.content }
Patrick@189
   145
Patrick@189
   146
subjectset.content = subject+
Patrick@189
   147
Patrick@189
   148
# ~~~~~~ subject
Patrick@189
   149
subject = element subject { subject.content }
Patrick@189
   150
Patrick@288
   151
subject.content = simple.inlines
Patrick@288
   152
Patrick@288
   153
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ index ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@288
   154
Patrick@288
   155
# ~~~~~~ index
Patrick@288
   156
head.index = element index { head.index.content }
Patrick@288
   157
Patrick@288
   158
head.index.content =
Patrick@288
   159
   index.entry, index.entry?
Patrick@288
   160
Patrick@288
   161
# ~~~~~~ index.entry
Patrick@288
   162
index.entry = element entry { simple.inlines }
Patrick@189
   163
yvon@52
   164
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yvon@52
   165
yvon@52
   166
abstract = element abstract { abstract.content }
yvon@52
   167
yvon@52
   168
abstract.content =
yvon@52
   169
   p+
yvon@52
   170
patrick@35
   171
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@35
   172
patrick@35
   173
cover = element cover { cover.content }
patrick@35
   174
patrick@35
   175
cover.content =
patrick@35
   176
   cover.image
patrick@35
   177
patrick@35
   178
cover.image = element image { cover.image.attributes }
patrick@35
   179
patrick@35
   180
cover.image.attributes =
Patrick@288
   181
   media.id.attribute
Patrick@288
   182
media.id.attribute = attribute id { xsd:NMTOKEN }
patrick@35
   183
patrick@0
   184
patrick@0
   185
# =============================================================================
Patrick@310
   186
#                                  TOP LEVEL
Patrick@310
   187
# =============================================================================
Patrick@310
   188
Patrick@310
   189
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   190
Patrick@310
   191
# ~~~~~~ composition
Patrick@310
   192
composition = element composition {
Patrick@310
   193
   composition.attributes,
Patrick@310
   194
   composition.content
Patrick@310
   195
}
Patrick@310
   196
Patrick@310
   197
composition.attributes =
Patrick@310
   198
   composition.id.attribute
Patrick@310
   199
 & path.attribute?
Patrick@310
   200
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   201
 & remap.attributes
Patrick@310
   202
 & lang.attribute?
Patrick@310
   203
composition.id.attribute = attribute id { xsd:NMTOKEN }
Patrick@310
   204
path.attribute = attribute path { xsd:anyURI }
Patrick@310
   205
xslt.attribute = attribute xslt { xsd:anyURI }
Patrick@310
   206
xpath.attribute = attribute xpath { text }
Patrick@310
   207
lang.attribute = attribute xml:lang { xsd:language }
Patrick@310
   208
Patrick@310
   209
composition.content =
Patrick@310
   210
   composition.head?,
Patrick@310
   211
   (composition.division | composition.file)+
Patrick@310
   212
Patrick@310
   213
# ~~~~~~ composition.head
Patrick@310
   214
composition.head = element head {
Patrick@310
   215
   composition.head.attributes, composition.head.content }
Patrick@310
   216
Patrick@310
   217
composition.head.attributes =
Patrick@310
   218
   remap.attributes
Patrick@310
   219
Patrick@310
   220
composition.head.content =
Patrick@310
   221
   (title, shorttitle?, subtitle*)?
Patrick@310
   222
 & identifier*
Patrick@310
   223
 & copyright*
Patrick@310
   224
 & collection?
Patrick@310
   225
 & contributors?
Patrick@310
   226
 & date?
Patrick@310
   227
 & (source, source?)?
Patrick@310
   228
 & keywordset?
Patrick@310
   229
 & subjectset?
Patrick@310
   230
 & head.index*
Patrick@310
   231
 & abstract?
Patrick@310
   232
 & cover?
Patrick@310
   233
Patrick@310
   234
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   235
Patrick@310
   236
# ~~~~~~ selection
Patrick@310
   237
selection = element selection {
Patrick@310
   238
   selection.attributes,
Patrick@310
   239
   selection.content
Patrick@310
   240
}
Patrick@310
   241
Patrick@310
   242
selection.attributes =
Patrick@310
   243
   selection.id.attribute
Patrick@310
   244
 & path.attribute?
Patrick@310
   245
 & lang.attribute?
Patrick@310
   246
selection.id.attribute = attribute id { xsd:NMTOKEN }
Patrick@310
   247
Patrick@310
   248
selection.content =
Patrick@310
   249
   selection.head?,
Patrick@310
   250
   (selection.division | selection.file | link)+
Patrick@310
   251
Patrick@310
   252
# ~~~~~~ selection.head
Patrick@310
   253
selection.head = element head { composition.head.content }
Patrick@310
   254
Patrick@310
   255
Patrick@310
   256
# =============================================================================
Patrick@310
   257
#                                DIVISION LEVEL
Patrick@310
   258
# =============================================================================
Patrick@310
   259
Patrick@310
   260
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   261
Patrick@310
   262
# ~~~~~~ division
Patrick@310
   263
composition.division = element division {
Patrick@310
   264
   composition.division.attributes,
Patrick@310
   265
   composition.division.content
Patrick@310
   266
}
Patrick@310
   267
selection.division = element division {
Patrick@310
   268
   selection.division.attributes,
Patrick@310
   269
   selection.division.content
Patrick@310
   270
}
Patrick@310
   271
Patrick@310
   272
composition.division.attributes =
Patrick@310
   273
   path.attribute?
Patrick@310
   274
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   275
 & remap.attributes
Patrick@310
   276
selection.division.attributes =
Patrick@310
   277
   path.attribute?
Patrick@310
   278
Patrick@310
   279
composition.division.content =
Patrick@310
   280
   composition.head?,
Patrick@310
   281
   (composition.division | composition.file)+
Patrick@310
   282
selection.division.content =
Patrick@310
   283
   selection.head?,
Patrick@310
   284
   (selection.division | selection.file | link)+
Patrick@310
   285
Patrick@310
   286
# ~~~~~~ division.head
Patrick@310
   287
division.head = element head { division.head.content }
Patrick@310
   288
Patrick@310
   289
division.head.content =
Patrick@310
   290
   (title, shorttitle?, subtitle*)?
Patrick@310
   291
 & head.index*
Patrick@310
   292
Patrick@310
   293
Patrick@310
   294
# =============================================================================
Patrick@310
   295
#                                  FILE LEVEL
Patrick@310
   296
# =============================================================================
Patrick@310
   297
Patrick@310
   298
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   299
Patrick@310
   300
composition.file = element file { composition.file.attributes, file.content }
Patrick@310
   301
selection.file = element file { selection.file.attributes, file.content }
Patrick@310
   302
Patrick@310
   303
composition.file.attributes =
Patrick@310
   304
   path.attribute?
Patrick@310
   305
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   306
 & argument.attribute?
Patrick@310
   307
selection.file.attributes =
Patrick@310
   308
   path.attribute?
Patrick@310
   309
argument.attribute = attribute argument { text }
Patrick@310
   310
   
Patrick@310
   311
file.content = xsd:anyURI
Patrick@310
   312
Patrick@310
   313
Patrick@310
   314
# =============================================================================
Patrick@310
   315
#                                 BLOCK LEVEL
Patrick@310
   316
# =============================================================================
Patrick@310
   317
Patrick@310
   318
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   319
Patrick@310
   320
p = element p { p.content }
Patrick@310
   321
Patrick@310
   322
p.content =
Patrick@310
   323
   inlines
Patrick@310
   324
Patrick@310
   325
Patrick@310
   326
# =============================================================================
patrick@20
   327
#                                 INLINE LEVEL
patrick@0
   328
# =============================================================================
patrick@0
   329
patrick@0
   330
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   331
Patrick@288
   332
simple.inlines = mixed {
patrick@0
   333
   sup*
patrick@0
   334
 & sub*
Patrick@189
   335
 & date*
patrick@126
   336
 & name*
Patrick@288
   337
}
Patrick@288
   338
Patrick@293
   339
inlines = mixed {
Patrick@293
   340
   sup*
Patrick@293
   341
 & sub*
Patrick@293
   342
 & date*
Patrick@293
   343
 & name*
Patrick@293
   344
patrick@126
   345
 & highlight*
Patrick@288
   346
 & emphasis*
Patrick@189
   347
 & link*
Patrick@293
   348
}
patrick@0
   349
patrick@0
   350
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   351
Patrick@288
   352
sup = element sup { simple.inlines }
patrick@0
   353
patrick@0
   354
sub = element sub { inlines }
patrick@0
   355
Patrick@189
   356
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@189
   357
Patrick@189
   358
date = element date { date.attributes, date.content }
Patrick@189
   359
Patrick@189
   360
date.attributes =
Patrick@189
   361
   date.value.attribute
Patrick@189
   362
date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
Patrick@189
   363
Patrick@189
   364
date.content = mixed { sup* }
Patrick@189
   365
patrick@126
   366
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@126
   367
patrick@126
   368
name = element name { name.attributes, name.content }
patrick@126
   369
patrick@126
   370
name.attributes =
patrick@126
   371
   name.of.attribute?
patrick@230
   372
name.of.attribute = attribute of {
patrick@230
   373
   "person" | "company" | "book" | "newspaper" | "party" | "painting"
patrick@230
   374
 | "movie" }
patrick@126
   375
patrick@230
   376
name.content = mixed { sup* }
patrick@126
   377
patrick@126
   378
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@126
   379
patrick@126
   380
highlight = element highlight { highlight.content }
patrick@126
   381
patrick@126
   382
highlight.content = inlines
patrick@126
   383
Patrick@288
   384
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ emphasis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@288
   385
Patrick@288
   386
emphasis = element emphasis { emphasis.content }
Patrick@288
   387
Patrick@288
   388
emphasis.content = inlines
Patrick@288
   389
patrick@36
   390
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@36
   391
patrick@36
   392
link = element link { link.attributes, link.content }
patrick@36
   393
patrick@36
   394
link.attributes =
patrick@36
   395
   uri.attribute
patrick@36
   396
uri.attribute = attribute uri { xsd:anyURI }
patrick@36
   397
Patrick@288
   398
link.content = simple.inlines
patrick@36
   399
patrick@0
   400
patrick@0
   401
# =============================================================================
patrick@20
   402
#                               REMAP ATTRIBUTES
patrick@0
   403
# =============================================================================
patrick@0
   404
patrick@0
   405
remap.attributes =
patrick@0
   406
   as.attribute?
patrick@0
   407
 & attributes.attribute?
patrick@97
   408
 & transform.attribute?
patrick@0
   409
as.attribute = attribute as { xsd:QName }
patrick@0
   410
attributes.attribute =
patrick@0
   411
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}
patrick@97
   412
transform.attribute = attribute transform { xsd:anyURI }