RelaxNG/publiset.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
lun., 18 juil. 2011 23:35:32 +0200
changeset 34 c51d5097d065
parent 30 c0f9e813c039
child 35 de4114d12ef1
permissions -rw-r--r--
Amélioration de la gestion des auteurs et des éditeurs
# $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
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 }

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

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

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

selection.attributes =
   selection.id.attribute
 & path.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*
 & language?
 & author*
 & publisher?
 & source?
division.head.content =
   (title, subtitle?)?
 & language?

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

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

title.content = inlines

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

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

identifier.attributes =
   class.attribute
class.attribute = attribute class { "uri" | "ean" }

identifier.content =  xsd:anyURI | xsd:NMTOKEN

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ language ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

language = element language { language.attributes }

language.attributes = lang.attribute
lang.attribute = attribute xml:lang { xsd:language }

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ author, publisher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

author.attributes =
   role.attribute?
role.attribute = attribute role { "author" | "illustrator" }

author.content =
   firstname?,
   lastname,
   role*

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

publisher.content =
   label,
   url?

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

firstname.content = inlines

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

lastname.content = inlines

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

label.content = inlines

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

role.attributes =
   role.of.attribute
role.of.attribute = attribute of { "author" | "illustrator" }

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

url.content = xsd:anyURI

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ~~~~~~ source
source = element source {
   source.attributes,
   (  (attribute type { "book" }, source.content.book)
    | (attribute type { "file" }))
}

source.attributes =
   source.id.attribute?
 & remap.attributes
source.id.attribute = attribute id { xsd:NMTOKEN }

source.content.book =
   title?,
   pagenumber?

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

pagenumber.attributes =
   pagenumber.value.attribute
pagenumber.value.attribute = attribute value { pagenumber.value.enumeration }
pagenumber.value.enumeration = xsd:positiveInteger


# =============================================================================
#                                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?
 & remap.attributes
selection.file.attributes =
   name.attribute
 & uri.attribute?
name.attribute = attribute name { xsd:anyURI }
uri.attribute = attribute uri { xsd:anyURI }

file.content = inlines

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

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

link.attributes =
   uri.attribute

link.content = inlines


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

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

inlines = mixed {
   sup*
 & sub*
}

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

sup = element sup { inlines }

sub = element sub { 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+"})+ }}