RelaxNG/publidoc.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
sam., 11 juin 2011 12:44:21 +0200
changeset 13 846ec40a5b2d
parent 11 2b32b535705c
child 17 ca367d4d080b
permissions -rw-r--r--
Exemples complétés + <date> et <number> améliorés
patrick@0
     1
# $Id$
patrick@0
     2
patrick@0
     3
start = publidoc
patrick@0
     4
patrick@0
     5
patrick@0
     6
publidoc = element publidoc {
patrick@0
     7
   publidoc.attributes,
patrick@0
     8
   publidoc.content
patrick@0
     9
}
patrick@0
    10
patrick@0
    11
publidoc.attributes =
patrick@0
    12
   version.attribute
patrick@0
    13
version.attribute = attribute version { "1.0" }
patrick@0
    14
patrick@0
    15
publidoc.content =
patrick@0
    16
   document
patrick@0
    17
 | top.topic
patrick@0
    18
patrick@0
    19
patrick@0
    20
# =============================================================================
patrick@0
    21
#                                  Top level
patrick@0
    22
# =============================================================================
patrick@0
    23
patrick@0
    24
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ document ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    25
patrick@0
    26
document = element document { document.attributes, document.content }
patrick@0
    27
patrick@0
    28
document.attributes =
patrick@0
    29
   document.id.attribute
patrick@0
    30
document.id.attribute = attribute xml:id { xsd:ID }
patrick@0
    31
patrick@0
    32
document.content =
patrick@0
    33
   metadata?,
patrick@0
    34
   (division+ | topic+)
patrick@0
    35
patrick@0
    36
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ topic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    37
patrick@0
    38
top.topic = element topic { top.topic.attributes, topic.content }
patrick@0
    39
patrick@0
    40
patrick@0
    41
# =============================================================================
patrick@0
    42
#                               Metadata level
patrick@0
    43
# =============================================================================
patrick@0
    44
patrick@0
    45
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    46
patrick@0
    47
metadata = element metadata { metadata.content }
patrick@0
    48
patrick@0
    49
metadata.content =
patrick@0
    50
   title
patrick@0
    51
 & subtitle?
patrick@0
    52
 & author*
patrick@0
    53
 & publisher?
patrick@0
    54
 & language?
patrick@0
    55
 & date?
patrick@0
    56
 & place?
patrick@0
    57
 & source*
patrick@0
    58
 & subjectset?
patrick@0
    59
 & abstract?
patrick@0
    60
 & annotation*
patrick@0
    61
patrick@0
    62
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    63
patrick@0
    64
title = element title { title.content }
patrick@2
    65
patrick@0
    66
title.content = inlines
patrick@0
    67
patrick@0
    68
subtitle = element subtitle { title.content }
patrick@0
    69
patrick@0
    70
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ author, publisher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
    71
patrick@5
    72
# ~~~~~~ author
patrick@0
    73
author = element author { author.content }
patrick@0
    74
patrick@0
    75
author.content =
patrick@0
    76
   firstname?,
patrick@0
    77
   lastname
patrick@0
    78
patrick@5
    79
# ~~~~~~ publisher
patrick@0
    80
publisher = element publisher { publisher.content }
patrick@0
    81
patrick@0
    82
publisher.content = inlines
patrick@0
    83
patrick@5
    84
# ~~~~~~ firstname
patrick@5
    85
firstname = element firstname { firstname.content }
patrick@5
    86
patrick@5
    87
firstname.content = inlines
patrick@5
    88
patrick@5
    89
# ~~~~~~ lastname
patrick@5
    90
lastname = element lastname { lastname.content }
patrick@5
    91
patrick@5
    92
lastname.content = inlines
patrick@5
    93
patrick@2
    94
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Language ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@2
    95
patrick@2
    96
language = element language { language.attributes }
patrick@2
    97
patrick@2
    98
language.attributes = lang.attribute
patrick@2
    99
lang.attribute = attribute xml:lang { xsd:language }
patrick@2
   100
patrick@2
   101
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ place ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@2
   102
patrick@2
   103
place = element place { place.content }
patrick@2
   104
patrick@2
   105
place.content = inlines
patrick@2
   106
patrick@0
   107
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   108
patrick@2
   109
