RelaxNG/publiset.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
lun., 23 janv. 2012 18:59:27 +0100
changeset 77 4690abab3daa
parent 66 29c53c3d676e
child 96 4817d2fa8801
permissions -rw-r--r--
Structuration des exercices composites
# $Id$

start = publiset


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

publiset.attributes =
   version.attribute
version.attribute = attribute version { "1.0" }

publiset.content =
   (composition | selection)+


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

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ composition ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

composition.attributes =
   composition.id.attribute
 & path.attribute?
 & xpath.attribute?
 & xslt.attribute?
 & remap.attributes
 & lang.attribute?
composition.id.attribute = attribute xml:id { xsd:ID }
path.attribute = attribute path { xsd:anyURI }
xslt.attribute = attribute xslt { xsd:anyURI }
xpath.attribute = attribute xpath { text }
lang.attribute = attribute xml:lang { xsd:language }

composition.content =
   composition.head?,
   (composition.division | composition.file)+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ selection ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

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

selection.content =
   selection.head?,
   (selection.division | selection.file | link)+


# =============================================================================
#                                  HEAD LEVEL
# =============================================================================

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ head ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

composition.head = element head { head.attributes, top.head.content }
selection.head = element head { top.head.content }
division.head = element head { division.head.content }

head.attributes =
   remap.attributes

top.head.content =
   (title, subtitle?)?
 & identifier*
 & copyright?
 & contributors?
 & abstract?
 & cover?
division.head.content =
   (title, subtitle?)?

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

title = element title { title.content }
subtitle = element subtitle { title.content }

title.content = inlines

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ identifier ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

identifier.uri = element identifier {
   attribute type { "uri" }, xsd:anyURI
}

identifier.ean = element identifier {
   attribute type { "ean" }, xsd:token {pattern = "\d{13}"}
}

identifier = identifier.uri | identifier.ean

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ copyright ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

copyright = element copyright { copyright.content }

copyright.content = inlines

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ contributors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

contributors.content =
   contributor+

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

contributor.content =
   (((firstname, secondname?)?, lastname) | label),
   address?,
   link?,
   role*

# ~~~~~~ firstname, secondname, lastname, label
firstname = element firstname { firstname.content }
secondname = element secondname { secondname.content }
lastname = element lastname { lastname.content }
label = element label { label.content }

firstname.content = inlines
secondname.content = inlines
lastname.content = inlines
label.content = inlines

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

address.content = inlines

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

role.content = "author" | "illustrator" | "publisher"

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ abstract ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

abstract = element abstract { abstract.content }

abstract.content =
   p+

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cover ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cover = element cover { cover.content }

cover.content =
   cover.image

cover.image = element image { cover.image.attributes }

cover.image.attributes =
   cover.image.id.attribute
cover.image.id.attribute = attribute id { xsd:NMTOKEN }


# =============================================================================
#                                DIVISION LEVEL
# =============================================================================

composition.division = element division {
   composition.division.attributes,
   composition.division.content
}
selection.division = element division {
   selection.division.attributes,
   selection.division.content
}

composition.division.attributes =
   path.attribute?
 & xpath.attribute?
 & xslt.attribute?
 & remap.attributes
selection.division.attributes =
   path.attribute?

composition.division.content =
   composition.head?,
   (composition.division | composition.file)+
selection.division.content =
   selection.head?,
   (selection.division | selection.file | link)+


# =============================================================================
#                                  FILE LEVEL
# =============================================================================

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ file ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

composition.file = element file { composition.file.attributes }
selection.file = element file { selection.file.attributes, file.content }

composition.file.attributes =
   name.attribute
 & xpath.attribute?
 & xslt.attribute?
selection.file.attributes =
   name.attribute
 & uri.attribute?
name.attribute = attribute name { xsd:anyURI }

file.content = inlines


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

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

p = element p { p.content }

p.content =
   inlines


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

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

inlines = mixed {
   sup*
 & sub*
}

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

sup = element sup { inlines }

sub = element sub { inlines }

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

link.attributes =
   uri.attribute
uri.attribute = attribute uri { xsd:anyURI }

link.content = inlines


# =============================================================================
#                               REMAP ATTRIBUTES
# =============================================================================

remap.attributes =
   as.attribute?
 & attributes.attribute?
as.attribute = attribute as { xsd:QName }
attributes.attribute =
   attribute attributes {list { (xsd:token {pattern = "\c+=\S+"})+ }}