RelaxNG/publiquiz.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
mar., 24 janv. 2012 11:48:53 +0100
changeset 80 4392d9609436
parent 77 4690abab3daa
child 81 a9276e7bcdf1
permissions -rw-r--r--
Amélioration commentaire quiz
# $Id$


include "publidoc.rnc" {
   start = publiquiz

   document.content =
      top.head?,
      (division | topic | quiz)+
}


publiquiz = element publiquiz {
   publiquiz.attributes,
   publiquiz.content
}

publiquiz.attributes =
   version.attribute

publiquiz.content =
   document
 | top.quiz


# =============================================================================
#                                  TOP LEVEL
# =============================================================================

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quiz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

top.quiz = element quiz { top.quiz.attributes, quiz.content }

top.quiz.attributes =
   quiz.id.attribute
 & lang.attribute?


# =============================================================================
#                               COMPONENT LEVEL
# =============================================================================

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ quiz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

quiz = element quiz { quiz.attributes, quiz.content }

quiz.attributes =
   quiz.id.attribute?
 & lang.attribute?
quiz.id.attribute = attribute xml:id { xsd:ID }

quiz.content =
   component.head?,
   instructions,
   (engine | composite)?,
   help?,
   commentary?


# =============================================================================
#                                 SECTION LEVEL
# =============================================================================

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

blanks.section = element section { section.attributes, blanks.section.content }
point.section = element section { section.attributes, point.section.content }

blanks.section.content =
   section.head?,
   (blanks.section+ | blanks.block+)
point.section.content =
   section.head?,
   (point.section+ | point.block+)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ instructions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

instructions = element instructions { section.content }

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ engine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

engine =
   choices
 | blanks
 | point
 | matching
 | sort

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ choices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

choices = element choices {
   (attribute type {"radio"}, choices.attributes, choices.radio.content)
 | (attribute type {"check"}, choices.attributes, choices.check.content)
}

choices.attributes =
   shuffle.attribute?
shuffle.attribute = attribute shuffle { xsd:boolean }

choices.radio.content =
   choices.right
 & choices.wrong+
choices.check.content =
   (choices.right | choices.wrong)+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

blanks = element blanks {
   (attribute type {"fill"}, blanks.fill.attributes, blanks.fill.content)
 | (attribute type {"select"}, blanks.select.attributes, blanks.select.content)
}

blanks.fill.attributes =
   strict.attribute?
blanks.select.attributes =
   multiple.attribute?
strict.attribute = attribute strict { xsd:boolean }
multiple.attribute = attribute multiple { xsd:boolean }

blanks.fill.content =
   (blanks.block+ | blanks.section+)
blanks.select.content =
   blanks.wrongs?,
   (blanks.block+ | blanks.section+)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ point ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

point = element point { point.attributes, point.content }

point.attributes =
   point.type.attribute?
point.type.attribute = attribute type {
   "radio" | "radio_button" | "check" | "check_button" }

point.content =
   (point.section+ | point.block+)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ matching ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

matching = element matching { matching.content }

matching.content =
   match,
   match+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sort ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sort = element sort { sort.attributes, sort.content }

sort.attributes =
   shuffle.attribute?

sort.content =
   comparison?,
   sort.item,
   sort.item+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composite ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ composite
composite = element composite { composite.content }

composite.content =
   composite.quiz,
   composite.quiz+

# ~~~~~~ composite.quiz
composite.quiz = element quiz { composite.quiz.content }

composite.quiz.content =
   instructions?,
   engine

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

help = element help { help.content }

help.content =
   (section+ | block+)?,
   link*

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ commentary ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

commentary = element commentary { commentary.content }

commentary.content =
   (section* | block*),
   link*


# =============================================================================
#                                 BLOCK LEVEL
# =============================================================================

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ block ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

blanks.block =
   (blanks.p | speech | blanks.list | blockquote | blanks.table | media)
point.block =
   (point.p | speech | point.list | blockquote | point.table | media)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ p ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

blanks.p = element p { blanks.p.content }
point.p = element p { point.p.content }

blanks.p.content =
   blanks.inlines
