RelaxNG/publiquiz.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
mar., 24 janv. 2012 19:45:41 +0100
changeset 81 a9276e7bcdf1
parent 80 4392d9609436
child 84 666cb4bd1342
permissions -rw-r--r--
Ajout lien dans commentaire
patrick@73
     1
# $Id$
patrick@73
     2
patrick@73
     3
patrick@73
     4
include "publidoc.rnc" {
patrick@73
     5
   start = publiquiz
patrick@73
     6
patrick@73
     7
   document.content =
patrick@73
     8
      top.head?,
patrick@73
     9
      (division | topic | quiz)+
patrick@73
    10
}
patrick@73
    11
patrick@75
    12
patrick@73
    13
publiquiz = element publiquiz {
patrick@73
    14
   publiquiz.attributes,
patrick@73
    15
   publiquiz.content
patrick@73
    16
}
patrick@73
    17
patrick@73
    18
publiquiz.attributes =
patrick@73
    19
   version.attribute
patrick@73
    20
patrick@73
    21
publiquiz.content =
patrick@73
    22
   document
patrick@73
    23
 | top.quiz
patrick@73
    24
patrick@73
    25
patrick@73
    26
# =============================================================================
patrick@73
    27
#                                  TOP LEVEL
patrick@73
    28
# =============================================================================
patrick@73
    29
patrick@73
    30
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quiz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
    31
patrick@73
    32
top.quiz = element quiz { top.quiz.attributes, quiz.content }
patrick@73
    33
patrick@73
    34
top.quiz.attributes =
patrick@73
    35
   quiz.id.attribute
patrick@73
    36
 & lang.attribute?
patrick@73
    37
patrick@73
    38
patrick@73
    39
# =============================================================================
patrick@73
    40
#                               COMPONENT LEVEL
patrick@73
    41
# =============================================================================
patrick@73
    42
patrick@73
    43
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quiz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
    44
patrick@73
    45
quiz = element quiz { quiz.attributes, quiz.content }
patrick@73
    46
patrick@73
    47
quiz.attributes =
patrick@73
    48
   quiz.id.attribute?
patrick@73
    49
 & lang.attribute?
patrick@73
    50
quiz.id.attribute = attribute xml:id { xsd:ID }
patrick@73
    51
patrick@73
    52
quiz.content =
patrick@73
    53
   component.head?,
patrick@73
    54
   instructions,
patrick@73
    55
   (engine | composite)?,
patrick@73
    56
   help?,
patrick@73
    57
   commentary?
patrick@73
    58
patrick@73
    59
patrick@73
    60
# =============================================================================
patrick@73
    61
#                                 SECTION LEVEL
patrick@73
    62
# =============================================================================
patrick@73
    63
patrick@73
    64
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
    65
patrick@73
    66
blanks.section = element section { section.attributes, blanks.section.content }
patrick@73
    67
point.section = element section { section.attributes, point.section.content }
patrick@73
    68
patrick@73
    69
blanks.section.content =
patrick@73
    70
   section.head?,
patrick@73
    71
   (blanks.section+ | blanks.block+)
patrick@73
    72
point.section.content =
patrick@73
    73
   section.head?,
patrick@73
    74
   (point.section+ | point.block+)
patrick@73
    75
patrick@73
    76
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ instructions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
    77
patrick@73
    78
instructions = element instructions { section.content }
patrick@73
    79
patrick@73
    80
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ engine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
    81
patrick@73
    82
engine =
patrick@75
    83
   choices
patrick@75
    84
 | blanks
patrick@73
    85
 | point
patrick@73
    86
 | matching
patrick@73
    87
 | sort
patrick@73
    88
patrick@73
    89
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ choices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
    90
patrick@75
    91
choices = element choices {
patrick@75
    92
   (attribute type {"radio"}, choices.attributes, choices.radio.content)
patrick@75
    93
 | (attribute type {"check"}, choices.attributes, choices.check.content)
patrick@75
    94
}
patrick@73
    95
patrick@73
    96
choices.attributes =
patrick@73
    97
   shuffle.attribute?
patrick@73
    98
shuffle.attribute = attribute shuffle { xsd:boolean }
patrick@73
    99
patrick@73
   100
choices.radio.content =
patrick@73
   101
   choices.right
