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