RelaxNG/publiquiz.rnc
author Patrick PIERRE
sam., 29 août 2015 10:07:30 +0200
changeset 396 7887f7b67db5
parent 388 954f6aef52d6
child 401 39a1454aa364
child 402 de00a458739d
permissions -rw-r--r--
Nouveaux <?tune-...?>
# $Id$


include "publidoc.rnc" {
   start = publiquiz

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

   division.content =
      division.head?,
      front?,
      (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 }
pointing.section = element section {
   section.attributes, pointing.section.content }

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

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

instructions = element instructions { section.content }

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

engine =
   choices-radio
 | choices-check
 | blanks-fill
 | blanks-select
 | blanks-char
 | pointing
 | pointing-categories
 | matching
 | sort
 | categories
 | pip
 | production

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

choices-radio = element choices-radio {
   choices-radio.attributes, choices-radio.content }
choices-check = element choices-check {
   choices-check.attributes, choices-check.content }

choices-radio.attributes =
   shuffle.attribute?
choices-check.attributes =
   success.attribute?
 & shuffle.attribute?
success.attribute = attribute success { xsd:decimal {maxInclusive="1"} }
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 =
   success.attribute?
 & strict.attribute?
 & long.attribute?
blanks-select.attributes =
   success.attribute?
 & multiple.attribute?
 & noshuffle.attribute?
strict.attribute = attribute strict { xsd:boolean }
multiple.attribute = attribute multiple { xsd:boolean }
noshuffle.attribute = attribute no-shuffle { xsd:boolean }
long.attribute = attribute long { xsd:positiveInteger }

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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pointing ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

pointing.attributes =
   success.attribute?
 & pointing.type.attribute?
pointing.type.attribute = attribute type { "radio" | "check" }

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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ pointing-categories ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ pointing-categories
pointing-categories = element pointing-categories {
   pointing-c.attributes, pointing-c.content }

pointing-c.attributes =
   success.attribute?

pointing-c.content =
   pointing-c.categories,
   pointing.section

# ~~~~~~ pointing-c.categories
pointing-c.categories = element categories { pointing-c.categories.content }

pointing-c.categories.content =
   pointing-c.category1,
   pointing-c.category2,
   (pointing-c.category3,
      (pointing-c.category4, pointing-c.category5?)?)?

# ~~~~~~ pointing-c.categoryN
pointing-c.category1 = element category {
   attribute id { "1" }, pointing-c.category.content }
pointing-c.category2 = element category {
   attribute id { "2" }, pointing-c.category.content }
pointing-c.category3 = element category {
   attribute id { "3" }, pointing-c.category.content }
pointing-c.category4 = element category {
   attribute id { "4" }, pointing-c.category.content }
pointing-c.category5 = element category {
   attribute id { "5" }, pointing-c.category.content }

pointing-c.category.content = inlines

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

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

matching.attributes =
   success.attribute?
 & multiple.attribute?

matching.content =
   matching.intruders?,
   match,
   match+

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

match.content =
   match.item,
   match.item

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

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

sort.attributes =
   success.attribute?
 & 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 =
   success.attribute?
 & multiple.attribute?
 & noshuffle.attribute?

categories.content =
   categories.intruders?,
   category,
   category+

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

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

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

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

pip.attributes =
   success.attribute?
 & multiple.attribute?

pip.content =
   pip.image

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

production = element production { empty }

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

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

composite.attributes =
   success.attribute?
 & 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)
pointing.block = (
   pointing.p | pointing.list | pointing.blockquote | pointing.speech
 | pointing.table | media)

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

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

blanks.p.content =
   blanks.inlines
pointing.p.content =
   pointing.inlines

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

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

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

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

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

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

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

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

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

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

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

blanks.speaker.content = blanks.inlines
pointing.speaker.content = pointing.inlines

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

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

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

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

blanks.tbody.content =
   blanks.tr+
pointing.tbody.content =
   pointing.tr+

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

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

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

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

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

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

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

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

blanks.media.content =
   block.head?,
   (blanks.image | audio | video)+,
   blanks.media.caption?,
   link?
pointing.media.content =
   block.head?,
   (image | audio | video)+,
   pointing.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 }
pointing.media.caption = element caption {
   caption.attributes, pointing.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.intruders ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

blanks.intruders = element intruders { blanks.intruders.content }

blanks.intruders.content =
   blank+

# ~~~~~~~~~~~~~~~~~~~~~~~ matching.intruders, match.item ~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~~ matching.intruders
matching.intruders = element intruders { matching.intruders.content }

matching.intruders.content =
   match.item+

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

match.item.content =
   inlines
 | (p, 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, help?, answer?)

# ~~~~~~~~~~~~~~~~~~~~~ categories.intruders, category.item ~~~~~~~~~~~~~~~~~~~

# ~~~~~~ categories.intruders
categories.intruders = element intruders { categories.intruders.content }

categories.intruders.content =
   category.item+

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

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


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

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

blanks.inlines = mixed {
   sup*
 & sub*
 & var*
 & number*
 & acronym*
 & warning*

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

 & blank*
}

pointing.inlines = mixed {
   sup*
 & sub*
 & var*
 & number*
 & acronym*
 & warning*

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

 & point*
}

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

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

blank.attributes =
   area.attribute?
 & long.attribute?
 & function.attribute?
area.attribute = attribute area { xsd:boolean }
function.attribute = attribute function { 'lowercase' | 'uppercase' }

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

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

s.content = text

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

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

point.attributes =
   point.ref.attribute?
point.ref.attribute = attribute ref {
   "right" | "cat1" | "cat2" | "cat3" | "cat4" | "cat5" }

point.content = inlines