# ~~~~~~ source
patrick@0
   110
source = element source {
patrick@0
   111
   source.attributes,
patrick@0
   112
   (  (attribute type { "book" }, source.content.book)
patrick@0
   113
    | (attribute type { "file" })),
patrick@0
   114
   source.content
patrick@0
   115
}
patrick@0
   116
patrick@0
   117
source.attributes =
patrick@0
   118
   source.id.attribute
patrick@0
   119
source.id.attribute = attribute id { xsd:NMTOKEN }
patrick@0
   120
patrick@0
   121
source.content.book =
patrick@0
   122
   title,
patrick@0
   123
   pagenumber*
patrick@0
   124
source.content =
patrick@0
   125
   annotation*
patrick@0
   126
patrick@2
   127
# ~~~~~~ pagenumber
patrick@0
   128
pagenumber = element pagenumber { pagenumber.attributes }
patrick@2
   129
patrick@0
   130
pagenumber.attributes =
patrick@0
   131
   pagenumber.value.attribute
patrick@0
   132
pagenumber.value.attribute = attribute value { pagenumber.value.enumeration }
patrick@0
   133
pagenumber.value.enumeration = xsd:positiveInteger
patrick@0
   134
patrick@0
   135
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   136
patrick@2
   137
# ~~~~~~ subjectset
patrick@0
   138
subjectset = element subjectset { subjectset.content }
patrick@0
   139
patrick@0
   140
subjectset.content = subject+
patrick@0
   141
patrick@2
   142
# ~~~~~~ subject
patrick@0
   143
subject = element subject { subject.attributes }
patrick@2
   144
patrick@0
   145
subject.attributes =
patrick@0
   146
   subject.id.attribute
patrick@0
   147
subject.id.attribute = attribute id { xsd:NMTOKEN }
patrick@0
   148
patrick@5
   149
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@2
   150
patrick@2
   151
abstract = element abstract { abstract.content }
patrick@2
   152
patrick@2
   153
abstract.content =
patrick@2
   154
   parag+
patrick@2
   155
patrick@0
   156
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ annotation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   157
patrick@0
   158
annotation = element annotation { annotation.content }
patrick@0
   159
patrick@0
   160
annotation.content = inlines
patrick@0
   161
patrick@0
   162
patrick@0
   163
# =============================================================================
patrick@0
   164
#                                 Division level
patrick@0
   165
# =============================================================================
patrick@0
   166
patrick@0
   167
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   168
patrick@0
   169
division = element division { division.content }
patrick@0
   170
patrick@0
   171
division.content =
patrick@0
   172
   metadata?,
patrick@0
   173
   (division+ | topic+)
patrick@0
   174
patrick@0
   175
patrick@0
   176
# =============================================================================
patrick@0
   177
#                               Component level
patrick@0
   178
# =============================================================================
patrick@0
   179
patrick@0
   180
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ topic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   181
patrick@0
   182
topic = element topic { topic.attributes, topic.content }
patrick@0
   183
patrick@0
   184
top.topic.attributes =
patrick@0
   185
   topic.id.attribute
patrick@0
   186
 & topic.type.attribute?
patrick@0
   187
topic.attributes =
patrick@0
   188
   topic.id.attribute?
patrick@0
   189
 & topic.type.attribute?
patrick@0
   190
topic.id.attribute = attribute xml:id { xsd:ID }
patrick@0
   191
topic.type.attribute = attribute type { xsd:NCName }
patrick@0
   192
patrick@0
   193
topic.content =
patrick@0
   194
   metadata?,
patrick@0
   195
   section+
patrick@0
   196
patrick@0
   197
patrick@0
   198
# =============================================================================
patrick@0
   199
#                                 Section level
patrick@0
   200
# =============================================================================
patrick@0
   201
patrick@0
   202
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   203
patrick@0
   204
section = element section { section.content, section.attributes }
patrick@0
   205
patrick@0
   206
section.content =
patrick@0
   207
   metadata?,
patrick@9
   208
   (section+ | block+)
patrick@0
   209
patrick@0
   210
section.attributes =
patrick@0
   211
   status.attribute?
patrick@0
   212
status.attribute = attribute status { xsd:NCName }
patrick@0
   213
patrick@0
   214
