RelaxNG/publiset.rnc
author Patrick PIERRE <patrick.pierre@prismallia.fr>
dim., 05 juin 2011 23:51:15 +0200
changeset 4 1db220a61526
parent 2 417bb62f2a77
child 5 69310bc35b63
permissions -rw-r--r--
Suppression des fichiers schemas.xml
# $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
 & base.attribute?
 & remap.attributes
composition.id.attribute = attribute xml:id { xsd:ID }
base.attribute = attribute xml:base { xsd:anyURI }

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

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

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

selection.attributes =
   base.attribute?
selection.id.attribute = attribute xml:id { xsd:ID }

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 }

metadata.attributes =
   remap.attributes

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

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

title = element title { title.content }

title.content = inlines

subtitle = element subtitle { title.content }

# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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 =
   base.attribute?
 & remap.attributes
selection.division.attributes =
   base.attribute?

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, file.content }
selection.file = element file { selection.file.attributes, file.content }

composition.file.attributes =
   xpath.attribute?
 & remap.attributes
selection.file.attributes =
   xpath.attribute?
xpath.attribute = attribute xpath { text }

file.content = xsd:anyURI
   
# =============================================================================
#                                 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+"})+ }}