RelaxNG/publiquiz.rnc
changeset 75 70418017787e
parent 73 0a3a8006996b
child 77 4690abab3daa
equal deleted inserted replaced
74:ebe0ab8699fc 75:70418017787e
     6 
     6 
     7    document.content =
     7    document.content =
     8       top.head?,
     8       top.head?,
     9       (division | topic | quiz)+
     9       (division | topic | quiz)+
    10 }
    10 }
       
    11 
    11 
    12 
    12 publiquiz = element publiquiz {
    13 publiquiz = element publiquiz {
    13    publiquiz.attributes,
    14    publiquiz.attributes,
    14    publiquiz.content
    15    publiquiz.content
    15 }
    16 }
    77 instructions = element instructions { section.content }
    78 instructions = element instructions { section.content }
    78 
    79 
    79 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ engine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    80 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ engine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    80 
    81 
    81 engine =
    82 engine =
    82    choices.radio
    83    choices
    83  | choices.check
    84  | blanks
    84  | blanks.fill
       
    85  | blanks.select
       
    86  | point
    85  | point
    87  | matching
    86  | matching
    88  | sort
    87  | sort
    89 
    88 
    90 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ choices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    89 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ choices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    91 
    90 
    92 choices.radio = element choices {
    91 choices = element choices {
    93    attribute type { "radio" }, choices.attributes, choices.radio.content }
    92    (attribute type {"radio"}, choices.attributes, choices.radio.content)
    94 choices.check = element choices {
    93  | (attribute type {"check"}, choices.attributes, choices.check.content)
    95    attribute type { "check" }, choices.attributes, choices.check.content }
    94 }
    96 
    95 
    97 choices.attributes =
    96 choices.attributes =
    98    shuffle.attribute?
    97    shuffle.attribute?
    99 shuffle.attribute = attribute shuffle { xsd:boolean }
    98 shuffle.attribute = attribute shuffle { xsd:boolean }
   100 
    99 
   104 choices.check.content =
   103 choices.check.content =
   105    (choices.right | choices.wrong)+
   104    (choices.right | choices.wrong)+
   106 
   105 
   107 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   106 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   108 
   107 
   109 blanks.fill = element blanks { blanks.fill.attributes, blanks.fill.content }
   108 blanks = element blanks {
   110 blanks.select = element blanks {
   109    (attribute type {"fill"}, blanks.fill.attributes, blanks.fill.content)
   111    blanks.select.attributes, blanks.select.content }
   110  | (attribute type {"select"}, blanks.select.attributes, blanks.select.content)
       
   111 }
   112 
   112 
   113 blanks.fill.attributes =
   113 blanks.fill.attributes =
   114    attribute type { "fill" }
   114    strict.attribute?
   115  & strict.attribute?
       
   116 blanks.select.attributes =
   115 blanks.select.attributes =
   117    attribute type { "select" },
       
   118    multiple.attribute?
   116    multiple.attribute?
   119 strict.attribute = attribute strict { xsd:boolean }
   117 strict.attribute = attribute strict { xsd:boolean }
   120 multiple.attribute = attribute multiple { xsd:boolean }
   118 multiple.attribute = attribute multiple { xsd:boolean }
   121 
   119 
   122 blanks.fill.content =
   120 blanks.fill.content =
   126    (blanks.block+ | blanks.section+)
   124    (blanks.block+ | blanks.section+)
   127 
   125 
   128 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ point ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   126 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ point ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   129 
   127 
   130 point = element point { point.attributes, point.content }
   128 point = element point { point.attributes, point.content }
   131    
   129 
   132 point.attributes =
   130 point.attributes =
   133    point.type.attribute?
   131    point.type.attribute?
   134 point.type.attribute = attribute type {
   132 point.type.attribute = attribute type {
   135    "radio" | "radio_button" | "check" | "check_button" }
   133    "radio" | "radio_button" | "check" | "check_button" }
   136 
   134 
   138    (point.section+ | point.block+)
   136    (point.section+ | point.block+)
   139 
   137 
   140 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ matching ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   138 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ matching ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   141 
   139 
   142 matching = element matching { matching.content }
   140 matching = element matching { matching.content }
   143    
   141 
   144 matching.content =
   142 matching.content =
   145    match,
   143    match,
   146    match+
   144    match+
   147 
   145 
   148 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sort ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   146 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sort ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   149 
   147 
   150 sort = element sort { sort.attributes, sort.content }
   148 sort = element sort { sort.attributes, sort.content }
   151 
   149 
   152 sort.attributes =
   150 sort.attributes =
   153    shuffle.attribute?
   151    shuffle.attribute?
   154    
   152 
   155 sort.content =
   153 sort.content =
   156    comparison?,
   154    comparison?,
   157    sort.item,
   155    sort.item,
   158    sort.item+
   156    sort.item+
   159 
   157 
   160 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composite ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   158 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composite ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   161 
   159 
   162 composite = element composite { composite.content }
   160 composite = element composite { composite.content }
   163    
   161 
   164 composite.content =
   162 composite.content =
   165    (instructions?, engine),
   163    (instructions?, engine),
   166    (instructions?, engine)+
   164    (instructions?, engine)+
   167 
   165 
   168 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   166 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   196 
   194 
   197 blanks.p = element p { blanks.p.content }
   195 blanks.p = element p { blanks.p.content }
   198 point.p = element p { point.p.content }
   196 point.p = element p { point.p.content }
   199 
   197 
   200 blanks.p.content =
   198 blanks.p.content =
   201    inlines
   199    blanks.inlines
   202  & blank*
       
   203 point.p.content =
   200 point.p.content =
   204    inlines
   201    point.inlines
   205  & point.right*
       
   206  & point.wrong*
       
   207 
   202 
   208 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   203 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   209 
   204 
   210 # ~~~~~~ list
   205 # ~~~~~~ list
   211 blanks.list = element list { blanks.list.content }
   206 blanks.list = element list {
   212 point.list = element list { point.list.content }
       
   213 
       
   214 blanks.list.content =
       
   215    block.head?,
   207    block.head?,
   216    (  (attribute type {"ordered"}?, blanks.item, blanks.item+)
   208    (  (attribute type {"ordered"}?, blanks.item, blanks.item+)
   217     | (attribute type {"glossary"}, glossary.item+) )
   209     | (attribute type {"glossary"}, glossary.item+) )
   218 point.list.content =
   210 }
       
   211 point.list = element list {
   219    block.head?,
   212    block.head?,
   220    (  (attribute type {"ordered"}?, point.item, point.item+)
   213    (  (attribute type {"ordered"}?, point.item, point.item+)
   221     | (attribute type {"glossary"}, glossary.item+) )
   214     | (attribute type {"glossary"}, glossary.item+) )
       
   215 }
   222 
   216 
   223 # ~~~~~~ item
   217 # ~~~~~~ item
   224 blanks.item = element item { blanks.item.content }
   218 blanks.item = element item { blanks.item.content }
   225 point.item = element item { point.item.content }
   219 point.item = element item { point.item.content }
   226 
   220 
   227 blanks.item.content =
   221 blanks.item.content =
   228    (inlines & blank*)
   222    blanks.inlines
   229  | blanks.block+
   223  | blanks.block+
   230 point.item.content =
   224 point.item.content =
   231    (inlines & point.right* & point.wrong*)
   225    point.inlines
   232  | point.block+
   226  | point.block+
   233 
   227 
   234 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   228 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   235 
   229 
   236 blanks.table = element table { blanks.table.content }
   230 blanks.table = element table { blanks.table.content }
   277 # ~~~~~~ entry
   271 # ~~~~~~ entry
   278 blanks.entry = element entry { blanks.entry.content }
   272 blanks.entry = element entry { blanks.entry.content }
   279 point.entry = element entry { point.entry.content }
   273 point.entry = element entry { point.entry.content }
   280 
   274 
   281 blanks.entry.content =
   275 blanks.entry.content =
   282    (inlines & blank*)
   276    blanks.inlines
   283  | (p | media)+
   277  | (p | media)+
   284 
   278 
   285 point.entry.content =
   279 point.entry.content =
   286    (inlines & point.right* & point.wrong*)
   280    point.inlines
   287  | (p | media)+
   281  | (p | media)+
   288 
   282 
   289 
   283 
   290 # ~~~~~~~~~~~~~~~~~~~~~~~~ choices.right, choices.wrong ~~~~~~~~~~~~~~~~~~~~~~~
   284 # ~~~~~~~~~~~~~~~~~~~~~~~~ choices.right, choices.wrong ~~~~~~~~~~~~~~~~~~~~~~~
   291 
   285 
   316 
   310 
   317 match.content =
   311 match.content =
   318    (p | section),
   312    (p | section),
   319    (p | section)
   313    (p | section)
   320 
   314 
   321 # ~~~~~~~~~~~~~~~~~~~~~~~~ (sort) comparaison, item ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   315 # ~~~~~~~~~~~~~~~~~~~~~~~~ (sort) comparison, item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   322 
   316 
   323 # ~~~~~~ comparison
   317 # ~~~~~~ comparison
   324 comparison = element comparison { comparison.content }
   318 comparison = element comparison { comparison.content }
   325 
   319 
   326 comparison.content = inlines
   320 comparison.content = inlines
   337 
   331 
   338 # =============================================================================
   332 # =============================================================================
   339 #                                 INLINE LEVEL
   333 #                                 INLINE LEVEL
   340 # =============================================================================
   334 # =============================================================================
   341 
   335 
       
   336 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       
   337 
       
   338 blanks.inlines = mixed {
       
   339    sup*
       
   340  & sub*
       
   341  & var*
       
   342  & number*
       
   343  & math*
       
   344  & date*
       
   345  & name*
       
   346  & note*
       
   347  & foreign*
       
   348  & highlight*
       
   349  & mentioned*
       
   350  & quote*
       
   351  & acronym*
       
   352  & term*
       
   353  & link*
       
   354  & anchor*
       
   355  & blank*
       
   356 }
       
   357 point.inlines = mixed {
       
   358    sup*
       
   359  & sub*
       
   360  & var*
       
   361  & number*
       
   362  & math*
       
   363  & date*
       
   364  & name*
       
   365  & note*
       
   366  & foreign*
       
   367  & highlight*
       
   368  & mentioned*
       
   369  & quote*
       
   370  & acronym*
       
   371  & term*
       
   372  & link*
       
   373  & anchor*
       
   374  & blank*
       
   375  & point.right*
       
   376  & point.wrong*
       
   377 }
       
   378 
   342 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blank ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   379 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blank ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   343 
   380 
   344 # ~~~~~~ blank
   381 # ~~~~~~ blank
   345 blank = element blank { blank.content }
   382 blank = element blank { blank.content }
   346 
   383