RelaxNG/publidoc.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
sam., 11 juin 2011 00:27:50 +0200
changeset 9 1efd69b7c90e
parent 8 1d4ee28efd68
child 11 2b32b535705c
permissions -rw-r--r--
Ajout d'exemples
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@9
   221
block = (parag | \list | media | speech)
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@9
   238
   (  (attribute type {"ordered"} ?, item, item+)
patrick@9
   239
    | (attribute type {"itemized"}, item, item+)
patrick@9
   240
    | (attribute type {"glossary"}, glossary.item+) )
patrick@9
   241
patrick@9
   242
# ~~~~~~ item
patrick@9
   243
item = element item { item.content }
patrick@9
   244
patrick@9
   245
item.content = block+
patrick@9
   246
patrick@9
   247
# ~~~~~~ glossary.item
patrick@9
   248
glossary.item = element item { glossary.item.content }
patrick@9
   249
patrick@9
   250
glossary.item.content =
patrick@9
   251
   label,
patrick@9
   252
   block+
patrick@9
   253
patrick@9
   254
# ~~~~~~ label
patrick@9
   255
label = element label { label.content }
patrick@9
   256
patrick@9
   257
label.content = inlines
patrick@9
   258
patrick@0
   259
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ media ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   260
patrick@2
   261
# ~~~~~~ media
patrick@0
   262
media = element media { media.content }
patrick@0
   263
patrick@0
   264
media.content =
patrick@0
   265
   image+,
patrick@0
   266
   media.caption?
patrick@0
   267
patrick@0
   268
media.id.attribute = attribute id { xsd:NMTOKEN }
patrick@0
   269
patrick@2
   270
# ~~~~~~ image
patrick@0
   271
image = element image { image.attributes, image.content }
patrick@0
   272
patrick@0
   273
image.attributes =
patrick@0
   274
   media.id.attribute
patrick@0
   275
patrick@0
   276
image.content =
patrick@0
   277
   copyright?
patrick@0
   278
patrick@3
   279
# ~~~~~~ caption
patrick@3
   280
media.caption = element caption { media.caption.content }
patrick@3
   281
patrick@3
   282
media.caption.content =
patrick@3
   283
   parag+
patrick@3
   284
patrick@2
   285
# ~~~~~~ copyright
patrick@0
   286
copyright = element copyright { copyright.content }
patrick@3
   287
patrick@0
   288
copyright.content = inlines
patrick@0
   289
patrick@0
   290
patrick@5
   291
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ speech ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   292
patrick@5
   293
# ~~~~~~ speech
patrick@5
   294
speech = element speech { speech.content }
patrick@5
   295
patrick@5
   296
speech.content =
patrick@5
   297
   speaker?,
patrick@5
   298
   stage?,
patrick@5
   299
   parag+
patrick@5
   300
patrick@5
   301
# ~~~~~~ speaker
patrick@5
   302
speaker = element speaker { speaker.content }
patrick@5
   303
patrick@5
   304
speaker.content = inlines
patrick@5
   305
patrick@5
   306
# ~~~~~~ stage
patrick@5
   307
stage = element stage { stage.content }
patrick@5
   308
patrick@5
   309
stage.content = inlines
patrick@5
   310
patrick@5
   311
patrick@0
   312
# =============================================================================
patrick@0
   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@0
   321
 & romannum*
patrick@0
   322
 & date*
patrick@0
   323
 & name*
patrick@5
   324
 & note*
patrick@0
   325
 & foreign*
patrick@0
   326
 & highlight*
patrick@5
   327
 & mentioned*
patrick@5
   328
 & quote*
patrick@8
   329
 & acronym*
patrick@8
   330
 & term*
patrick@0
   331
}
patrick@0
   332
patrick@0
   333
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   334
patrick@0
   335
sup = element sup { inlines }
patrick@0
   336
patrick@0
   337
sub = element sub { inlines }
patrick@0
   338
patrick@0
   339
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ romannum ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   340
patrick@0
   341
romannum = element romannum { xsd:token {pattern = "([dlxvi]+)"} }
patrick@0
   342
patrick@0
   343
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   344
patrick@0
   345
date = element date { date.attributes, date.content }
patrick@0
   346
patrick@3
   347
date.attributes =
patrick@5
   348
   date.of.attribute?
patrick@0
   349
date.of.attribute = attribute of { date.of.enumeration }
patrick@0
   350
date.of.enumeration = "event" | "birth" | "death"
patrick@0
   351
patrick@0
   352
date.content = xsd:date | xsd:gYearMonth | xsd:gYear
patrick@0
   353
patrick@2
   354
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   355
patrick@0
   356
name = element name { name.attributes, name.content }
patrick@2
   357
patrick@2
   358
name.attributes =
patrick@2
   359
   name.of.attribute?
patrick@0
   360
name.of.attribute = attribute of { name.of.enumeration }
patrick@0
   361
name.of.enumeration = "person" | "company" | "book" | "newspaper" | "party"
patrick@0
   362
patrick@2
   363
name.content = inlines
patrick@2
   364
patrick@5
   365
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ note ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   366
patrick@5
   367
note = element note { note.attributes, note.content }
patrick@0
   368
patrick@5
   369
note.attributes =
patrick@5
   370
   note.label.attribute?
patrick@5
   371
note.label.attribute = attribute label { text }
patrick@0
   372
patrick@5
   373
note.content =
patrick@2
   374
   parag+
patrick@0
   375
patrick@0
   376
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foreign ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   377
patrick@0
   378
foreign = element foreign { foreign.attributes, foreign.content }
patrick@0
   379
patrick@9
   380
foreign.attributes =
patrick@9
   381
   lang.attribute?
patrick@0
   382
patrick@0
   383
foreign.content = inlines
patrick@0
   384
patrick@0
   385
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   386
patrick@0
   387
highlight = element highlight { highlight.content }
patrick@0
   388
patrick@0
   389
highlight.content = inlines
patrick@0
   390
patrick@5
   391
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ mentioned ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   392
patrick@5
   393
mentioned = element mentioned { mentioned.content }
patrick@5
   394
patrick@5
   395
mentioned.content = inlines
patrick@5
   396
patrick@5
   397
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quote ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@5
   398
patrick@5
   399
quote = element quote { quote.content }
patrick@5
   400
patrick@5
   401
quote.content = inlines
patrick@5
   402
patrick@8
   403
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ acronym ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@8
   404
patrick@8
   405
acronym = element acronym { acronym.content }
patrick@8
   406
patrick@8
   407
acronym.content = inlines
patrick@8
   408
patrick@8
   409
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ term ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@8
   410
patrick@8
   411
term = element term { term.content }
patrick@8
   412
patrick@8
   413
term.content = inlines
patrick@8
   414
patrick@0
   415
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@0
   416
patrick@0
   417
link = element link { link.attributes, link.content }
patrick@0
   418
patrick@9
   419
link.attributes =
patrick@9
   420
   (uri.attribute | idref.attribute)?
patrick@9
   421
uri.attribute = attribute uri { xsd:anyURI }
patrick@9
   422
idref.attribute = attribute idref { xsd:IDREF }
patrick@0
   423
patrick@0
   424
link.content = inlines