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