patrick@73
   102
 & choices.wrong+
patrick@73
   103
choices.check.content =
patrick@73
   104
   (choices.right | choices.wrong)+
patrick@73
   105
patrick@73
   106
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   107
patrick@75
   108
blanks = element blanks {
patrick@75
   109
   (attribute type {"fill"}, blanks.fill.attributes, blanks.fill.content)
patrick@75
   110
 | (attribute type {"select"}, blanks.select.attributes, blanks.select.content)
patrick@75
   111
}
patrick@73
   112
patrick@73
   113
blanks.fill.attributes =
patrick@75
   114
   strict.attribute?
patrick@73
   115
blanks.select.attributes =
patrick@73
   116
   multiple.attribute?
patrick@73
   117
strict.attribute = attribute strict { xsd:boolean }
patrick@73
   118
multiple.attribute = attribute multiple { xsd:boolean }
patrick@73
   119
patrick@73
   120
blanks.fill.content =
patrick@73
   121
   (blanks.block+ | blanks.section+)
patrick@73
   122
blanks.select.content =
patrick@73
   123
   blanks.wrongs?,
patrick@73
   124
   (blanks.block+ | blanks.section+)
patrick@73
   125
patrick@73
   126
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ point ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   127
patrick@73
   128
point = element point { point.attributes, point.content }
patrick@75
   129
patrick@73
   130
point.attributes =
patrick@73
   131
   point.type.attribute?
patrick@73
   132
point.type.attribute = attribute type {
patrick@73
   133
   "radio" | "radio_button" | "check" | "check_button" }
patrick@73
   134
patrick@73
   135
point.content =
patrick@73
   136
   (point.section+ | point.block+)
patrick@73
   137
patrick@73
   138
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ matching ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   139
patrick@73
   140
matching = element matching { matching.content }
patrick@75
   141
patrick@73
   142
matching.content =
patrick@73
   143
   match,
patrick@73
   144
   match+
patrick@73
   145
patrick@73
   146
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sort ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   147
patrick@73
   148
sort = element sort { sort.attributes, sort.content }
patrick@73
   149
patrick@73
   150
sort.attributes =
patrick@73
   151
   shuffle.attribute?
patrick@75
   152
patrick@73
   153
sort.content =
patrick@73
   154
   comparison?,
patrick@73
   155
   sort.item,
patrick@73
   156
   sort.item+
patrick@73
   157
patrick@73
   158
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composite ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   159
patrick@77
   160
# ~~~~~~ composite
patrick@73
   161
composite = element composite { composite.content }
patrick@75
   162
patrick@73
   163
composite.content =
patrick@77
   164
   composite.quiz,
patrick@77
   165
   composite.quiz+
patrick@77
   166
patrick@77
   167
# ~~~~~~ composite.quiz
patrick@77
   168
composite.quiz = element quiz { composite.quiz.content }
patrick@77
   169
patrick@77
   170
composite.quiz.content =
patrick@77
   171
   instructions?,
patrick@77
   172
   engine
patrick@73
   173
patrick@73
   174
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   175
patrick@73
   176
help = element help { help.content }
patrick@73
   177
patrick@73
   178
help.content =
patrick@73
   179
   (section+ | block+)?,
patrick@73
   180
   link*
patrick@73
   181
patrick@73
   182
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ commentary ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   183
patrick@73
   184
commentary = element commentary { commentary.content }
patrick@73
   185
patrick@73
   186
commentary.content =
patrick@81
   187
   (section+ | block+)?,
patrick@80
   188
   link*
patrick@73
   189
patrick@73
   190
patrick@73
   191
# =============================================================================
patrick@73
   192
#                                 BLOCK LEVEL
patrick@73
   193
# =============================================================================
patrick@73
   194
patrick@73
   195
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   196
patrick@73
   197
blanks.block =
patrick@73
   198
   (blanks.p | speech | blanks.list | blockquote | blanks.table | media)
patrick@73
   199
point.block =
patrick@73
   200
   (point.p | speech | point.list | blockquote | point.table | media)
patrick@73
   201
patrick@73
   202
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   203
patrick@73
   204
blanks.p = element p { blanks.p.content }
patrick@73
   205
point.p = element p { point.p.content }
patrick@73
   206
patrick@73
   207
blanks.p.content =
patrick@75
   208
   blanks.inlines
