RelaxNG/publiquiz.rnc
author Patrick PIERRE
lun., 11 févr. 2013 13:18:31 +0100
changeset 168 c0413c8aa327
parent 166 4e4c9b47f2a1
child 169 416be14707c1
permissions -rw-r--r--
Mode multiple
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@161
   158
# ~~~~~~ matching
patrick@73
   159
matching = element matching { matching.content }
patrick@75
   160
patrick@73
   161
matching.content =
patrick@73
   162
   match,
patrick@73
   163
   match+
patrick@73
   164
Patrick@161
   165
# ~~~~~~ match
Patrick@161
   166
match = element match { match.content }
Patrick@161
   167
Patrick@161
   168
match.content =
Patrick@161
   169
   match.item,
Patrick@161
   170
   match.item
Patrick@161
   171
patrick@73
   172
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sort ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   173
patrick@73
   174
sort = element sort { sort.attributes, sort.content }
patrick@73
   175
patrick@73
   176
sort.attributes =
patrick@73
   177
   shuffle.attribute?
patrick@75
   178
patrick@73
   179
sort.content =
patrick@73
   180
   comparison?,
patrick@73
   181
   sort.item,
patrick@73
   182
   sort.item+
patrick@73
   183
patrick@125
   184
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ categories ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@125
   185
patrick@125
   186
# ~~~~~~ categories
Patrick@168
   187
categories = element categories { categories.attributes, categories.content }
patrick@125
   188
Patrick@168
   189
categories.attributes =
Patrick@168
   190
   multiple.attribute?
Patrick@168
   191
   
patrick@125
   192
categories.content =
patrick@125
   193
   category,
patrick@125
   194
   category+
patrick@125
   195
patrick@125
   196
# ~~~~~~ category
patrick@125
   197
category = element category { category.content }
patrick@125
   198
patrick@125
   199
category.content =
patrick@125
   200
   category.head,
patrick@125
   201
   category.item*
patrick@125
   202
   
patrick@125
   203
# ~~~~~~ category.head
patrick@125
   204
category.head = element head { category.head.content }
patrick@125
   205
patrick@125
   206
category.head.content =
patrick@125
   207
   title,
patrick@127
   208
   shorttitle?,
patrick@125
   209
   subtitle?
patrick@125
   210
patrick@87
   211
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ production ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@87
   212
patrick@87
   213
production = element production { empty }
patrick@87
   214
patrick@73
   215
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composite ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   216
patrick@77
   217
# ~~~~~~ composite
Patrick@161
   218
composite = element composite { composite.attributes, composite.content }
Patrick@161
   219
Patrick@161
   220
composite.attributes =
Patrick@161
   221
   multipage.attribute?
Patrick@161
   222
multipage.attribute = attribute multipage { xsd:boolean } 
patrick@75
   223
patrick@73
   224
composite.content =
patrick@85
   225
   subquiz,
Patrick@154
   226
   subquiz+
patrick@77
   227
patrick@85
   228
# ~~~~~~ subquiz
patrick@85
   229
subquiz = element subquiz { subquiz.content }
patrick@77
   230
patrick@85
   231
subquiz.content =
patrick@77
   232
   instructions?,
Patrick@141
   233
   engine,
Patrick@141
   234
   help?,
Patrick@141
   235
   answer?
patrick@73
   236
patrick@73
   237
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   238
patrick@73
   239
help = element help { help.content }
patrick@73
   240
patrick@73
   241
help.content =
patrick@73
   242
   (section+ | block+)?,
patrick@73
   243
   link*
patrick@73
   244
patrick@87
   245
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   246
patrick@87
   247
answer = element answer { answer.content }
patrick@73
   248
patrick@87
   249
answer.content =
patrick@81
   250
   (section+ | block+)?,
patrick@80
   251
   link*
patrick@73
   252
patrick@73
   253
patrick@73
   254
# =============================================================================
patrick@73
   255
#                                 BLOCK LEVEL
patrick@73
   256
# =============================================================================
patrick@73
   257
patrick@73
   258
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   259
patrick@73
   260
blanks.block =
patrick@73
   261
   (blanks.p | speech | blanks.list | blockquote | blanks.table | media)
patrick@73
   262
point.block =
patrick@73
   263
   (point.p | speech | point.list | blockquote | point.table | media)
patrick@73
   264
patrick@73
   265
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   266
patrick@73
   267
blanks.p = element p { blanks.p.content }
patrick@73
   268
point.p = element p { point.p.content }
patrick@73
   269
patrick@73
   270
