RelaxNG/publiquiz.rnc
changeset 73 0a3a8006996b
child 75 70418017787e
equal deleted inserted replaced
72:c85252fac80c 73:0a3a8006996b
       
     1 # $Id$
       
     2 
       
     3 
       
     4 include "publidoc.rnc" {
       
     5    start = publiquiz
       
     6 
       
     7    document.content =
       
     8       top.head?,
       
     9       (division | topic | quiz)+
       
    10 }
       
    11 
       
    12 publiquiz = element publiquiz {
       
    13    publiquiz.attributes,
       
    14    publiquiz.content
       
    15 }
       
    16 
       
    17 publiquiz.attributes =
       
    18    version.attribute
       
    19 
       
    20 publiquiz.content =
       
    21    document
       
    22  | top.quiz
       
    23 
       
    24 
       
    25 # =============================================================================
       
    26 #                                  TOP LEVEL
       
    27 # =============================================================================
       
    28 
       
    29 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quiz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    30 
       
    31 top.quiz = element quiz { top.quiz.attributes, quiz.content }
       
    32 
       
    33 top.quiz.attributes =
       
    34    quiz.id.attribute
       
    35  & lang.attribute?
       
    36 
       
    37 
       
    38 # =============================================================================
       
    39 #                               COMPONENT LEVEL
       
    40 # =============================================================================
       
    41 
       
    42 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quiz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    43 
       
    44 quiz = element quiz { quiz.attributes, quiz.content }
       
    45 
       
    46 quiz.attributes =
       
    47    quiz.id.attribute?
       
    48  & lang.attribute?
       
    49 quiz.id.attribute = attribute xml:id { xsd:ID }
       
    50 
       
    51 quiz.content =
       
    52    component.head?,
       
    53    instructions,
       
    54    (engine | composite)?,
       
    55    help?,
       
    56    commentary?
       
    57 
       
    58 
       
    59 # =============================================================================
       
    60 #                                 SECTION LEVEL
       
    61 # =============================================================================
       
    62 
       
    63 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    64 
       
    65 blanks.section = element section { section.attributes, blanks.section.content }
       
    66 point.section = element section { section.attributes, point.section.content }
       
    67 
       
    68 blanks.section.content =
       
    69    section.head?,
       
    70    (blanks.section+ | blanks.block+)
       
    71 point.section.content =
       
    72    section.head?,
       
    73    (point.section+ | point.block+)
       
    74 
       
    75 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ instructions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    76 
       
    77 instructions = element instructions { section.content }
       
    78 
       
    79 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ engine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    80 
       
    81 engine =
       
    82    choices.radio
       
    83  | choices.check
       
    84  | blanks.fill
       
    85  | blanks.select
       
    86  | point
       
    87  | matching
       
    88  | sort
       
    89 
       
    90 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ choices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
    91 
       
    92 choices.radio = element choices {
       
    93    attribute type { "radio" }, choices.attributes, choices.radio.content }
       
    94 choices.check = element choices {
       
    95    attribute type { "check" }, choices.attributes, choices.check.content }
       
    96 
       
    97 choices.attributes =
       
    98    shuffle.attribute?
       
    99 shuffle.attribute = attribute shuffle { xsd:boolean }
       
   100 
       
   101 choices.radio.content =
       
   102    choices.right
       
   103  & choices.wrong+
       
   104 choices.check.content =
       
   105    (choices.right | choices.wrong)+
       
   106 
       
   107 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   108 
       
   109 blanks.fill = element blanks { blanks.fill.attributes, blanks.fill.content }
       
   110 blanks.select = element blanks {
       
   111    blanks.select.attributes, blanks.select.content }
       
   112 
       
   113 blanks.fill.attributes =
       
   114    attribute type { "fill" }
       
   115  & strict.attribute?
       
   116 blanks.select.attributes =
       
   117    attribute type { "select" },
       
   118    multiple.attribute?
       
   119 strict.attribute = attribute strict { xsd:boolean }
       
   120 multiple.attribute = attribute multiple { xsd:boolean }
       
   121 
       
   122 blanks.fill.content =
       
   123    (blanks.block+ | blanks.section+)
       
   124 blanks.select.content =
       
   125    blanks.wrongs?,
       
   126    (blanks.block+ | blanks.section+)
       
   127 
       
   128 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ point ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   129 
       
   130 point = element point { point.attributes, point.content }
       
   131    
       
   132 point.attributes =
       
   133    point.type.attribute?
       
   134 point.type.attribute = attribute type {
       
   135    "radio" | "radio_button" | "check" | "check_button" }
       
   136 
       
   137 point.content =
       
   138    (point.section+ | point.block+)
       
   139 
       
   140 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ matching ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   141 
       
   142 matching = element matching { matching.content }
       
   143    
       
   144 matching.content =
       
   145    match,
       
   146    match+
       
   147 
       
   148 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sort ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   149 
       
   150 sort = element sort { sort.attributes, sort.content }
       
   151 
       
   152 sort.attributes =
       
   153    shuffle.attribute?
       
   154    
       
   155 sort.content =
       
   156    comparison?,
       
   157    sort.item,
       
   158    sort.item+
       
   159 
       
   160 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composite ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   161 
       
   162 composite = element composite { composite.content }
       
   163    
       
   164 composite.content =
       
   165    (instructions?, engine),
       
   166    (instructions?, engine)+
       
   167 
       
   168 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   169 
       
   170 help = element help { help.content }
       
   171 
       
   172 help.content =
       
   173    (section+ | block+)?,
       
   174    link*
       
   175 
       
   176 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ commentary ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   177 
       
   178 commentary = element commentary { commentary.content }
       
   179 
       
   180 commentary.content =
       
   181    (section+ | block+)
       
   182 
       
   183 
       
   184 # =============================================================================
       
   185 #                                 BLOCK LEVEL
       
   186 # =============================================================================
       
   187 
       
   188 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   189 
       
   190 blanks.block =
       
   191    (blanks.p | speech | blanks.list | blockquote | blanks.table | media)
       
   192 point.block =
       
   193    (point.p | speech | point.list | blockquote | point.table | media)
       
   194 
       
   195 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   196 
       
   197 blanks.p = element p { blanks.p.content }
       
   198 point.p = element p { point.p.content }
       
   199 
       
   200 blanks.p.content =
       
   201    inlines
       
   202  & blank*
       
   203 point.p.content =
       
   204    inlines
       
   205  & point.right*
       
   206  & point.wrong*
       
   207 
       
   208 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   209 
       
   210 # ~~~~~~ list
       
   211 blanks.list = element list { blanks.list.content }
       
   212 point.list = element list { point.list.content }
       
   213 
       
   214 blanks.list.content =
       
   215    block.head?,
       
   216    (  (attribute type {"ordered"}?, blanks.item, blanks.item+)
       
   217     | (attribute type {"glossary"}, glossary.item+) )
       
   218 point.list.content =
       
   219    block.head?,
       
   220    (  (attribute type {"ordered"}?, point.item, point.item+)
       
   221     | (attribute type {"glossary"}, glossary.item+) )
       
   222 
       
   223 # ~~~~~~ item
       
   224 blanks.item = element item { blanks.item.content }
       
   225 point.item = element item { point.item.content }
       
   226 
       
   227 blanks.item.content =
       
   228    (inlines & blank*)
       
   229  | blanks.block+
       
   230 point.item.content =
       
   231    (inlines & point.right* & point.wrong*)
       
   232  | point.block+
       
   233 
       
   234 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   235 
       
   236 blanks.table = element table { blanks.table.content }
       
   237 point.table = element table { point.table.content }
       
   238 
       
   239 blanks.table.content =
       
   240    block.head?,
       
   241    blanks.tgroup+,
       
   242    caption?
       
   243 point.table.content =
       
   244    block.head?,
       
   245    point.tgroup+,
       
   246    caption?
       
   247 
       
   248 # ~~~~~~ tgroup
       
   249 blanks.tgroup = element tgroup { tgroup.attributes, blanks.tgroup.content }
       
   250 point.tgroup = element tgroup { tgroup.attributes, point.tgroup.content }
       
   251 
       
   252 blanks.tgroup.content =
       
   253    thead?,
       
   254    blanks.tbody
       
   255 point.tgroup.content =
       
   256    thead?,
       
   257    point.tbody
       
   258 
       
   259 # ~~~~~~ tbody
       
   260 blanks.tbody = element tbody { tbody.attributes, blanks.tbody.content }
       
   261 point.tbody = element tbody { tbody.attributes, point.tbody.content }
       
   262 
       
   263 blanks.tbody.content =
       
   264    blanks.row+
       
   265 point.tbody.content =
       
   266    point.row+
       
   267 
       
   268 # ~~~~~~ row
       
   269 blanks.row = element row { row.attribute, blanks.row.content }
       
   270 point.row = element row { row.attribute, point.row.content }
       
   271 
       
   272 blanks.row.content =
       
   273   blanks.entry+
       
   274 point.row.content =
       
   275   point.entry+
       
   276 
       
   277 # ~~~~~~ entry
       
   278 blanks.entry = element entry { blanks.entry.content }
       
   279 point.entry = element entry { point.entry.content }
       
   280 
       
   281 blanks.entry.content =
       
   282    (inlines & blank*)
       
   283  | (p | media)+
       
   284 
       
   285 point.entry.content =
       
   286    (inlines & point.right* & point.wrong*)
       
   287  | (p | media)+
       
   288 
       
   289 
       
   290 # ~~~~~~~~~~~~~~~~~~~~~~~~ choices.right, choices.wrong ~~~~~~~~~~~~~~~~~~~~~~~
       
   291 
       
   292 choices.right = element right { choices.right.content }
       
   293 choices.wrong = element wrong { choices.right.content }
       
   294 
       
   295 choices.right.content =
       
   296    inlines
       
   297  | p+
       
   298 
       
   299 
       
   300 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks.wrongs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   301 
       
   302 # ~~~~~~ blanks.wrongs
       
   303 blanks.wrongs = element wrongs { blanks.wrongs.content }
       
   304 
       
   305 blanks.wrongs.content =
       
   306    blanks.wrong+
       
   307 
       
   308 # ~~~~~~ blanks.wrong
       
   309 blanks.wrong = element wrong { blanks.wrong.content }
       
   310 
       
   311 blanks.wrong.content = text
       
   312 
       
   313 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ match ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   314 
       
   315 match = element match { match.content }
       
   316 
       
   317 match.content =
       
   318    (p | section),
       
   319    (p | section)
       
   320 
       
   321 # ~~~~~~~~~~~~~~~~~~~~~~~~ (sort) comparaison, item ~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   322 
       
   323 # ~~~~~~ comparison
       
   324 comparison = element comparison { comparison.content }
       
   325 
       
   326 comparison.content = inlines
       
   327 
       
   328 # ~~~~~~ sort.item
       
   329 sort.item = element item { sort.item.attributes, sort.item.content }
       
   330 
       
   331 sort.item.attributes =
       
   332    item.shuffle.attribute?
       
   333 item.shuffle.attribute = attribute shuffle { xsd:integer }
       
   334 
       
   335 sort.item.content = inlines
       
   336 
       
   337 
       
   338 # =============================================================================
       
   339 #                                 INLINE LEVEL
       
   340 # =============================================================================
       
   341 
       
   342 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blank ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   343 
       
   344 # ~~~~~~ blank
       
   345 blank = element blank { blank.content }
       
   346 
       
   347 blank.content =
       
   348    text
       
   349  | (s+, help?, commentary?)
       
   350 
       
   351 # ~~~~~~ s
       
   352 s = element s { s.content }
       
   353 
       
   354 s.content = text
       
   355 
       
   356 # ~~~~~~~~~~~~~~~~~~~~~~~~~ point.right, point.wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   357 
       
   358 point.right = element right { point.right.content }
       
   359 point.wrong = element wrong { point.right.content }
       
   360 
       
   361 point.right.content = inlines