patrick@0
   215
# =============================================================================
patrick@0
   216
#                                 Block level
patrick@0
   217
# =============================================================================
patrick@0
   218
patrick@9
   219
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blocks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@9
   220
patrick@11
   221
block = (parag | \list | speech | media)
patrick@9
   222
patrick@9
   223
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ parag ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   224
patrick@0
   225
parag = element parag { parag.content }
patrick@0
   226
patrick@0
   227
parag.content =
patrick@0
   228
   inlines
patrick@0
   229
 & link*
patrick@0
   230
patrick@9
   231
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@9
   232
patrick@9
   233
# ~~~~~~ list
patrick@9
   234
\list = element list { \list.content }
patrick@9
   235
patrick@9
   236
\list.content =
patrick@9
   237
   title?,
patrick@13
   238
   (  (attribute type {"ordered"} ?, item, item+)
patrick@9
   239
    | (attribute type {"glossary"}, glossary.item+) )
patrick@9
   240
patrick@9
   241
# ~~~~~~ item
patrick@9
   242
item = element item { item.content }
patrick@9
   243
patrick@9
   244
item.content = block+
patrick@9
   245
patrick@9
   246
# ~~~~~~ glossary.item
patrick@9
   247
glossary.item = element item { glossary.item.content }
patrick@9
   248
patrick@9
   249
glossary.item.content =
patrick@9
   250
   label,
patrick@9
   251
   block+
patrick@9
   252
patrick@9
   253
# ~~~~~~ label
patrick@9
   254
label = element label { label.content }
patrick@9
   255
patrick@9
   256
label.content = inlines
patrick@9
   257
patrick@13
   258
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ speech ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@11
   259
patrick@11
   260
# ~~~~~~ speech
patrick@11
   261
speech = element speech { speech.content }
patrick@11
   262
patrick@11
   263
speech.content =
patrick@11
   264
   speaker?,
patrick@11
   265
   stage?,
patrick@11
   266
   parag+
patrick@11
   267
patrick@11
   268
# ~~~~~~ speaker
patrick@11
   269
speaker = element speaker { speaker.content }
patrick@11
   270
patrick@11
   271
speaker.content = inlines
patrick@11
   272
patrick@11
   273
# ~~~~~~ stage
patrick@11
   274
stage = element stage { stage.content }
patrick@11
   275
patrick@11
   276
stage.content = inlines
patrick@11
   277
patrick@0
   278
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ media ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   279
patrick@2
   280
# ~~~~~~ media
patrick@0
   281
media = element media { media.content }
patrick@0
   282
patrick@0
   283
media.content =
patrick@0
   284
   image+,
patrick@0
   285
   media.caption?
patrick@0
   286
patrick@0
   287
media.id.attribute = attribute id { xsd:NMTOKEN }
patrick@0
   288
patrick@2
   289
# ~~~~~~ image
patrick@0
   290
image = element image { image.attributes, image.content }
patrick@0
   291
patrick@0
   292
image.attributes =
patrick@0
   293
   media.id.attribute
patrick@0
   294
patrick@0
   295
image.content =
patrick@0
   296
   copyright?
patrick@0
   297
patrick@3
   298
# ~~~~~~ caption
patrick@3
   299
media.caption = element caption { media.caption.content }
patrick@3
   300
patrick@3
   301
media.caption.content =
patrick@3
   302
   parag+
patrick@3
   303
patrick@2
   304
# ~~~~~~ copyright
patrick@0
   305
copyright = element copyright { copyright.content }
patrick@3
   306
patrick@0
   307
copyright.content = inlines
patrick@0
   308
patrick@0
   309
patrick@0
   310
# =============================================================================
patrick@0
   311
#                                 Inline level
patrick@0
   312
# =============================================================================
patrick@0
   313
patrick@0
   314
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   315
patrick@0
   316
inlines = mixed {
patrick@0
   317
   sup*
patrick@0
   318
 & sub*
patrick@13
   319
 & number*
patrick@0
   320
 & date*
patrick@0
   321
 & name*
patrick@5
   322
 & note*
patrick@0
   323
 & foreign*
patrick@0
   324
 & highlight*
patrick@5
   325
 & mentioned*
patrick@5
   326
 & quote*
patrick@8
   327
 & acronym*
patrick@8
   328
 & term*
patrick@0
   329
}
patrick@0
   330
