RelaxNG/publiset.rnc
author Patrick PIERRE
ven., 16 janv. 2015 11:22:43 +0100
changeset 361 edbbf787aaa2
parent 350 58bbf6bb79e2
child 362 c9c19db11584
permissions -rw-r--r--
indexset
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@350
   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@361
   155
# ~~~~~~ indexset
Patrick@361
   156
indexset = element indexset { indexset.content }
Patrick@361
   157
Patrick@361
   158
indexset.content = head.index+
Patrick@361
   159
Patrick@288
   160
# ~~~~~~ index
Patrick@288
   161
head.index = element index { head.index.content }
Patrick@288
   162
Patrick@288
   163
head.index.content =
Patrick@288
   164
   index.entry, index.entry?
Patrick@288
   165
Patrick@288
   166
# ~~~~~~ index.entry
Patrick@288
   167
index.entry = element entry { simple.inlines }
Patrick@189
   168
yvon@52
   169
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
yvon@52
   170
yvon@52
   171
abstract = element abstract { abstract.content }
yvon@52
   172
yvon@52
   173
abstract.content =
yvon@52
   174
   p+
yvon@52
   175
patrick@35
   176
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@35
   177
patrick@35
   178
cover = element cover { cover.content }
patrick@35
   179
patrick@35
   180
cover.content =
patrick@35
   181
   cover.image
patrick@35
   182
patrick@35
   183
cover.image = element image { cover.image.attributes }
patrick@35
   184
patrick@35
   185
cover.image.attributes =
Patrick@288
   186
   media.id.attribute
Patrick@288
   187
media.id.attribute = attribute id { xsd:NMTOKEN }
patrick@35
   188
patrick@0
   189
patrick@0
   190
# =============================================================================
Patrick@310
   191
#                                  TOP LEVEL
Patrick@310
   192
# =============================================================================
Patrick@310
   193
Patrick@310
   194
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   195
Patrick@310
   196
# ~~~~~~ composition
Patrick@310
   197
composition = element composition {
Patrick@310
   198
   composition.attributes,
Patrick@310
   199
   composition.content
Patrick@310
   200
}
Patrick@310
   201
Patrick@310
   202
composition.attributes =
Patrick@310
   203
   composition.id.attribute
Patrick@317
   204
 & lang.attribute?
Patrick@323
   205
 & path.attribute?
Patrick@317
   206
 & pi-source.attribute?
Patrick@310
   207
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   208
 & remap.attributes
Patrick@310
   209
composition.id.attribute = attribute id { xsd:NMTOKEN }
Patrick@317
   210
lang.attribute = attribute xml:lang { xsd:language }
Patrick@323
   211
path.attribute = attribute path { xsd:anyURI }
Patrick@317
   212
pi-source.attribute = attribute pi-source { xsd:boolean }
Patrick@323
   213
xpath.attribute = attribute xpath { text }
Patrick@310
   214
xslt.attribute = attribute xslt { xsd:anyURI }
Patrick@310
   215
Patrick@310
   216
composition.content =
Patrick@310
   217
   composition.head?,
Patrick@310
   218
   (composition.division | composition.file)+
Patrick@310
   219
Patrick@310
   220
# ~~~~~~ composition.head
Patrick@310
   221
composition.head = element head {
Patrick@310
   222
   composition.head.attributes, composition.head.content }
Patrick@310
   223
Patrick@310
   224
composition.head.attributes =
Patrick@310
   225
   remap.attributes
Patrick@310
   226
Patrick@310
   227
composition.head.content =
Patrick@310
   228
   (title, shorttitle?, subtitle*)?
Patrick@310
   229
 & identifier*
Patrick@310
   230
 & copyright*
Patrick@310
   231
 & collection?
Patrick@310
   232
 & contributors?
Patrick@310
   233
 & date?
Patrick@310
   234
 & (source, source?)?
Patrick@310
   235
 & keywordset?
Patrick@310
   236
 & subjectset?
Patrick@361
   237
 & indexset?
Patrick@310
   238
 & abstract?
Patrick@310
   239
 & cover?
Patrick@310
   240
Patrick@310
   241
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   242
Patrick@310
   243
# ~~~~~~ selection
Patrick@310
   244
selection = element selection {
Patrick@310
   245
   selection.attributes,
Patrick@310
   246
   selection.content
Patrick@310
   247
}
Patrick@310
   248
Patrick@310
   249
selection.attributes =
Patrick@310
   250
   selection.id.attribute
Patrick@317
   251
 & lang.attribute?
Patrick@310
   252
 & path.attribute?
Patrick@310
   253
selection.id.attribute = attribute id { xsd:NMTOKEN }
Patrick@310
   254
Patrick@310
   255
selection.content =
Patrick@310
   256
   selection.head?,
Patrick@310
   257
   (selection.division | selection.file | link)+
Patrick@310
   258
Patrick@310
   259
# ~~~~~~ selection.head
Patrick@310
   260
selection.head = element head { composition.head.content }
Patrick@310
   261
Patrick@310
   262
Patrick@310
   263
# =============================================================================
Patrick@310
   264
#                                DIVISION LEVEL
Patrick@310
   265
# =============================================================================
Patrick@310
   266
Patrick@361
   267
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division.head ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@361
   268
division.head = element head { division.head.content }
Patrick@361
   269
Patrick@361
   270
division.head.content =
Patrick@361
   271
   (title, shorttitle?, subtitle*)?
Patrick@361
   272
 & indexset?
Patrick@361
   273
Patrick@310
   274
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   275
Patrick@310
   276
# ~~~~~~ division
Patrick@310
   277
