RelaxNG/publiset.rnc
author Patrick PIERRE
mar., 13 mai 2014 12:59:42 +0200
changeset 312 7f6b762880b4
parent 310 13939fb7824a
child 313 e4f154ea2837
permissions -rw-r--r--
Ajout de l'attribut alt
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@0
    20
# =============================================================================
patrick@20
    21
#                                  HEAD LEVEL
patrick@0
    22
# =============================================================================
patrick@0
    23
patrick@0
    24
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    25
patrick@0
    26
title = element title { title.content }
patrick@127
    27
shorttitle = element shorttitle { title.content }
patrick@18
    28
subtitle = element subtitle { title.content }
patrick@2
    29
patrick@0
    30
title.content = inlines
patrick@0
    31
patrick@34
    32
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@34
    33
Patrick@256
    34
# ~~~~~~ identifier
Patrick@257
    35
identifier = element identifier {
Patrick@257
    36
   (attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"})
Patrick@257
    37
 | (attribute type { "uri" }, for.attribute?, xsd:anyURI)
Patrick@257
    38
}
Patrick@257
    39
Patrick@258
    40
for.attribute = attribute for { xsd:NCName }
Patrick@258
    41
Patrick@257
    42
# ~~~~~~ identifier.ean
Patrick@257
    43
identifier.ean = element identifier {
Patrick@257
    44
   attribute type { "ean" }, for.attribute?, xsd:token {pattern = "\d{13}"}
Patrick@257
    45
}
patrick@34
    46
Patrick@256
    47
# ~~~~~~ identifier.uri
Patrick@257
    48
identifier.uri = element identifier {
Patrick@257
    49
   attribute type { "uri" }, for.attribute?, xsd:anyURI
Patrick@257
    50
}
patrick@34
    51
patrick@39
    52
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@39
    53
patrick@39
    54
copyright = element copyright { copyright.content }
patrick@39
    55
Patrick@288
    56
copyright.content = simple.inlines
patrick@39
    57
Patrick@155
    58
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ collection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@155
    59
Patrick@155
    60
collection = element collection { collection.content }
Patrick@155
    61
Patrick@288
    62
collection.content = simple.inlines
Patrick@155
    63
patrick@66
    64
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
    65
patrick@66
    66
# ~~~~~~ contributors
patrick@66
    67
contributors = element contributors { contributors.content }
patrick@5
    68
patrick@66
    69
contributors.content =
patrick@66
    70
   contributor+
patrick@34
    71
patrick@66
    72
# ~~~~~~ contributor
patrick@66
    73
contributor = element contributor { contributor.content }
patrick@66
    74
patrick@66
    75
contributor.content =
Patrick@263
    76
   identifier.uri?,
patrick@66
    77
   (((firstname, secondname?)?, lastname) | label),
patrick@66
    78
   address?,
patrick@66
    79
   link?,
patrick@101
    80
   role+
patrick@5
    81
patrick@66
    82
# ~~~~~~ firstname, secondname, lastname, label
patrick@5
    83
firstname = element firstname { firstname.content }
patrick@66
    84
secondname = element secondname { secondname.content }
patrick@66
    85
lastname = element lastname { lastname.content }
patrick@66
    86
label = element label { label.content }
patrick@5
    87
Patrick@288
    88
firstname.content = simple.inlines
Patrick@288
    89
secondname.content = simple.inlines
Patrick@288
    90
lastname.content = simple.inlines
Patrick@288
    91
label.content = simple.inlines
patrick@5
    92
patrick@66
    93
# ~~~~~~ address
patrick@66
    94
address = element address { address.content }
patrick@5
    95
Patrick@288
    96
address.content = simple.inlines
patrick@5
    97
patrick@34
    98
# ~~~~~~ role
patrick@66
    99
role = element role { role.content }
patrick@34
   100
patrick@101
   101
role.content = "author" | "illustrator" | "publisher" | "packager"
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@259
   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@288
   156
# ~~~~~~ index
Patrick@288
   157
head.index = element index { head.index.content }
Patrick@288
   158
Patrick@288
   159
head.index.content =
Patrick@288
   160
   index.entry, index.entry?
Patrick@288
   161
Patrick@288
   162
# ~~~~~~ index.entry
Patrick@288
   163
index.entry = element entry { simple.inlines }
Patrick@189
   164
yvon@52
   165
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yvon@52
   166
yvon@52
   167
abstract = element abstract { abstract.content }
yvon@52
   168
yvon@52
   169
abstract.content =
yvon@52
   170
   p+
yvon@52
   171
patrick@35
   172
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@35
   173
patrick@35
   174
cover = element cover { cover.content }
patrick@35
   175
patrick@35
   176
cover.content =
patrick@35
   177
   cover.image
patrick@35
   178
patrick@35
   179
cover.image = element image { cover.image.attributes }
patrick@35
   180
patrick@35
   181
cover.image.attributes =
Patrick@288
   182
   media.id.attribute
Patrick@288
   183
media.id.attribute = attribute id { xsd:NMTOKEN }
patrick@35
   184
patrick@0
   185
patrick@0
   186
# =============================================================================
Patrick@310
   187
#                                  TOP LEVEL
Patrick@310
   188
# =============================================================================
Patrick@310
   189
Patrick@310
   190
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   191
Patrick@310
   192
# ~~~~~~ composition
Patrick@310
   193
composition = element composition {
Patrick@310
   194
   composition.attributes,
Patrick@310
   195
   composition.content
Patrick@310
   196
}
Patrick@310
   197
Patrick@310
   198
composition.attributes =
Patrick@310
   199
   composition.id.attribute
Patrick@310
   200
 & path.attribute?
Patrick@310
   201
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   202
 & remap.attributes
Patrick@310
   203
 & lang.attribute?
Patrick@310
   204
composition.id.attribute = attribute id { xsd:NMTOKEN }
Patrick@310
   205
path.attribute = attribute path { xsd:anyURI }
Patrick@310
   206
xslt.attribute = attribute xslt { xsd:anyURI }
Patrick@310
   207
xpath.attribute = attribute xpath { text }
Patrick@310
   208
lang.attribute = attribute xml:lang { xsd:language }
Patrick@310
   209
Patrick@310
   210
composition.content =
Patrick@310
   211
   composition.head?,
Patrick@310
   212
   (composition.division | composition.file)+
Patrick@310
   213
Patrick@310
   214
# ~~~~~~ composition.head
Patrick@310
   215
composition.head = element head {
Patrick@310
   216
   composition.head.attributes, composition.head.content }
Patrick@310
   217
Patrick@310
   218
composition.head.attributes =
Patrick@310
   219
   remap.attributes
Patrick@310
   220
Patrick@310
   221
composition.head.content =
Patrick@310
   222
   (title, shorttitle?, subtitle*)?
Patrick@310
   223
 & identifier*
Patrick@310
   224
 & copyright*
Patrick@310
   225
 & collection?
Patrick@310
   226
 & contributors?
Patrick@310
   227
 & date?
Patrick@310
   228
 & (source, source?)?
Patrick@310
   229
 & keywordset?
Patrick@310
   230
 & subjectset?
Patrick@310
   231
 & head.index*
Patrick@310
   232
 & abstract?
Patrick@310
   233
 & cover?
Patrick@310
   234
Patrick@310
   235
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   236
Patrick@310
   237
# ~~~~~~ selection
Patrick@310
   238
selection = element selection {
Patrick@310
   239
   selection.attributes,
Patrick@310
   240
   selection.content
Patrick@310
   241
}
Patrick@310
   242
Patrick@310
   243
selection.attributes =
Patrick@310
   244
   selection.id.attribute
Patrick@310
   245
 & path.attribute?
Patrick@310
   246
 & lang.attribute?
Patrick@310
   247
selection.id.attribute = attribute id { xsd:NMTOKEN }
Patrick@310
   248
Patrick@310
   249
selection.content =
Patrick@310
   250
   selection.head?,
Patrick@310
   251
   (selection.division | selection.file | link)+
Patrick@310
   252
Patrick@310
   253
# ~~~~~~ selection.head
Patrick@310
   254
selection.head = element head { composition.head.content }
Patrick@310
   255
Patrick@310
   256
Patrick@310
   257
# =============================================================================
Patrick@310
   258
#                                DIVISION LEVEL
Patrick@310
   259
# =============================================================================
Patrick@310
   260
Patrick@310
   261
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   262
Patrick@310
   263
# ~~~~~~ division
Patrick@310
   264
composition.division = element division {
Patrick@310
   265
   composition.division.attributes,
Patrick@310
   266
   composition.division.content
Patrick@310
   267
}
Patrick@310
   268
selection.division = element division {
Patrick@310
   269
   selection.division.attributes,
Patrick@310
   270
   selection.division.content
Patrick@310
   271
}
Patrick@310
   272
Patrick@310
   273
composition.division.attributes =
Patrick@310
   274
   path.attribute?
Patrick@310
   275
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   276
 & remap.attributes
Patrick@310
   277
selection.division.attributes =
Patrick@310
   278
   path.attribute?
Patrick@310
   279
Patrick@310
   280
composition.division.content =
Patrick@310
   281
   composition.head?,
Patrick@310
   282
   (composition.division | composition.file)+
Patrick@310
   283
selection.division.content =
Patrick@310
   284
   selection.head?,
Patrick@310
   285
   (selection.division | selection.file | link)+
Patrick@310
   286
Patrick@310
   287
# ~~~~~~ division.head
Patrick@310
   288
division.head = element head { division.head.content }
Patrick@310
   289
Patrick@310
   290
division.head.content =
Patrick@310
   291
   (title, shorttitle?, subtitle*)?
Patrick@310
   292
 & head.index*
Patrick@310
   293
Patrick@310
   294
Patrick@310
   295
# =============================================================================
Patrick@310
   296
#                                  FILE LEVEL
Patrick@310
   297
# =============================================================================
Patrick@310
   298
Patrick@310
   299
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   300
Patrick@310
   301
composition.file = element file { composition.file.attributes, file.content }
Patrick@310
   302
selection.file = element file { selection.file.attributes, file.content }
Patrick@310
   303
Patrick@310
   304
composition.file.attributes =
Patrick@310
   305
   path.attribute?
Patrick@310
   306
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   307
 & argument.attribute?
Patrick@310
   308
selection.file.attributes =
Patrick@310
   309
   path.attribute?
Patrick@310
   310
argument.attribute = attribute argument { text }
Patrick@310
   311
   
Patrick@310
   312
file.content = xsd:anyURI
Patrick@310
   313
Patrick@310
   314
Patrick@310
   315
# =============================================================================
Patrick@310
   316
#                                 BLOCK LEVEL
Patrick@310
   317
# =============================================================================
Patrick@310
   318
Patrick@310
   319
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   320
Patrick@310
   321
p = element p { p.content }
Patrick@310
   322
Patrick@310
   323
p.content =
Patrick@310
   324
   inlines
Patrick@310
   325
Patrick@310
   326
Patrick@310
   327
# =============================================================================
patrick@20
   328
#                                 INLINE LEVEL
patrick@0
   329
# =============================================================================
patrick@0
   330
patrick@0
   331
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   332
Patrick@288
   333
simple.inlines = mixed {
patrick@0
   334
   sup*
patrick@0
   335
 & sub*
Patrick@189
   336
 & date*
patrick@126
   337
 & name*
Patrick@288
   338
}
Patrick@288
   339
Patrick@293
   340
inlines = mixed {
Patrick@293
   341
   sup*
Patrick@293
   342
 & sub*
Patrick@293
   343
 & date*
Patrick@293
   344
 & name*
Patrick@293
   345
patrick@126
   346
 & highlight*
Patrick@288
   347
 & emphasis*
Patrick@189
   348
 & link*
Patrick@293
   349
}
patrick@0
   350
patrick@0
   351
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   352
Patrick@288
   353
sup = element sup { simple.inlines }
patrick@0
   354
patrick@0
   355
sub = element sub { inlines }
patrick@0
   356
Patrick@189
   357
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@189
   358
Patrick@189
   359
date = element date { date.attributes, date.content }
Patrick@189
   360
Patrick@189
   361
date.attributes =
Patrick@189
   362
   date.value.attribute
Patrick@189
   363
date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
Patrick@189
   364
Patrick@189
   365
date.content = mixed { sup* }
Patrick@189
   366
patrick@126
   367
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@126
   368
patrick@126
   369
name = element name { name.attributes, name.content }
patrick@126
   370
patrick@126
   371
name.attributes =
patrick@126
   372
   name.of.attribute?
patrick@230
   373
name.of.attribute = attribute of {
patrick@230
   374
   "person" | "company" | "book" | "newspaper" | "party" | "painting"
patrick@230
   375
 | "movie" }
patrick@126
   376
patrick@230
   377
name.content = mixed { sup* }
patrick@126
   378
patrick@126
   379
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@126
   380
patrick@126
   381
highlight = element highlight { highlight.content }
patrick@126
   382
patrick@126
   383
highlight.content = inlines
patrick@126
   384
Patrick@288
   385
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ emphasis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@288
   386
Patrick@288
   387
emphasis = element emphasis { emphasis.content }
Patrick@288
   388
Patrick@288
   389
emphasis.content = inlines
Patrick@288
   390
patrick@36
   391
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@36
   392
patrick@36
   393
link = element link { link.attributes, link.content }
patrick@36
   394
patrick@36
   395
link.attributes =
patrick@36
   396
   uri.attribute
patrick@36
   397
uri.attribute = attribute uri { xsd:anyURI }
patrick@36
   398
Patrick@288
   399
link.content = simple.inlines
patrick@36
   400
patrick@0
   401
patrick@0
   402
# =============================================================================
patrick@20
   403
#                               REMAP ATTRIBUTES
patrick@0
   404
# =============================================================================
patrick@0
   405
patrick@0
   406
remap.attributes =
patrick@0
   407
   as.attribute?
patrick@0
   408
 & attributes.attribute?
patrick@97
   409
 & transform.attribute?
patrick@0
   410
as.attribute = attribute as { xsd:QName }
patrick@0
   411
attributes.attribute =
patrick@0
   412
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}
patrick@97
   413
transform.attribute = attribute transform { xsd:anyURI }