patrick@0
   331
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   332
patrick@0
   333
sup = element sup { inlines }
patrick@0
   334
patrick@0
   335
sub = element sub { inlines }
patrick@0
   336
patrick@13
   337
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ number ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   338
patrick@13
   339
number = element number {
patrick@13
   340
   ( attribute type {"roman"}, number.attributes, number.roman.content )
patrick@13
   341
 | ( number.attributes, number.content)
patrick@13
   342
}
patrick@13
   343
patrick@13
   344
number.attributes =
patrick@13
   345
   number.value.attribute?
patrick@13
   346
number.value.attribute = attribute value { xsd:integer | xsd:decimal }
patrick@13
   347
patrick@13
   348
number.content = mixed { sup* }
patrick@13
   349
number.roman.content = xsd:token {pattern = "[dlxvi]+"}
patrick@0
   350
patrick@0
   351
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   352
patrick@0
   353
date = element date { date.attributes, date.content }
patrick@0
   354
patrick@3
   355
date.attributes =
patrick@13
   356
   date.value.attribute
patrick@13
   357
 & date.of.attribute?
patrick@13
   358
date.value.attribute = attribute value { xsd:date | xsd:gYearMonth | xsd:gYear }
patrick@0
   359
date.of.attribute = attribute of { date.of.enumeration }
patrick@13
   360
date.of.enumeration = "birth" | "death"
patrick@0
   361
patrick@13
   362
date.content = mixed { sup* }
patrick@0
   363
patrick@2
   364
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   365
patrick@0
   366
name = element name { name.attributes, name.content }
patrick@2
   367
patrick@2
   368
name.attributes =
patrick@2
   369
   name.of.attribute?
patrick@0
   370
name.of.attribute = attribute of { name.of.enumeration }
patrick@0
   371
name.of.enumeration = "person" | "company" | "book" | "newspaper" | "party"
patrick@0
   372
patrick@2
   373
name.content = inlines
patrick@2
   374
patrick@5
   375
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ note ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   376
patrick@5
   377
note = element note { note.attributes, note.content }
patrick@0
   378
patrick@5
   379
note.attributes =
patrick@5
   380
   note.label.attribute?
patrick@5
   381
note.label.attribute = attribute label { text }
patrick@0
   382
patrick@5
   383
note.content =
patrick@2
   384
   parag+
patrick@0
   385
patrick@13
   386
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foreign ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   387
patrick@0
   388
foreign = element foreign { foreign.attributes, foreign.content }
patrick@0
   389
patrick@9
   390
foreign.attributes =
patrick@9
   391
   lang.attribute?
patrick@0
   392
patrick@0
   393
foreign.content = inlines
patrick@0
   394
patrick@0
   395
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   396
patrick@0
   397
highlight = element highlight { highlight.content }
patrick@0
   398
patrick@0
   399
highlight.content = inlines
patrick@0
   400
patrick@5
   401
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mentioned ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   402
patrick@5
   403
mentioned = element mentioned { mentioned.content }
patrick@5
   404
patrick@5
   405
mentioned.content = inlines
patrick@5
   406
patrick@5
   407
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quote ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   408
patrick@5
   409
quote = element quote { quote.content }
patrick@5
   410
patrick@5
   411
quote.content = inlines
patrick@5
   412
patrick@8
   413
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ acronym ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@8
   414
patrick@8
   415
acronym = element acronym { acronym.content }
patrick@8
   416
patrick@8
   417
acronym.content = inlines
patrick@8
   418
patrick@8
   419
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ term ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@8
   420
patrick@8
   421
term = element term { term.content }
patrick@8
   422
patrick@8
   423
term.content = inlines
patrick@8
   424
patrick@0
   425
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   426
patrick@0
   427
link = element link { link.attributes, link.content }
patrick@0
   428
patrick@9
   429
link.attributes =
patrick@9
   430
   (uri.attribute | idref.attribute)?
patrick@9
   431
uri.attribute = attribute uri { xsd:anyURI }
patrick@9
   432
idref.attribute = attribute idref { xsd:IDREF }
patrick@0
   433
patrick@0
   434
link.content = inlines