patrick@73
   209
point.p.content =
patrick@75
   210
   point.inlines
patrick@73
   211
patrick@73
   212
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   213
patrick@73
   214
# ~~~~~~ list
patrick@75
   215
blanks.list = element list {
patrick@73
   216
   block.head?,
patrick@73
   217
   (  (attribute type {"ordered"}?, blanks.item, blanks.item+)
patrick@73
   218
    | (attribute type {"glossary"}, glossary.item+) )
patrick@75
   219
}
patrick@75
   220
point.list = element list {
patrick@73
   221
   block.head?,
patrick@73
   222
   (  (attribute type {"ordered"}?, point.item, point.item+)
patrick@73
   223
    | (attribute type {"glossary"}, glossary.item+) )
patrick@75
   224
}
patrick@73
   225
patrick@73
   226
# ~~~~~~ item
patrick@73
   227
blanks.item = element item { blanks.item.content }
patrick@73
   228
point.item = element item { point.item.content }
patrick@73
   229
patrick@73
   230
blanks.item.content =
patrick@75
   231
   blanks.inlines
patrick@73
   232
 | blanks.block+
patrick@73
   233
point.item.content =
patrick@75
   234
   point.inlines
patrick@73
   235
 | point.block+
patrick@73
   236
patrick@73
   237
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   238
patrick@73
   239
blanks.table = element table { blanks.table.content }
patrick@73
   240
point.table = element table { point.table.content }
patrick@73
   241
patrick@73
   242
blanks.table.content =
patrick@73
   243
   block.head?,
patrick@73
   244
   blanks.tgroup+,
patrick@73
   245
   caption?
patrick@73
   246
point.table.content =
patrick@73
   247
   block.head?,
patrick@73
   248
   point.tgroup+,
patrick@73
   249
   caption?
patrick@73
   250
patrick@73
   251
# ~~~~~~ tgroup
patrick@73
   252
blanks.tgroup = element tgroup { tgroup.attributes, blanks.tgroup.content }
patrick@73
   253
point.tgroup = element tgroup { tgroup.attributes, point.tgroup.content }
patrick@73
   254
patrick@73
   255
blanks.tgroup.content =
patrick@73
   256
   thead?,
patrick@73
   257
   blanks.tbody
patrick@73
   258
point.tgroup.content =
patrick@73
   259
   thead?,
patrick@73
   260
   point.tbody
patrick@73
   261
patrick@73
   262
# ~~~~~~ tbody
patrick@73
   263
blanks.tbody = element tbody { tbody.attributes, blanks.tbody.content }
patrick@73
   264
point.tbody = element tbody { tbody.attributes, point.tbody.content }
patrick@73
   265
patrick@73
   266
blanks.tbody.content =
patrick@73
   267
   blanks.row+
patrick@73
   268
point.tbody.content =
patrick@73
   269
   point.row+
patrick@73
   270
patrick@73
   271
# ~~~~~~ row
patrick@73
   272
blanks.row = element row { row.attribute, blanks.row.content }
patrick@73
   273
point.row = element row { row.attribute, point.row.content }
patrick@73
   274
patrick@73
   275
blanks.row.content =
patrick@73
   276
  blanks.entry+
patrick@73
   277
point.row.content =
patrick@73
   278
  point.entry+
patrick@73
   279
patrick@73
   280
# ~~~~~~ entry
patrick@73
   281
blanks.entry = element entry { blanks.entry.content }
patrick@73
   282
point.entry = element entry { point.entry.content }
patrick@73
   283
patrick@73
   284
blanks.entry.content =
patrick@75
   285
   blanks.inlines
patrick@73
   286
 | (p | media)+
patrick@73
   287
patrick@73
   288
point.entry.content =
patrick@75
   289
   point.inlines
patrick@73
   290
 | (p | media)+
patrick@73
   291
patrick@73
   292
patrick@73
   293
# ~~~~~~~~~~~~~~~~~~~~~~~~ choices.right, choices.wrong ~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   294
patrick@73
   295
choices.right = element right { choices.right.content }
patrick@73
   296
choices.wrong = element wrong { choices.right.content }
patrick@73
   297
patrick@73
   298
choices.right.content =
patrick@73
   299
   inlines
patrick@73
   300
 | p+
