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