RelaxNG/publiset.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
dim., 05 juin 2011 12:02:50 +0200
changeset 1 5f332cc7150a
parent 0 41a5385c69a2
child 2 417bb62f2a77
permissions -rw-r--r--
Ajout d'un logo
# $Id$

start = publiset


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

# ~~~~~~ attributes
publiset.attributes =
   version.attribute

version.attribute = attribute version { "1.0" }

# ~~~~~~ content
publiset.content =
   (composition | selection)+


# =============================================================================
#                                  Top level
# =============================================================================

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

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

# ~~~~~~ attributes
composition.attributes =
   composition.id.attribute
 & base.attribute?
 & remap.attributes

composition.id.attribute = attribute xml:id { xsd:ID }
base.attribute = attribute xml:base { xsd:anyURI }

# ~~~~~~ content
composition.content =
   composition.metadata?,
   (composition.file | composition.division)+

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

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

# ~~~~~~ attributes
selection.attributes =
   base.attribute?

selection.id.attribute = attribute xml:id { xsd:ID }

# ~~~~~~ content
selection.content =
   selection.metadata?,
   (selection.file | selection.division)+


# =============================================================================
#                                 Metadata level
# =============================================================================

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

selection.metadata = element metadata { metadata.content }

# ~~~~~~ attributes
metadata.attributes =
   remap.attributes

# ~~~~~~ content
metadata.content =
   title?,
   subtitle?,
   source?

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

title = element title { title.content }
title.content = inlines

subtitle = element subtitle { title.content }

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

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

# ~~~~~~ Attributes
source.attributes =
   source.id.attribute?
 & remap.attributes

source.id.attribute = attribute id { xsd:NMTOKEN }

# ~~~~~~ Content
source.content.book =
   title?,
   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
}

# ~~~~~~ attributes
composition.division.attributes =
   base.attribute?
 & remap.attributes

selection.division.attributes =
   base.attribute?

# ~~~~~~ content
composition.division.content =
   composition.metadata?,
   (composition.file | composition.division)+

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


# =============================================================================
#                                  File level
# =============================================================================

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

composition.file = element file { composition.file.attributes }

selection.file = element file { selection.file.attributes }

# ~~~~~~ attributes
composition.file.attributes =
   name.attribute
 & xpath.attribute?
 & remap.attributes

selection.file.attributes =
   name.attribute
 & xpath.attribute?

name.attribute = attribute name { text }
xpath.attribute = attribute xpath { text }


# =============================================================================
#                                 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+"})+ }}