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