point.p.content =
   point.inlines

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ list ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ list
blanks.list = element list {
   block.head?,
   (  (attribute type {"ordered"}?, blanks.item, blanks.item+)
    | (attribute type {"glossary"}, glossary.item+) )
}
point.list = element list {
   block.head?,
   (  (attribute type {"ordered"}?, point.item, point.item+)
    | (attribute type {"glossary"}, glossary.item+) )
}

# ~~~~~~ item
blanks.item = element item { blanks.item.content }
point.item = element item { point.item.content }

blanks.item.content =
   blanks.inlines
 | blanks.block+
point.item.content =
   point.inlines
 | point.block+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ table ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

blanks.table = element table { blanks.table.content }
point.table = element table { point.table.content }

blanks.table.content =
   block.head?,
   blanks.tgroup+,
   caption?
point.table.content =
   block.head?,
   point.tgroup+,
   caption?

# ~~~~~~ tgroup
blanks.tgroup = element tgroup { tgroup.attributes, blanks.tgroup.content }
point.tgroup = element tgroup { tgroup.attributes, point.tgroup.content }

blanks.tgroup.content =
   thead?,
   blanks.tbody
point.tgroup.content =
   thead?,
   point.tbody

# ~~~~~~ tbody
blanks.tbody = element tbody { tbody.attributes, blanks.tbody.content }
point.tbody = element tbody { tbody.attributes, point.tbody.content }

blanks.tbody.content =
   blanks.row+
point.tbody.content =
   point.row+

# ~~~~~~ row
blanks.row = element row { row.attribute, blanks.row.content }
point.row = element row { row.attribute, point.row.content }

blanks.row.content =
  blanks.entry+
point.row.content =
  point.entry+

# ~~~~~~ entry
blanks.entry = element entry { blanks.entry.content }
point.entry = element entry { point.entry.content }

blanks.entry.content =
   blanks.inlines
 | (p | media)+

point.entry.content =
   point.inlines
 | (p | media)+


# ~~~~~~~~~~~~~~~~~~~~~~~~ choices.right, choices.wrong ~~~~~~~~~~~~~~~~~~~~~~~

choices.right = element right { choices.right.content }
choices.wrong = element wrong { choices.right.content }

choices.right.content =
   inlines
 | p+


# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blanks.wrongs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ blanks.wrongs
blanks.wrongs = element wrongs { blanks.wrongs.content }

blanks.wrongs.content =
   blanks.wrong+

# ~~~~~~ blanks.wrong
blanks.wrong = element wrong { blanks.wrong.content }

blanks.wrong.content = text

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ match ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

match = element match { match.content }

match.content =
   (p | section),
   (p | section)

# ~~~~~~~~~~~~~~~~~~~~~~~~ (sort) comparison, item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ comparison
comparison = element comparison { comparison.content }

comparison.content = inlines

# ~~~~~~ sort.item
sort.item = element item { sort.item.attributes, sort.item.content }

sort.item.attributes =
   item.shuffle.attribute?
item.shuffle.attribute = attribute shuffle { xsd:integer }

sort.item.content = inlines


# =============================================================================
#                                 INLINE LEVEL
# =============================================================================

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

blanks.inlines = mixed {
   sup*
 & sub*
 & var*
 & number*
 & math*
 & date*
 & name*
 & note*
 & foreign*
 & highlight*
 & mentioned*
 & quote*
 & acronym*
 & term*
 & link*
 & anchor*
 & blank*
}
point.inlines = mixed {
   sup*
 & sub*
 & var*
 & number*
 & math*
 & date*
 & name*
 & note*
 & foreign*
 & highlight*
 & mentioned*
 & quote*
 & acronym*
 & term*
 & link*
 & anchor*
 & blank*
 & point.right*
 & point.wrong*
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blank ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ blank
blank = element blank { blank.content }

blank.content =
   text
 | (s+, help?, commentary?)

# ~~~~~~ s
s = element s { s.content }

s.content = text

# ~~~~~~~~~~~~~~~~~~~~~~~~~ point.right, point.wrong ~~~~~~~~~~~~~~~~~~~~~~~~~~

point.right = element right { point.right.content }
point.wrong = element wrong { point.right.content }

point.right.content = inlines