composition.division = element division {
Patrick@310
   278
   composition.division.attributes,
Patrick@310
   279
   composition.division.content
Patrick@310
   280
}
Patrick@310
   281
selection.division = element division {
Patrick@310
   282
   selection.division.attributes,
Patrick@310
   283
   selection.division.content
Patrick@310
   284
}
Patrick@310
   285
Patrick@310
   286
composition.division.attributes =
Patrick@310
   287
   path.attribute?
Patrick@310
   288
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   289
 & remap.attributes
Patrick@310
   290
selection.division.attributes =
Patrick@310
   291
   path.attribute?
Patrick@310
   292
Patrick@310
   293
composition.division.content =
Patrick@310
   294
   composition.head?,
Patrick@310
   295
   (composition.division | composition.file)+
Patrick@310
   296
selection.division.content =
Patrick@310
   297
   selection.head?,
Patrick@310
   298
   (selection.division | selection.file | link)+
Patrick@310
   299
Patrick@310
   300
Patrick@310
   301
# =============================================================================
Patrick@310
   302
#                                  FILE LEVEL
Patrick@310
   303
# =============================================================================
Patrick@310
   304
Patrick@310
   305
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   306
Patrick@310
   307
composition.file = element file { composition.file.attributes, file.content }
Patrick@310
   308
selection.file = element file { selection.file.attributes, file.content }
Patrick@310
   309
Patrick@310
   310
composition.file.attributes =
Patrick@310
   311
   path.attribute?
Patrick@310
   312
 & (xpath.attribute | xslt.attribute)?
Patrick@310
   313
 & argument.attribute?
Patrick@310
   314
selection.file.attributes =
Patrick@310
   315
   path.attribute?
Patrick@310
   316
argument.attribute = attribute argument { text }
Patrick@350
   317
Patrick@310
   318
file.content = xsd:anyURI
Patrick@310
   319
Patrick@310
   320
Patrick@310
   321
# =============================================================================
Patrick@310
   322
#                                 BLOCK LEVEL
Patrick@310
   323
# =============================================================================
Patrick@310
   324
Patrick@310
   325
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@310
   326
Patrick@310
   327
p = element p { p.content }
Patrick@310
   328
Patrick@310
   329
p.content =
Patrick@310
   330
   inlines
Patrick@310
   331
Patrick@310
   332
Patrick@310
   333
# =============================================================================
patrick@20
   334
#                                 INLINE LEVEL
patrick@0
   335
# =============================================================================
patrick@0
   336
patrick@0
   337
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   338
Patrick@288
   339
simple.inlines = mixed {
patrick@0
   340
   sup*
patrick@0
   341
 & sub*
Patrick@288
   342
}
Patrick@288
   343
Patrick@293
   344
inlines = mixed {
Patrick@293
   345
   sup*
Patrick@293
   346
 & sub*
Patrick@293
   347
patrick@126
   348
 & highlight*
Patrick@288
   349
 & emphasis*
Patrick@350
   350
 & name*
Patrick@350
   351
 & date*
Patrick@189
   352
 & link*
Patrick@293
   353
}
patrick@0
   354
patrick@0
   355
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   356
Patrick@288
   357
sup = element sup { simple.inlines }
patrick@0
   358
patrick@0
   359
sub = element sub { inlines }
patrick@0
   360
patrick@126
   361
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@126
   362
patrick@126
   363
highlight = element highlight { highlight.content }
patrick@126
   364
patrick@126
   365
highlight.content = inlines
patrick@126
   366
Patrick@288
   367
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ emphasis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@288
   368
Patrick@288
   369
emphasis = element emphasis { emphasis.content }
Patrick@288
   370
Patrick@288
   371
emphasis.content = inlines
Patrick@288
   372
Patrick@350
   373
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@350
   374
Patrick@350
   375
name = element name { name.attributes, name.content }
Patrick@350
   376
Patrick@350
   377
name.attributes =
Patrick@350
   378
   name.of.attribute?
Patrick@350
   379
name.of.attribute = attribute of {
Patrick@350
   380
   "person" | "company" | "book" | "newspaper" | "party" | "movie"
Patrick@350
   381
 | "painting" }
Patrick@350
   382
Patrick@350
   383
name.content = mixed { sup* }
Patrick@350
   384
Patrick@350
   385
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Patrick@350
   386
Patrick@350
   387
date = element date { date.attributes, date.content }
Patrick@350
   388
Patrick@350
   389
date.attributes =
Patrick@350
   390
   date.value.attribute
Patrick@350
   391
date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
Patrick@350
   392
Patrick@350
   393
date.content = mixed { sup* }
Patrick@350
   394
patrick@36
   395
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@36
   396
patrick@36
   397
link = element link { link.attributes, link.content }
patrick@36
   398
patrick@36
   399
link.attributes =
patrick@36
   400
   uri.attribute
patrick@36
   401
uri.attribute = attribute uri { xsd:anyURI }
patrick@36
   402
Patrick@288
   403
link.content = simple.inlines
patrick@36
   404
patrick@0
   405
patrick@0
   406
# =============================================================================
patrick@20
   407
#                               REMAP ATTRIBUTES
patrick@0
   408
# =============================================================================
patrick@0
   409
patrick@0
   410
remap.attributes =
patrick@0
   411
   as.attribute?
patrick@0
   412
 & attributes.attribute?
patrick@97
   413
 & transform.attribute?
patrick@0
   414
as.attribute = attribute as { xsd:QName }
patrick@0
   415
attributes.attribute =
patrick@0
   416
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}
patrick@97
   417
transform.attribute = attribute transform { xsd:anyURI }