blanks.p.content =
patrick@75
   271
   blanks.inlines
patrick@73
   272
point.p.content =
patrick@75
   273
   point.inlines
patrick@73
   274
patrick@73
   275
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   276
patrick@73
   277
# ~~~~~~ list
patrick@75
   278
blanks.list = element list {
patrick@73
   279
   block.head?,
patrick@73
   280
   (  (attribute type {"ordered"}?, blanks.item, blanks.item+)
patrick@73
   281
    | (attribute type {"glossary"}, glossary.item+) )
patrick@75
   282
}
patrick@75
   283
point.list = element list {
patrick@73
   284
   block.head?,
patrick@73
   285
   (  (attribute type {"ordered"}?, point.item, point.item+)
patrick@73
   286
    | (attribute type {"glossary"}, glossary.item+) )
patrick@75
   287
}
patrick@73
   288
patrick@73
   289
# ~~~~~~ item
patrick@73
   290
blanks.item = element item { blanks.item.content }
patrick@73
   291
point.item = element item { point.item.content }
patrick@73
   292
patrick@73
   293
blanks.item.content =
patrick@75
   294
   blanks.inlines
patrick@73
   295
 | blanks.block+
patrick@73
   296
point.item.content =
patrick@75
   297
   point.inlines
patrick@73
   298
 | point.block+
patrick@73
   299
patrick@73
   300
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   301
patrick@73
   302
blanks.table = element table { blanks.table.content }
patrick@73
   303
point.table = element table { point.table.content }
patrick@73
   304
patrick@73
   305
blanks.table.content =
patrick@73
   306
   block.head?,
patrick@73
   307
   blanks.tgroup+,
patrick@111
   308
   table.caption?
patrick@73
   309
point.table.content =
patrick@73
   310
   block.head?,
patrick@73
   311
   point.tgroup+,
patrick@111
   312
   table.caption?
patrick@73
   313
patrick@73
   314
# ~~~~~~ tgroup
patrick@73
   315
blanks.tgroup = element tgroup { tgroup.attributes, blanks.tgroup.content }
patrick@73
   316
point.tgroup = element tgroup { tgroup.attributes, point.tgroup.content }
patrick@73
   317
patrick@73
   318
blanks.tgroup.content =
patrick@73
   319
   thead?,
patrick@73
   320
   blanks.tbody
patrick@73
   321
point.tgroup.content =
patrick@73
   322
   thead?,
patrick@73
   323
   point.tbody
patrick@73
   324
patrick@73
   325
# ~~~~~~ tbody
patrick@73
   326
blanks.tbody = element tbody { tbody.attributes, blanks.tbody.content }
patrick@73
   327
point.tbody = element tbody { tbody.attributes, point.tbody.content }
patrick@73
   328
patrick@73
   329
blanks.tbody.content =
patrick@73
   330
   blanks.row+
patrick@73
   331
point.tbody.content =
patrick@73
   332
   point.row+
patrick@73
   333
patrick@73
   334
# ~~~~~~ row
patrick@148
   335
blanks.row = element row { row.attributes, blanks.row.content }
patrick@148
   336
point.row = element row { row.attributes, point.row.content }
patrick@73
   337
patrick@73
   338
blanks.row.content =
patrick@73
   339
  blanks.entry+
patrick@73
   340
point.row.content =
patrick@73
   341
  point.entry+
patrick@73
   342
patrick@73
   343
# ~~~~~~ entry
patrick@73
   344
blanks.entry = element entry { blanks.entry.content }
patrick@73
   345
point.entry = element entry { point.entry.content }
patrick@73
   346
patrick@73
   347
blanks.entry.content =
patrick@75
   348
   blanks.inlines
patrick@73
   349
 | (p | media)+
patrick@73
   350
patrick@73
   351
point.entry.content =
patrick@75
   352
   point.inlines
patrick@73
   353
 | (p | media)+
patrick@73
   354
patrick@73
   355
# ~~~~~~~~~~~~~~~~~~~~~~~~ choices.right, choices.wrong ~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   356
patrick@73
   357
choices.right = element right { choices.right.content }
patrick@73
   358
choices.wrong = element wrong { choices.right.content }
patrick@73
   359
patrick@73
   360
choices.right.content =
patrick@73
   361
   inlines
Patrick@161
   362
 | ((p | image | (audio, image?) | video), help?, answer?)
patrick@73
   363
patrick@73
   364
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks.wrongs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   365
patrick@73
   366
# ~~~~~~ blanks.wrongs
patrick@73
   367
blanks.wrongs = element wrongs { blanks.wrongs.content }
patrick@73
   368