patrick@73
   301
patrick@73
   302
patrick@73
   303
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks.wrongs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   304
patrick@73
   305
# ~~~~~~ blanks.wrongs
patrick@73
   306
blanks.wrongs = element wrongs { blanks.wrongs.content }
patrick@73
   307
patrick@73
   308
blanks.wrongs.content =
patrick@73
   309
   blanks.wrong+
patrick@73
   310
patrick@73
   311
# ~~~~~~ blanks.wrong
patrick@73
   312
blanks.wrong = element wrong { blanks.wrong.content }
patrick@73
   313
patrick@73
   314
blanks.wrong.content = text
patrick@73
   315
patrick@73
   316
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ match ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   317
patrick@73
   318
match = element match { match.content }
patrick@73
   319
patrick@73
   320
match.content =
patrick@73
   321
   (p | section),
patrick@73
   322
   (p | section)
patrick@73
   323
patrick@75
   324
# ~~~~~~~~~~~~~~~~~~~~~~~~ (sort) comparison, item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   325
patrick@73
   326
# ~~~~~~ comparison
patrick@73
   327
comparison = element comparison { comparison.content }
patrick@73
   328
patrick@73
   329
comparison.content = inlines
patrick@73
   330
patrick@73
   331
# ~~~~~~ sort.item
patrick@73
   332
sort.item = element item { sort.item.attributes, sort.item.content }
patrick@73
   333
patrick@73
   334
sort.item.attributes =
patrick@73
   335
   item.shuffle.attribute?
patrick@73
   336
item.shuffle.attribute = attribute shuffle { xsd:integer }
patrick@73
   337
patrick@73
   338
sort.item.content = inlines
patrick@73
   339
patrick@73
   340
patrick@73
   341
# =============================================================================
patrick@73
   342
#                                 INLINE LEVEL
patrick@73
   343
# =============================================================================
patrick@73
   344
patrick@75
   345
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@75
   346
patrick@75
   347
blanks.inlines = mixed {
patrick@75
   348
   sup*
patrick@75
   349
 & sub*
patrick@75
   350
 & var*
patrick@75
   351
 & number*
patrick@75
   352
 & math*
patrick@75
   353
 & date*
patrick@75
   354
 & name*
patrick@75
   355
 & note*
patrick@75
   356
 & foreign*
patrick@75
   357
 & highlight*
patrick@75
   358
 & mentioned*
patrick@75
   359
 & quote*
patrick@75
   360
 & acronym*
patrick@75
   361
 & term*
patrick@75
   362
 & link*
patrick@75
   363
 & anchor*
patrick@75
   364
 & blank*
patrick@75
   365
}
patrick@75
   366
point.inlines = mixed {
patrick@75
   367
   sup*
patrick@75
   368
 & sub*
patrick@75
   369
 & var*
patrick@75
   370
 & number*
patrick@75
   371
 & math*
patrick@75
   372
 & date*
patrick@75
   373
 & name*
patrick@75
   374
 & note*
patrick@75
   375
 & foreign*
patrick@75
   376
 & highlight*
patrick@75
   377
 & mentioned*
patrick@75
   378
 & quote*
patrick@75
   379
 & acronym*
patrick@75
   380
 & term*
patrick@75
   381
 & link*
patrick@75
   382
 & anchor*
patrick@75
   383
 & blank*
patrick@75
   384
 & point.right*
patrick@75
   385
 & point.wrong*
patrick@75
   386
}
patrick@75
   387
patrick@73
   388
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blank ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   389
patrick@73
   390
# ~~~~~~ blank
patrick@73
   391
blank = element blank { blank.content }
patrick@73
   392
patrick@73
   393
blank.content =
patrick@73
   394
   text
patrick@73
   395
 | (s+, help?, commentary?)
patrick@73
   396
patrick@73
   397
# ~~~~~~ s
patrick@73
   398
s = element s { s.content }
patrick@73
   399
patrick@73
   400
s.content = text
patrick@73
   401
patrick@73
   402
# ~~~~~~~~~~~~~~~~~~~~~~~~~ point.right, point.wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   403
patrick@73
   404
point.right = element right { point.right.content }
patrick@73
   405
point.wrong = element wrong { point.right.content }
patrick@73
   406
patrick@73
   407
point.right.content = inlines