RelaxNG/publiquiz.rnc
author Patrick PIERRE
jeu., 15 mai 2014 07:20:59 +0200
changeset 313 e4f154ea2837
parent 310 13939fb7824a
child 336 15beef04b08c
permissions -rw-r--r--
Présence de blanks, right et wrong dans les légendes, les citations et les discours
# $Id$


include "publidoc.rnc" {
   start = publiquiz

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

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


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

publiquiz.attributes =
   version.attribute

publiquiz.content =
   document
 | top.quiz


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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ top.quiz ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

top.quiz.attributes =
   quiz.id.attribute
 & quiz.type.attribute?
 & lang.attribute?
quiz.id.attribute = attribute id { xsd:NMTOKEN }
quiz.type.attribute = attribute type { xsd:NCName }

top.quiz.content =
   top.head?,
   instructions,
   (engine | composite),
   help?,
   answer?


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

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

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

quiz.attributes =
   (quiz.id.attribute | xmlid.attribute)?
 & quiz.type.attribute?
 & lang.attribute?

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


# =============================================================================
#                                 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-radio
 | choices-check
 | blanks-fill
 | blanks-select
 | blanks-char
 | point
 | matching
 | sort
 | categories
 | pip
 | production

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

choices-radio = element choices-radio {
   choices.attributes, choices-radio.content }
choices-check = element choices-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-fill = element blanks-fill {
   blanks-fill.attributes, blanks-fill.content }
blanks-select = element blanks-select {
   blanks-select.attributes, blanks-select.content }
blanks-char = element blanks-char { 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
matching = element matching { matching.attributes, matching.content }

matching.attributes =
   multiple.attribute?

matching.content =
   match,
   match+

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

match.content =
   match.item,
   match.item

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

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

sort.attributes =
   shuffle.attribute?

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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ categories ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ category.head
category.head = element head { category.head.content }

category.head.content =
   title,
   shorttitle?,
   subtitle*

# ~~~~~~ categories
categories = element categories { categories.attributes, categories.content }

categories.attributes =
   multiple.attribute?

categories.content =
   category.item*,
   category,
   category+

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

category.content =
   category.head,
   category.item*

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pip ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

pip.attributes =
   multiple.attribute?

pip.content =
   pip.image

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ production ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

production = element production { empty }

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

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

composite.attributes =
   multipage.attribute?
multipage.attribute = attribute multipage { xsd:boolean }

composite.content =
   subquiz,
   subquiz+

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

subquiz.content =
   instructions?,
   engine,
   help?,
   answer?

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

help = element help { help.content }

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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

answer = element answer { answer.content }

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


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

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

blanks.block = (
   blanks.p | blanks.list | blanks.blockquote | blanks.speech | blanks.table
 | blanks.media)
point.block = (
   point.p | point.list | point.blockquote | point.speech | 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+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ blockquote ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

blanks.blockquote.content =
   block.head?,
   (blanks.p | speech | blanks.list)+,
   attribution?
point.blockquote.content =
   block.head?,
   (point.p | speech | point.list)+,
   attribution?

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ speech ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

blanks.speech.content =
   blanks.speaker?,
   stage?,
   (blanks.p | blanks.blockquote)+
point.speech.content =
   point.speaker?,
   stage?,
   (point.p | point.blockquote)+

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

blanks.speaker.content = blanks.inlines
point.speaker.content = point.inlines

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

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

blanks.table.content =
   block.head?,
   thead?,
   (blanks.tbody+ | blanks.tr+),
   blanks.table.caption?
point.table.content =
   block.head?,
   (point.tbody+ | point.tr+),
   point.table.caption?

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

blanks.tbody.content =
   blanks.tr+
point.tbody.content =
   point.tr+

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

blanks.tr.content =
  (blanks.td | blanks.th)+
point.tr.content =
  (point.td | point.th)+

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

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

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

# ~~~~~~ table.caption
blanks.table.caption = element caption { blanks.caption.content }
point.table.caption = element caption { point.caption.content }

blanks.caption.content =
   blanks.inlines
 | (blanks.p | speech | blanks.list | blockquote)+
point.caption.content =
   point.inlines
 | (point.p | speech | point.list | blockquote)+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ media ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

blanks.media.content =
   block.head?,
   (blanks.image | audio | video)+,
   blanks.media.caption?,
   link?
point.media.content =
   block.head?,
   (image | audio | video)+,
   point.media.caption?,
   link?

# ~~~~~~ blanks.image
blanks.image = element image { image.attributes, blanks.image.content }
pip.image = element image { image.attributes, pip.image.content }

blanks.image.content =
   copyright?,
   blanks.dropzone*
pip.image.content =
   pip.dropzone+

# ~~~~~~ dropzone
blanks.dropzone = element dropzone {
   blanks.dropzone.attributes, blanks.dropzone.content }
pip.dropzone = element dropzone {
   pip.dropzone.attributes, pip.dropzone.content }

blanks.dropzone.attributes =
   x.attribute
 & y.attribute
pip.dropzone.attributes =
   x.attribute
 & y.attribute
 & w.attribute
 & h.attribute

blanks.dropzone.content =
   blank
pip.dropzone.content =
   image?

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

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

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

choices.right.content =
   inlines
 | ((p | image | (audio, image?) | video), help?, answer?)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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.item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

match.item = element item { match.item.content }

match.item.content =
   inlines
 | ((p | image | (audio, image?) | video), help?, answer?)

# ~~~~~~~~~~~~~~~~~~~~~~~~ comparison, sort.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
 | ((p | image | (audio, image?) | video), help?, answer?)

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ category.item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

category.item = element item { category.item.content }

category.item.content =
   inlines
 | ((p | image | (audio, image?) | video), help?, answer?)


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

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

blanks.inlines = mixed {
   sup*
 & sub*
 & var*
 & number*
 & math*
 & date*
 & name*
 & acronym*
 & term*
 & warning*

 & literal*
 & foreign*
 & highlight*
 & emphasis*
 & mentioned*
 & stage*
 & initial*
 & quote*
 & image*
 & audio*
 & smil*
 & note*
 & link*
 & anchor*
 & index*

 & blank*
}

point.inlines = mixed {
   sup*
 & sub*
 & var*
 & number*
 & math*
 & date*
 & name*
 & acronym*
 & term*
 & warning*

 & literal*
 & foreign*
 & highlight*
 & emphasis*
 & mentioned*
 & stage*
 & initial*
 & quote*
 & image*
 & audio*
 & smil*
 & note*
 & link*
 & anchor*
 & index*

 & blank*
 & point.right*
 & point.wrong*
}

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

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

blank.attributes =
   function.attribute?
function.attribute = attribute function { 'lowercase' | 'uppercase' }

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

# ~~~~~~ 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