patrick@73
   369
blanks.wrongs.content =
patrick@73
   370
   blanks.wrong+
patrick@73
   371
patrick@73
   372
# ~~~~~~ blanks.wrong
patrick@73
   373
blanks.wrong = element wrong { blanks.wrong.content }
patrick@73
   374
patrick@73
   375
blanks.wrong.content = text
patrick@73
   376
Patrick@161
   377
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (match) item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   378
Patrick@161
   379
match.item = element item { match.item.content }
patrick@73
   380
Patrick@161
   381
match.item.content =
Patrick@161
   382
   inlines
patrick@166
   383
 | ((p | image | (audio, image?) | video), help?, answer?)
patrick@73
   384
patrick@75
   385
# ~~~~~~~~~~~~~~~~~~~~~~~~ (sort) comparison, item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   386
patrick@73
   387
# ~~~~~~ comparison
patrick@73
   388
comparison = element comparison { comparison.content }
patrick@73
   389
patrick@73
   390
comparison.content = inlines
patrick@73
   391
patrick@73
   392
# ~~~~~~ sort.item
patrick@73
   393
sort.item = element item { sort.item.attributes, sort.item.content }
patrick@73
   394
patrick@73
   395
sort.item.attributes =
patrick@73
   396
   item.shuffle.attribute?
patrick@73
   397
item.shuffle.attribute = attribute shuffle { xsd:integer }
patrick@73
   398
Patrick@161
   399
sort.item.content =
Patrick@161
   400
   inlines
patrick@166
   401
 | ((p | image | (audio, image?) | video), help?, answer?)
patrick@73
   402
patrick@125
   403
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (category) item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@125
   404
patrick@125
   405
category.item = element item { category.item.content }
patrick@125
   406
Patrick@161
   407
category.item.content =
Patrick@161
   408
   inlines
patrick@166
   409
 | ((p | image | (audio, image?) | video), help?, answer?)
patrick@125
   410
patrick@73
   411
patrick@73
   412
# =============================================================================
patrick@73
   413
#                                 INLINE LEVEL
patrick@73
   414
# =============================================================================
patrick@73
   415
patrick@75
   416
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@75
   417
patrick@75
   418
blanks.inlines = mixed {
patrick@75
   419
   sup*
patrick@75
   420
 & sub*
patrick@75
   421
 & var*
patrick@75
   422
 & number*
patrick@75
   423
 & math*
patrick@75
   424
 & date*
patrick@75
   425
 & name*
patrick@75
   426
 & note*
patrick@75
   427
 & foreign*
patrick@75
   428
 & highlight*
patrick@75
   429
 & mentioned*
patrick@75
   430
 & quote*
patrick@75
   431
 & acronym*
patrick@75
   432
 & term*
patrick@75
   433
 & link*
patrick@75
   434
 & anchor*
patrick@75
   435
 & blank*
patrick@75
   436
}
patrick@75
   437
point.inlines = mixed {
patrick@75
   438
   sup*
patrick@75
   439
 & sub*
patrick@75
   440
 & var*
patrick@75
   441
 & number*
patrick@75
   442
 & math*
patrick@75
   443
 & date*
patrick@75
   444
 & name*
patrick@75
   445
 & note*
patrick@75
   446
 & foreign*
patrick@75
   447
 & highlight*
patrick@75
   448
 & mentioned*
patrick@75
   449
 & quote*
patrick@75
   450
 & acronym*
patrick@75
   451
 & term*
patrick@75
   452
 & link*
patrick@75
   453
 & anchor*
patrick@75
   454
 & blank*
patrick@75
   455
 & point.right*
patrick@75
   456
 & point.wrong*
patrick@75
   457
}
patrick@75
   458
patrick@73
   459
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blank ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   460
patrick@73
   461
# ~~~~~~ blank
patrick@73
   462
blank = element blank { blank.content }
patrick@73
   463
patrick@73
   464
blank.content =
patrick@73
   465
   text
patrick@87
   466
 | (s+, help?, answer?)
patrick@73
   467
patrick@73
   468
# ~~~~~~ s
patrick@73
   469
s = element s { s.content }
patrick@73
   470
patrick@73
   471
s.content = text
patrick@73
   472
patrick@73
   473
# ~~~~~~~~~~~~~~~~~~~~~~~~~ point.right, point.wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   474
patrick@73
   475
point.right = element right { point.right.content }
patrick@73
   476
point.wrong = element wrong { point.right.content }
patrick@73
   477
patrick@73
   478
point.right.content = inlines