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