RelaxNG/publiquiz.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
jeu., 02 août 2012 17:16:36 +0200
changeset 127 efce69890bfd
parent 125 dd9b04a54839
child 128 14dc149154f4
permissions -rw-r--r--
Ajout de <shorttitle>
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@127
   188
   shorttitle?,
patrick@125
   189
   subtitle?
patrick@125
   190
patrick@87
   191
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ production ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@87
   192
patrick@87
   193
production = element production { empty }
patrick@87
   194
patrick@73
   195
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composite ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   196
patrick@77
   197
# ~~~~~~ composite
patrick@73
   198
composite = element composite { composite.content }
patrick@75
   199
patrick@73
   200
composite.content =
patrick@85
   201
   subquiz,
patrick@85
   202
   subquiz+
patrick@77
   203
patrick@85
   204
# ~~~~~~ subquiz
patrick@85
   205
subquiz = element subquiz { subquiz.content }
patrick@77
   206
patrick@85
   207
subquiz.content =
patrick@77
   208
   instructions?,
patrick@77
   209
   engine
patrick@73
   210
patrick@73
   211
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   212
patrick@73
   213
help = element help { help.content }
patrick@73
   214
patrick@73
   215
help.content =
patrick@73
   216
   (section+ | block+)?,
patrick@73
   217
   link*
patrick@73
   218
patrick@87
   219
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   220
patrick@87
   221
answer = element answer { answer.content }
patrick@73
   222
patrick@87
   223
answer.content =
patrick@81
   224
   (section+ | block+)?,
patrick@80
   225
   link*
patrick@73
   226
patrick@73
   227
patrick@73
   228
# =============================================================================
patrick@73
   229
#                                 BLOCK LEVEL
patrick@73
   230
# =============================================================================
patrick@73
   231
patrick@73
   232
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   233
patrick@73
   234
blanks.block =
patrick@73
   235
   (blanks.p | speech | blanks.list | blockquote | blanks.table | media)
patrick@73
   236
point.block =
patrick@73
   237
   (point.p | speech | point.list | blockquote | point.table | media)
patrick@73
   238
patrick@73
   239
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   240
patrick@73
   241
blanks.p = element p { blanks.p.content }
patrick@73
   242
point.p = element p { point.p.content }
patrick@73
   243
patrick@73
   244
blanks.p.content =
patrick@75
   245
   blanks.inlines
patrick@73
   246
point.p.content =
patrick@75
   247
   point.inlines
patrick@73
   248
patrick@73
   249
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   250
patrick@73
   251
# ~~~~~~ list
patrick@75
   252
blanks.list = element list {
patrick@73
   253
   block.head?,
patrick@73
   254
   (  (attribute type {"ordered"}?, blanks.item, blanks.item+)
patrick@73
   255
    | (attribute type {"glossary"}, glossary.item+) )
patrick@75
   256
}
patrick@75
   257
point.list = element list {
patrick@73
   258
   block.head?,
patrick@73
   259
   (  (attribute type {"ordered"}?, point.item, point.item+)
patrick@73
   260
    | (attribute type {"glossary"}, glossary.item+) )
patrick@75
   261
}
patrick@73
   262
patrick@73
   263
# ~~~~~~ item
patrick@73
   264
blanks.item = element item { blanks.item.content }
patrick@73
   265
point.item = element item { point.item.content }
patrick@73
   266
patrick@73
   267
blanks.item.content =
patrick@75
   268
   blanks.inlines
patrick@73
   269
 | blanks.block+
patrick@73
   270
point.item.content =
patrick@75
   271
   point.inlines
patrick@73
   272
 | point.block+
patrick@73
   273
patrick@73
   274
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   275
patrick@73
   276
blanks.table = element table { blanks.table.content }
patrick@73
   277
point.table = element table { point.table.content }
patrick@73
   278
patrick@73
   279
blanks.table.content =
patrick@73
   280
   block.head?,
patrick@73
   281
   blanks.tgroup+,
patrick@111
   282
   table.caption?
patrick@73
   283
point.table.content =
patrick@73
   284
   block.head?,
patrick@73
   285
   point.tgroup+,
patrick@111
   286
   table.caption?
patrick@73
   287
patrick@73
   288
# ~~~~~~ tgroup
patrick@73
   289
blanks.tgroup = element tgroup { tgroup.attributes, blanks.tgroup.content }
patrick@73
   290
point.tgroup = element tgroup { tgroup.attributes, point.tgroup.content }
patrick@73
   291
patrick@73
   292
blanks.tgroup.content =
patrick@73
   293
   thead?,
patrick@73
   294
   blanks.tbody
patrick@73
   295
point.tgroup.content =
patrick@73
   296
   thead?,
patrick@73
   297
   point.tbody
patrick@73
   298
patrick@73
   299
# ~~~~~~ tbody
patrick@73
   300
blanks.tbody = element tbody { tbody.attributes, blanks.tbody.content }
patrick@73
   301
point.tbody = element tbody { tbody.attributes, point.tbody.content }
patrick@73
   302
patrick@73
   303
blanks.tbody.content =
patrick@73
   304
   blanks.row+
patrick@73
   305
point.tbody.content =
patrick@73
   306
   point.row+
patrick@73
   307
patrick@73
   308
# ~~~~~~ row
patrick@73
   309
blanks.row = element row { row.attribute, blanks.row.content }
patrick@73
   310
point.row = element row { row.attribute, point.row.content }
patrick@73
   311
patrick@73
   312
blanks.row.content =
patrick@73
   313
  blanks.entry+
patrick@73
   314
