RelaxNG/publiquiz.rnc
author iinov
dim., 20 janv. 2019 16:50:11 +0100
changeset 476 6c30a3543cd8
parent 472 021552e09b34
child 478 90e0fdca7fb7
permissions -rw-r--r--
Restructuration
include "publidoc.rnc"
    {
     start = publiquiz

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

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

     nowrap.content =
         inlines | blanks.inlines | blanks-m.inlines | blanks-c.inlines
         | pointing.inlines
    }


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

publiquiz.attributes =
    version.attribute

publiquiz.content =
    document
    | quiz


# =============================================================================
#                                    QUIZ
# =============================================================================

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

quiz.attributes =
    quiz.id.attribute?
    & quiz.type.attribute?
    & lang.attribute?
document.quiz.attributes =
    (quiz.id.attribute | xmlid.attribute)?
    & quiz.type.attribute?
    & lang.attribute?
quiz.id.attribute = attribute id { xsd:NMTOKEN }
quiz.type.attribute = attribute type { xsd:NCName }

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


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

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

blanks.section = element section { section.attributes, blanks.section.content }
blanks-m.section =
    element section { section.attributes, blanks-m.section.content }
blanks-c.section =
    element section { section.attributes, blanks-c.section.content }
correct.section =
    element section { section.attributes, correct.section.content }
pointing.section =
    element section { section.attributes, pointing.section.content }

blanks.section.content =
    section.head?,
    (blanks.section+ | blanks.block+)
blanks-m.section.content =
    section.head?,
    (blanks-m.section+ | blanks-m.block+)
blanks-c.section.content =
    section.head?,
    (blanks-c.section+ | blanks-c.block+)
