RelaxNG/publidoc.rnc
changeset 0 41a5385c69a2
child 2 417bb62f2a77
--- /dev/null	jeu. janv. 01 00:00:00 1970 +0000
+++ b/RelaxNG/publidoc.rnc	sam. juin 04 09:01:30 2011 +0200
@@ -0,0 +1,320 @@
+# $Id$
+
+start = publidoc
+
+
+publidoc = element publidoc {
+   publidoc.attributes,
+   publidoc.content
+}
+
+# ~~~~~~ attributes
+publidoc.attributes =
+   version.attribute
+
+version.attribute = attribute version { "1.0" }
+
+# ~~~~~~ content
+publidoc.content =
+   document
+ | top.topic
+
+
+# =============================================================================
+#                                  Top level
+# =============================================================================
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ document ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+document = element document { document.attributes, document.content }
+
+# ~~~~~~ attributes
+document.attributes =
+   document.id.attribute
+
+document.id.attribute = attribute xml:id { xsd:ID }
+
+# ~~~~~~ content
+document.content =
+   metadata?,
+   (division+ | topic+)
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ topic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+top.topic = element topic { top.topic.attributes, topic.content }
+
+
+# =============================================================================
+#                               Metadata level
+# =============================================================================
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ metadata ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+metadata = element metadata { metadata.content }
+
+metadata.content =
+   title
+ & subtitle?
+ & author*
+ & publisher?
+ & language?
+ & date?
+ & place?
+ & source*
+ & subjectset?
+ & abstract?
+ & annotation*
+
+language = element language { language.attributes }
+language.attributes = lang.attribute
+lang.attribute = attribute xml:lang { xsd:language }
+
+place = element place { place.content }
+place.content = inlines
+
+abstract = element abstract { abstract.content }
+abstract.content = parag+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ title, subtitle ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+title = element title { title.content }
+title.content = inlines
+
+subtitle = element subtitle { title.content }
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ author, publisher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+author = element author { author.content }
+
+author.content =
+   firstname?,
+   lastname
+
+publisher = element publisher { publisher.content }
+
+publisher.content = inlines
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ source ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+source = element source {
+   source.attributes,
+   (  (attribute type { "book" }, source.content.book)
+    | (attribute type { "file" })),
+   source.content
+}
+
+# ~~~~~~ Attributes
+source.attributes =
+   source.id.attribute
+
+source.id.attribute = attribute id { xsd:NMTOKEN }
+
+# ~~~~~~ Content
+source.content.book =
+   title,
+   pagenumber*
+
+source.content =
+   annotation*
+
+pagenumber = element pagenumber { pagenumber.attributes }
+pagenumber.attributes =
+   pagenumber.value.attribute
+pagenumber.value.attribute = attribute value { pagenumber.value.enumeration }
+pagenumber.value.enumeration = xsd:positiveInteger
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ subject ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+subjectset = element subjectset { subjectset.content }
+
+subjectset.content = subject+
+
+subject = element subject { subject.attributes }
+subject.attributes =
+   subject.id.attribute
+subject.id.attribute = attribute id { xsd:NMTOKEN }
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ annotation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+annotation = element annotation { annotation.content }
+
+annotation.content = inlines
+
+
+# =============================================================================
+#                                 Division level
+# =============================================================================
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ division ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+division = element division { division.content }
+
+division.content =
+   metadata?,
+   (division+ | topic+)
+
+
+# =============================================================================
+#                               Component level
+# =============================================================================
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ topic ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+topic = element topic { topic.attributes, topic.content }
+
+# ~~~~~~ attributes
+top.topic.attributes =
+   topic.id.attribute
+ & topic.type.attribute?
+
+topic.attributes =
+   topic.id.attribute?
+ & topic.type.attribute?
+
+topic.id.attribute = attribute xml:id { xsd:ID }
+
+topic.type.attribute = attribute type { xsd:NCName }
+
+# ~~~~~~ content
+topic.content =
+   metadata?,
+   section+
+
+
+# =============================================================================
+#                                 Section level
+# =============================================================================
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ section ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+section = element section { section.content, section.attributes }
+
+section.content =
+   metadata?,
+   (section+
+    | (parag | media)+)
+
+section.attributes =
+   status.attribute?
+status.attribute = attribute status { xsd:NCName }
+
+
+# =============================================================================
+#                                 Block level
+# =============================================================================
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ parag ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+parag = element parag { parag.content }
+
+parag.content =
+   inlines
+ & link*
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ media ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+media = element media { media.content }
+
+media.content =
+   image+,
+   media.caption?
+
+media.id.attribute = attribute id { xsd:NMTOKEN }
+
+media.caption = element caption { media.caption.content }
+media.caption.content = parag+
+
+# ~~~~~~ Image
+image = element image { image.attributes, image.content }
+
+image.attributes =
+   media.id.attribute
+
+image.content =
+   copyright?
+
+copyright = element copyright { copyright.content }
+copyright.content = inlines
+
+
+# =============================================================================
+#                                 Inline level
+# =============================================================================
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ inlines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+inlines = mixed {
+   sup*
+ & sub*
+ & romannum*
+ & date*
+ & name*
+ & footnote*
+ & foreign*
+ & highlight*
+}
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sub, sup ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+sup = element sup { inlines }
+
+sub = element sub { inlines }
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ romannum ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+romannum = element romannum { xsd:token {pattern = "([dlxvi]+)"} }
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ date ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+date = element date { date.attributes, date.content }
+
+date.attributes = date.of.attribute
+
+date.of.attribute = attribute of { date.of.enumeration }
+date.of.enumeration = "event" | "birth" | "death"
+
+date.content = xsd:date | xsd:gYearMonth | xsd:gYear
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ name ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+firstname = element firstname { inlines }
+
+lastname = element lastname { inlines }
+
+name = element name { name.attributes, name.content }
+name.attributes = name.of.attribute?
+name.content = inlines
+name.of.attribute = attribute of { name.of.enumeration }
+name.of.enumeration = "person" | "company" | "book" | "newspaper" | "party"
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ footnote ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+footnote = element footnote { footnote.attributes, footnote.content }
+
+footnote.attributes = footnote.label.attribute?
+
+footnote.label.attribute = attribute label { text }
+
+footnote.content = parag+
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ foreign ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+foreign = element foreign { foreign.attributes, foreign.content }
+
+foreign.attributes = lang.attribute?
+
+foreign.content = inlines
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ highlight ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+highlight = element highlight { highlight.content }
+
+highlight.content = inlines
+
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ link ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+link = element link { link.attributes, link.content }
+
+link.attributes = empty
+
+link.content = inlines