point.row.content =
patrick@73
   315
  point.entry+
patrick@73
   316
patrick@73
   317
# ~~~~~~ entry
patrick@73
   318
blanks.entry = element entry { blanks.entry.content }
patrick@73
   319
point.entry = element entry { point.entry.content }
patrick@73
   320
patrick@73
   321
blanks.entry.content =
patrick@75
   322
   blanks.inlines
patrick@73
   323
 | (p | media)+
patrick@73
   324
patrick@73
   325
point.entry.content =
patrick@75
   326
   point.inlines
patrick@73
   327
 | (p | media)+
patrick@73
   328
patrick@73
   329
patrick@73
   330
# ~~~~~~~~~~~~~~~~~~~~~~~~ choices.right, choices.wrong ~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   331
patrick@73
   332
choices.right = element right { choices.right.content }
patrick@73
   333
choices.wrong = element wrong { choices.right.content }
patrick@73
   334
patrick@73
   335
choices.right.content =
patrick@73
   336
   inlines
patrick@73
   337
 | p+
patrick@73
   338
patrick@73
   339
patrick@73
   340
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks.wrongs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   341
patrick@73
   342
# ~~~~~~ blanks.wrongs
patrick@73
   343
blanks.wrongs = element wrongs { blanks.wrongs.content }
patrick@73
   344
patrick@73
   345
blanks.wrongs.content =
patrick@73
   346
   blanks.wrong+
patrick@73
   347
patrick@73
   348
# ~~~~~~ blanks.wrong
patrick@73
   349
blanks.wrong = element wrong { blanks.wrong.content }
patrick@73
   350
patrick@73
   351
blanks.wrong.content = text
patrick@73
   352
patrick@73
   353
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ match ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   354
patrick@73
   355
match = element match { match.content }
patrick@73
   356
patrick@73
   357
match.content =
patrick@73
   358
   (p | section),
patrick@73
   359
   (p | section)
patrick@73
   360
patrick@75
   361
# ~~~~~~~~~~~~~~~~~~~~~~~~ (sort) comparison, item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   362
patrick@73
   363
# ~~~~~~ comparison
patrick@73
   364
comparison = element comparison { comparison.content }
patrick@73
   365
patrick@73
   366
comparison.content = inlines
patrick@73
   367
patrick@73
   368
# ~~~~~~ sort.item
patrick@73
   369
sort.item = element item { sort.item.attributes, sort.item.content }
patrick@73
   370
patrick@73
   371
sort.item.attributes =
patrick@73
   372
   item.shuffle.attribute?
patrick@73
   373
item.shuffle.attribute = attribute shuffle { xsd:integer }
patrick@73
   374
patrick@73
   375
sort.item.content = inlines
patrick@73
   376
patrick@125
   377
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ (category) item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@125
   378
patrick@125
   379
# ~~~~~~ category.item
patrick@125
   380
category.item = element item { category.item.content }
patrick@125
   381
patrick@125
   382
category.item.content = inlines
patrick@125
   383
patrick@73
   384
patrick@73
   385
# =============================================================================
patrick@73
   386
#                                 INLINE LEVEL
patrick@73
   387
# =============================================================================
patrick@73
   388
patrick@75
   389
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@75
   390
patrick@75
   391
blanks.inlines = mixed {
patrick@75
   392
   sup*
patrick@75
   393
 & sub*
patrick@75
   394
 & var*
patrick@75
   395
 & number*
patrick@75
   396
 & math*
patrick@75
   397
 & date*
patrick@75
   398
 & name*
patrick@75
   399
 & note*
patrick@75
   400
 & foreign*
patrick@75
   401
 & highlight*
patrick@75
   402
 & mentioned*
patrick@75
   403
 & quote*
patrick@75
   404
 & acronym*
patrick@75
   405
 & term*
patrick@75
   406
 & link*
patrick@75
   407
 & anchor*
patrick@75
   408
 & blank*
patrick@75
   409
}
patrick@75
   410
point.inlines = mixed {
patrick@75
   411
   sup*
patrick@75
   412
 & sub*
patrick@75
   413
 & var*
patrick@75
   414
 & number*
patrick@75
   415
 & math*
patrick@75
   416
 & date*
patrick@75
   417
 & name*
patrick@75
   418
 & note*
patrick@75
   419
 & foreign*
patrick@75
   420
 & highlight*
patrick@75
   421
 & mentioned*
patrick@75
   422
 & quote*
patrick@75
   423
 & acronym*
patrick@75
   424
 & term*
patrick@75
   425
 & link*
patrick@75
   426
 & anchor*
patrick@75
   427
 & blank*
patrick@75
   428
 & point.right*
patrick@75
   429
 & point.wrong*
patrick@75
   430
}
patrick@75
   431
patrick@73
   432
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blank ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   433
patrick@73
   434
# ~~~~~~ blank
patrick@73
   435
blank = element blank { blank.content }
patrick@73
   436
patrick@73
   437
blank.content =
patrick@73
   438
   text
patrick@87
   439
 | (s+, help?, answer?)
patrick@73
   440
patrick@73
   441
# ~~~~~~ s
patrick@73
   442
s = element s { s.content }
patrick@73
   443
patrick@73
   444
s.content = text
patrick@73
   445
patrick@73
   446
# ~~~~~~~~~~~~~~~~~~~~~~~~~ point.right, point.wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~
patrick@73
   447
patrick@73
   448
point.right = element right { point.right.content }
patrick@73
   449
point.wrong = element wrong { point.right.content }
patrick@73
   450
patrick@73
   451
point.right.content = inlines