correct.section.content =
    section.head?,
    (correct.section+ | correct.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-media
    | blanks-choices
    | correct-line
    | pointing
    | pointing-categories
    | matching
    | sort
    | categories
    | wordsearch
    | flashcard
    | coloring
    | memory
    | dictation
    | 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-media =
    element blanks-media { blanks-select.attributes, blanks-media.content }
blanks-choices =
    element blanks-choices { blanks-choices.content }

blanks-fill.attributes =
    success.attribute?
    & strict.attribute?
    & long.attribute?
blanks-select.attributes =
    success.attribute?
    & multiple.attribute?
    & noshuffle.attribute?
    & orientation.attribute?
strict.attribute = attribute strict { xsd:boolean }
multiple.attribute = attribute multiple { xsd:boolean }
noshuffle.attribute = attribute no-shuffle { "true" | "false" | "alpha" }
long.attribute = attribute long { xsd:positiveInteger }
orientation.attribute = attribute orientation {"north"|"east"|"west"|"south"}

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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ correct-line ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

correct-line = element correct-line { correct.attributes, correct.content }

correct.attributes =
    remove-space.attribute?
remove-space.attribute = attribute remove-space { xsd:boolean }

correct.content =
    correct.intruders?,
    (correct.block+ | correct.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?
    & noshuffle.attribute?
    & orientation.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?
    & orientation.attribute?

sort.content =
    sort.intruders?,
    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?
    & orientation.attribute?

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

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

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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ wordsearch ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

wordsearch.attributes =
    strict.attribute ?
    & wordlist.attribute ?

wordlist.attribute = attribute wordlist { "hidden" | "right" | "left" }

wordsearch.content =
    words
    & grid

# ~~~~~~ words
words = element words {words.content}
words.content = words.item+

# ~~~~~~ grid
grid = element grid {grid.content}
grid.content = line+

line = element line {line.content}
line.content = cell+

cell = element cell {cell.content}
cell.content = xsd:token {pattern = "."}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ flashcard ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

flashcard.content =
    side1,
    side2

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

side1.content =
    section+ | block+

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

side2.content =
    instructions?,
    flashcard.engine,
    help?,
    answer?

# ~~~~~~ flashcard.engine
flashcard.engine =
    choices-radio
    | choices-check
    | blanks-fill
    | blanks-select
    | sort

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ coloring ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

coloring.attributes =
    nomark.attribute?
nomark.attribute = attribute nomark { xsd:boolean }

coloring.content =
    palette
    & canvas
    & areas?

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

palette.content =
    color+

# ~~~~~~ canvas
canvas = element canvas { canvas.attributes }

canvas.attributes =
    media.id.attribute

# ~~~~~~ areas
areas = element areas { areas.attributes }

areas.attributes =
    media.id.attribute

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ memory ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

memory.attributes =
    display.attribute?
    & delay.attribute?
display.attribute = attribute display { xsd:positiveInteger }
delay.attribute = attribute delay { xsd:positiveInteger }

memory.content =
    memory.match,
    memory.match+

# ~~~~~~ memory.match
memory.match = element match { memory-m.content }

memory-m.content =
    memory-m.item,
    memory-m.item,
    audio?

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dictation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

dictation.attributes =
    case_insensitive.attribute?
case_insensitive.attribute = attribute case-insensitive { xsd:boolean }

dictation.content =
    dictation.media,
    dictation.p

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

production = element production { production.content }

production.content = text

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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)
blanks-m.block =
    (blanks-m.p | blanks-m.list | blanks-m.blockquote | blanks-m.speech
     | blanks-m.table | blanks-m.media)
blanks-c.block =
    (blanks-c.p | blanks-c.list | blanks-c.blockquote | blanks-c.speech
     | blanks-c.table | blanks-c.media)
correct.block =
    (correct.p | correct.list | correct.blockquote | correct.speech
     | correct.table | media)
pointing.block =
    (pointing.p | pointing.list | pointing.blockquote | pointing.speech
     | pointing.table | media)

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

blanks.p = element p { blanks.p.content }
blanks-m.p = element p { blanks-m.p.content }
blanks-c.p = element p { blanks-c.p.content }
correct.p = element p { correct.p.content }
pointing.p = element p { pointing.p.content }
dictation.p = element p { dictation.p.content }

blanks.p.content =
    blanks.inlines
blanks-m.p.content =
    blanks-m.inlines
blanks-c.p.content =
    blanks-c.inlines
correct.p.content =
    correct.inlines
pointing.p.content =
    pointing.inlines
dictation.p.content =
    dictation.inlines

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

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

# ~~~~~~ item
blanks.item = element item { blanks.item.content }
blanks-m.item = element item { blanks-m.item.content }
blanks-c.item = element item { blanks-c.item.content }
correct.item = element item { correct.item.content }
pointing.item = element item { pointing.item.content }


blanks.item.content = blanks.inlines | blanks.block+
blanks-m.item.content = blanks-m.inlines | blanks-m.block+
blanks-c.item.content = blanks-c.inlines | blanks-c.block+
correct.item.content = correct.inlines | correct.block+
pointing.item.content = pointing.inlines | pointing.block+

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

blanks.blockquote =
    element blockquote { blockquote.attributes, blanks.blockquote.content }
blanks-m.blockquote =
    element blockquote { blockquote.attributes, blanks-m.blockquote.content }
blanks-c.blockquote =
    element blockquote { blockquote.attributes, blanks-c.blockquote.content }
correct.blockquote =
    element blockquote { blockquote.attributes, correct.blockquote.content }
pointing.blockquote =
    element blockquote { blockquote.attributes, pointing.blockquote.content }

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

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

# ~~~~~~ speech
blanks.speech = element speech { blanks.speech.content }
blanks-m.speech = element speech { blanks-m.speech.content }
blanks-c.speech = element speech { blanks-c.speech.content }
correct.speech = element speech { correct.speech.content }
pointing.speech = element speech { pointing.speech.content }

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

# ~~~~~~ speaker
blanks.speaker = element speaker { blanks.speaker.content }
blanks-m.speaker = element speaker { blanks-m.speaker.content }
blanks-c.speaker = element speaker { blanks-c.speaker.content }
correct.speaker = element speaker { correct.speaker.content }
pointing.speaker = element speaker { pointing.speaker.content }

blanks.speaker.content = blanks.inlines
blanks-m.speaker.content = blanks-m.inlines
blanks-c.speaker.content = blanks-c.inlines
correct.speaker.content = correct.inlines
pointing.speaker.content = pointing.inlines

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

# ~~~~~~ table
blanks.table = element table { table.attributes, blanks.table.content }
blanks-m.table = element table { table.attributes, blanks-m.table.content }
blanks-c.table = element table { table.attributes, blanks-m.table.content }
correct.table = element table { table.attributes, correct.table.content }
pointing.table = element table { table.attributes, pointing.table.content }

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

# ~~~~~~ tbody
blanks.tbody = element tbody { blanks.tbody.content }
blanks-m.tbody = element tbody { blanks-m.tbody.content }
blanks-c.tbody = element tbody { blanks-m.tbody.content }
correct.tbody = element tbody { correct.tbody.content }
pointing.tbody = element tbody { pointing.tbody.content }

blanks.tbody.content =
    blanks.tr+
blanks-m.tbody.content =
    blanks-m.tr+
blanks-c.tbody.content =
    blanks-c.tr+
correct.tbody.content =
    correct.tr+
pointing.tbody.content =
    pointing.tr+

# ~~~~~~ tr
blanks.tr = element tr { tr.attributes, blanks.tr.content }
blanks-m.tr = element tr { tr.attributes, blanks-m.tr.content }
blanks-c.tr = element tr { tr.attributes, blanks-c.tr.content }
correct.tr = element tr { tr.attributes, correct.tr.content }
pointing.tr = element tr { tr.attributes, pointing.tr.content }

blanks.tr.content =
    (blanks.td | blanks.th)+
blanks-m.tr.content =
    (blanks-m.td | blanks-m.th)+
blanks-c.tr.content =
    (blanks-c.td | blanks-c.th)+
correct.tr.content =
    (correct.td | correct.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 }
blanks-m.td = element td { td.attributes, blanks-m.td.content }
blanks-m.th = element th { td.attributes, blanks-m.td.content }
blanks-c.td = element td { td.attributes, blanks-c.td.content }
blanks-c.th = element th { td.attributes, blanks-c.td.content }
correct.td = element td { td.attributes, correct.td.content }
correct.th = element th { td.attributes, correct.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)+
blanks-m.td.content =
    blanks-m.inlines
    | (blanks-m.p | blanks-m.media)+
blanks-c.td.content =
    blanks-c.inlines
    | (blanks-c.p | blanks-c.media)+
correct.td.content =
    correct.inlines
    | (correct.p | media)+
pointing.td.content =
    pointing.inlines
    | (pointing.p | media)+

# ~~~~~~ table.caption
blanks.table.caption = element caption { blanks.caption.content }
blanks-m.table.caption = element caption { blanks-m.caption.content }
blanks-c.table.caption = element caption { blanks-c.caption.content }
correct.table.caption = element caption { correct.caption.content }
pointing.table.caption = element caption { pointing.caption.content }

blanks.caption.content =
    blanks.inlines
    | (blanks.p | speech | blanks.list | blockquote)+
blanks-m.caption.content =
    blanks-m.inlines
    | (blanks-m.p | speech | blanks-m.list | blockquote)+
blanks-c.caption.content =
    blanks-c.inlines
    | (blanks-c.p | speech | blanks-c.list | blockquote)+
correct.caption.content =
    correct.inlines
    | (correct.p | speech | correct.list | blockquote)+
pointing.caption.content =
    pointing.inlines
    | (pointing.p | speech | pointing.list | blockquote)+

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

# ~~~~~~ media
blanks.media = element media { media.attributes, blanks.media.content }
blanks-m.media = element media { media.attributes, blanks-m.media.content }
blanks-c.media = element media { media.attributes, blanks-c.media.content }
correct.media = element media { media.attributes, correct.media.content }
pointing.media = element media { media.attributes, pointing.media.content }
dictation.media = element media { media.attributes, dictation.media.content }

blanks.media.content =
    block.head?,
    (blanks.image | audio | video)+,
    blanks.media.caption?,
    link?
blanks-m.media.content =
    block.head?,
    (blanks-m.image | audio | video)+,
    blanks-m.media.caption?,
    link?
blanks-c.media.content =
    block.head?,
    (image | audio | video)+,
    blanks-c.media.caption?,
    link?
correct.media.content =
    block.head?,
    (image | audio | video)+,
    correct.media.caption?,
    link?
pointing.media.content =
    block.head?,
    (image | audio | video)+,
    pointing.media.caption?,
    link?
dictation.media.content =
    audio

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

blanks.image.content =
    copyright?,
    blanks.dropzone*
blanks-m.image.content =
    copyright?,
    blanks-m.dropzone*

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

blanks.dropzone.attributes =
    x.attribute
    & y.attribute
blanks-m.dropzone.attributes =
    x.attribute
    & y.attribute
    & h.attribute
    & w.attribute

blanks.dropzone.content =
    blank
blanks-m.dropzone.content =
    blank-m

# ~~~~~~ media.caption
blanks.media.caption =
    element caption { caption.attributes, blanks.caption.content }
blanks-m.media.caption =
    element caption { caption.attributes, blanks-m.caption.content }
blanks-c.media.caption =
    element caption { caption.attributes, blanks-c.caption.content }
correct.media.caption =
    element caption { caption.attributes, correct.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-m.intruders  ~~~~~~~~~~~~~~~~~~

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

blanks.intruders.content = blank+
blanks-m.intruders.content = blank-m+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ correct.intruders ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

correct.intruders = element intruders { correct.intruders.content }

correct.intruders.content = char+

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

# ~~~~~~~~~~~~~~~~~~~~ sort.intruders, comparison, sort.item ~~~~~~~~~~~~~~~~~~

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

sort.intruders.content =
    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?)

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

words.item.content = inlines

words.item.attributes =
    startx
    & starty
    & endx
    & endy

startx = attribute startx {xsd:token {pattern = "[a-zA-Z]+"}}
starty = attribute starty {xsd:token {pattern = "\d+"}}
endx = attribute endx {xsd:token {pattern = "[a-zA-Z]+"}}
endy = attribute endy {xsd:token {pattern = "\d+"}}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ color ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

color = element color { color.attributes }

color.attributes =
    color.code
    & color.coderef?
color.code = attribute code {xsd:token { pattern = "#(\d|\w){6}"}}
color.coderef = attribute coderef { list{xsd:token { pattern = "#(\d|\w){6}"}+}}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ memory-m.item ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

memory-m.item = element item { memory-m.item.content }

memory-m.item.content = image


# =============================================================================
#                                 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*
        & nowrap*

        & blank*
    }

