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