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