blanks-m.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*
        & nowrap*

        & blank-m*
    }

blanks-c.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*
        & nowrap*

        & blank-c*
    }

correct.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*
        & nowrap*

        & char*
    }

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*
        & nowrap*

        & point*
    }

dictation.inlines = mixed { warning* & dictation.hint* }

# ~~~~~~~~~~~~~~~~~~~~~~~~~~ blank, blank-m, blank-c ~~~~~~~~~~~~~~~~~~~~~~~~~~

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

blank.attributes =
    area.attribute?
    & long.attribute?
area.attribute = attribute area { xsd:boolean }

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

# ~~~~~~ blank-m
blank-m = element blank { blank-m.content }
blank-m.content =
    p
    | math
    | image
    | audio
    | (s-m+, help?, answer?)

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

blank-c.attributes = form.attribute?
form.attribute = attribute form { 'radio' | 'check' }

blank-c.content = (blank-c.right | blank-c.wrong)+, help?, answer?
blank-c.right = element right { inlines }
blank-c.wrong = element wrong { inlines }

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

# ~~~~~~ s-m
s-m = element s { s-m.content }
s-m.content =
    p
    | math
    | image
    | audio

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ char ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

char.attributes = function.attribute?
function.attribute = attribute function { "accent" | "uppercase" }

char.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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ dictation.hint ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ dictation.hint
dictation.hint = element hint { dictation.hint.content }

dictation.hint.content =
    dictation.hint.w,
    mistake+

# ~~~~~~ dictation.hint.w
dictation.hint.w = element w { text }

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

mistake.attributes =
    mistake.is.attribute?
mistake.is.attribute = attribute is { text }

mistake.content = inlines