# /=====================================================================\ 
# |  LaTeXML-structure.rnc                                              |
# | RelaxNG model for LaTeXML generated documents                       |
# |=====================================================================|
# | Part of LaTeXML:                                                    |
# |  Public domain software, produced as part of work done by the       |
# |  United States Government & not subject to copyright in the US.     |
# |=====================================================================|
# | Bruce Miller <bruce.miller@nist.gov>                        #_#     |
# | http://dlmf.nist.gov/LaTeXML/                              (o o)    |
# \=========================================================ooo==U==ooo=/

default namespace = "http://dlmf.nist.gov/LaTeXML"

#======================================================================

document =
## The document root.
element document { document_attributes, document_model }


## The content allowable as the main body of the document.
document.body.class = Para.model | paragraph | subsubsection
  | subsection | section | chapter | part | slide | sidebar

## Attributes for \elementref{document}.
document_attributes = Sectional.attributes


## Content model for \elementref{document}.
document_model =
 (FrontMatter.class | SectionalFrontMatter.class | Meta.class | titlepage)*,
  (document.body.class | BackMatter.class)*

#======================================================================

part =
## A part within a document.
element part { part_attributes, part_model }

## The content allowable as the main body of a part.
part.body.class = Para.model |  subparagraph | paragraph
   | subsubsection | subsection | section | chapter  | slide | sidebar

## Attributes for \elementref{part}.
part_attributes = Sectional.attributes

## Content model for \elementref{part}.
part_model = SectionalFrontMatter.class*, (part.body.class | BackMatter.class)*

#----------------------------------------------------------------------

chapter =
## A Chapter within a document.
element chapter { chapter_attributes, chapter_model }

## The content allowable as the main body of a chapter.
chapter.body.class = Para.model | subparagraph | paragraph
   | subsubsection | subsection | section | slide | sidebar

## Attributes for \elementref{chapter}.
chapter_attributes = Sectional.attributes

## Content model for \elementref{chapter}.
chapter_model = SectionalFrontMatter.class*, (chapter.body.class | BackMatter.class)*

#----------------------------------------------------------------------

section =
## A Section within a document.
element section { section_attributes, section_model }

## The content allowable as the main body of a section.
section.body.class = Para.model | subparagraph | paragraph
   | subsubsection | subsection  | slide | sidebar

## Attributes for \elementref{section}.
section_attributes = Sectional.attributes

## Content model for \elementref{section}.
section_model = SectionalFrontMatter.class*, (section.body.class | BackMatter.class)*

#----------------------------------------------------------------------

subsection =
## A Subsection within a document.
element subsection { subsection_attributes, subsection_model }
  
## The content allowable as the main body of a subsection.
subsection.body.class = Para.model | subparagraph | paragraph | subsubsection | slide | sidebar

## Attributes for \elementref{subsection}.
subsection_attributes = Sectional.attributes

## Content model for \elementref{subsection}.
subsection_model = SectionalFrontMatter.class*, (subsection.body.class | BackMatter.class)*

#----------------------------------------------------------------------

subsubsection =
## A Subsubsection within a document.
element subsubsection { subsubsection_attributes, subsubsection_model }

## The content allowable as the main body of a subsubsection.
subsubsection.body.class = Para.model | subparagraph | paragraph | slide | sidebar

## Attributes for \elementref{subsubsection}.
subsubsection_attributes = Sectional.attributes

## Content model for \elementref{subsubsection}.
subsubsection_model = SectionalFrontMatter.class*, (subsubsection.body.class | BackMatter.class)*

#----------------------------------------------------------------------

paragraph =
## A Paragraph within a document. This corresponds to a `formal' marked, possibly labelled
## LaTeX Paragraph,  in distinction from an unlabelled logical paragraph.
element paragraph { paragraph_attributes, paragraph_model }

## The content allowable as the main body of a paragraph.
paragraph.body.class = Para.model | subparagraph | slide | sidebar

## Attributes for \elementref{paragraph}.
paragraph_attributes = Sectional.attributes

## Content model for \elementref{paragraph}.
paragraph_model = SectionalFrontMatter.class*, (paragraph.body.class | BackMatter.class)*


#----------------------------------------------------------------------

subparagraph =
## A Subparagraph within a document.
element subparagraph { subparagraph_attributes, subparagraph_model }

## The content allowable as the main body of a subparagraph.
subparagraph.body.class = Para.model | slide | sidebar

## Attributes for \elementref{subparagraph}.
subparagraph_attributes = Sectional.attributes

## Content model for \elementref{subparagraph}.
subparagraph_model = SectionalFrontMatter.class*, (subparagraph.body.class | BackMatter.class)*

#======================================================================

slide =
## A Slide within a slideshow.
## The model currently doesn't enforce this, but the idea is that
## a slideshow document can contain section headings, but all
## real content should be confined to slides.
element slide { slide_attributes, slide_model }

## The content allowable as the main body of a \elementref{slide}.
slide.body.class = Para.model

## Attributes for \elementref{slide}.
slide_attributes = Sectional.attributes

## Content model for \elementref{slide}.
slide_model = SectionalFrontMatter.class*, (slide.body.class | BackMatter.class)*

#======================================================================

sidebar =
## A Sidebar; a short section-like object that floats outside the main flow.
element sidebar { sidebar_attributes, sidebar_model }

## The content allowable as the main body of a \elementref{sidebar}.
sidebar.body.class = Para.model

## Attributes for \elementref{sidebar}.
sidebar_attributes = Sectional.attributes

## Content model for \elementref{sidebar}.
sidebar_model = (FrontMatter.class | SectionalFrontMatter.class)*, (sidebar.body.class | BackMatter.class)*

#======================================================================

appendix =
## An Appendix within a document.
element appendix { appendix_attributes, appendix_model }

## The content allowable as the main body of a chapter.
appendix.body.class = Para.model | subparagraph | paragraph
  | subsubsection | subsection | section  | slide | sidebar

## Attributes for \elementref{appendix}.
appendix_attributes = Sectional.attributes

## Content model for \elementref{appendix}.
appendix_model = SectionalFrontMatter.class*, appendix.body.class*

#======================================================================

bibliography =
## A Bibliography within a document.
element bibliography { bibliography_attributes, bibliography_model }

## The content allowable as the main body of a chapter.
bibliography.body.class = Para.model | biblist

## Attributes for \elementref{bibliography}.
bibliography_attributes = 
  Sectional.attributes,
  Listing.attributes,

  ## the list of bib files used to create the bibliography.
  attribute files { text }?,

  ## the bibliographic style to be used to format the bibliography
  ## (presumably a BibTeX bst file name)
  attribute bibstyle { text }?,

  ## the citation style to be used when citing items from the bibliography
  attribute citestyle { text }?,

  ## whether the bibliographic items should be sorted or in order of citation.
  attribute sort { xsd:boolean }?

## Content model for \elementref{bibliography}.
bibliography_model = FrontMatter.class*, SectionalFrontMatter.class*, bibliography.body.class*

#======================================================================

index =
## An Index within a document.
element index { index_attributes, index_model }

## The content allowable as the main body of a chapter.
index.body.class = Para.model | indexlist

## Attributes for \elementref{index}.
index_attributes = 
  Sectional.attributes,
  Listing.attributes,

  ## The kind of index (obsolete?)
  attribute role { text }?

## Content model for \elementref{index}.
index_model = SectionalFrontMatter.class*, index.body.class*

#----------------------------------------------------------------------

indexlist =
## A heirarchical index structure typically generated during postprocessing
## from the collection of \elementref{indexmark} in the document
## (or document collection).
element indexlist { indexlist_attributes, indexlist_model }

## Attributes for \elementref{indexlist}.
indexlist_attributes = Common.attributes, ID.attributes

## Content model for \elementref{indexlist}.
indexlist_model = indexentry*

#----------------------------------------------------------------------

indexentry =
## An entry in an \elementref{indexlist} consisting of a phrase, references to
## points in the document where the phrase was found, and possibly
## a nested \elementref{indexlist} represented index levels below this one.
element indexentry { indexentry_attributes, indexentry_model }

## Attributes for \elementref{indexentry}.
indexentry_attributes = Common.attributes, ID.attributes

## Content model for \elementref{indexentry}.
indexentry_model = indexphrase, indexrefs?, indexlist?

#----------------------------------------------------------------------

indexrefs =
## A container for the references (\elementref{ref}) to where an \elementref{indexphrase} was
## encountered in the document. The model is Inline to allow
## arbitrary text, in addition to the expected \elementref{ref}'s.
element indexrefs { indexrefs_attributes, indexrefs_model }

## Attributes for \elementref{indexrefs}.
indexrefs_attributes = Common.attributes

## Content model for \elementref{indexrefs}.
indexrefs_model = Inline.model

#======================================================================

glossary =
## An Glossary within a document.
element glossary { glossary_attributes, glossary_model }

## The content allowable as the main body of a chapter.
glossary.body.class = Para.model | glossarylist

## Attributes for \elementref{glossary}.
glossary_attributes = 
  Sectional.attributes,
  Listing.attributes,

  ## The kind of glossary
  attribute role { text }?

## Content model for \elementref{glossary}.
glossary_model = SectionalFrontMatter.class*, glossary.body.class*

#----------------------------------------------------------------------

glossarylist =
## A glossary list typically generated during postprocessing
## from the collection of \elementref{glossaryphrase}'s in the document
## (or document collection).
element glossarylist { glossarylist_attributes, glossarylist_model }

## Attributes for \elementref{glossarylist}.
glossarylist_attributes = Common.attributes, ID.attributes

## Content model for \elementref{glossarylist}.
## The model allows loose \elementref{glossaryphrase}'s for data definitions,
## but they are not displayed as part of the list.
glossarylist_model = glossaryentry*

#----------------------------------------------------------------------

glossaryentry =
## An entry in an \elementref{glossarylist} consisting of a phrase,
## (one or more, presumably in increasing detail?), possibly a definition,
## and references to points in the document where the phrase was found.
element glossaryentry { glossaryentry_attributes, glossaryentry_model }

## Attributes for \elementref{glossaryentry}.
glossaryentry_attributes = Common.attributes, ID.attributes,
  ## The kind of glossary
  attribute role { text }?,
  ## a flattened form of the phrase for generating an \attr{ID}.
  attribute key { text }?

## Content model for \elementref{glossaryentry}.
glossaryentry_model = glossaryphrase*, indexrefs?

#======================================================================

title =
## The title of a document, section or similar document structure container.
element title { title_attributes, title_model }

## Attributes for \elementref{title}.
title_attributes =
  Common.attributes,
  Fontable.attributes,
  Colorable.attributes,
  Backgroundable.attributes

## Content model for \elementref{title},
## basically Inline.model with tag included (normally, but not necessarily, tag would come first).
title_model = (tag | text | Inline.class | Misc.class | Meta.class)*

#----------------------------------------------------------------------

toctitle =
## The short form of a title, for use in tables of contents or similar.
element toctitle { toctitle_attributes, toctitle_model }

## Attributes for \elementref{toctitle}.
toctitle_attributes = Common.attributes

## Content model for \elementref{toctitle}.
toctitle_model = (tag | text | Inline.class | Misc.class | Meta.class)*

#----------------------------------------------------------------------

subtitle =
## A subtitle, or secondary title.
element subtitle { subtitle_attributes, subtitle_model }

## Attributes for \elementref{subtitle}.
subtitle_attributes = Common.attributes

## Content model for \elementref{subtitle}.
subtitle_model = Inline.model

#======================================================================

creator =
## Generalized document creator.
element creator { creator_attributes, creator_model }

## The content allowed in authors, editors, etc.
Person.class = personname | contact

## Attributes for \elementref{creator}.
creator_attributes = 
  Common.attributes,
  FrontMatter.attributes,

  ## indicates the role of the person in creating the docment.
  ## Commonly useful values are specified, but is open-ended to support extension.
  attribute role { "author" | "editor" | "translator" | "contributor" | "translator" | text }?,

  ## specifies opening text to display before this creator in a formatted titlepage.
  ## This would be typically appear outside the author information, like "and".
  attribute before { text }?,

  ## specifies closing text, punctuation or conjunction to display after
  ## this creator in a formatted titlepage.
  attribute after { text }?


## Content model for \elementref{creator}.
creator_model = (Person.class | Misc.class)*

#----------------------------------------------------------------------
# NOTE: This should be aligned with Bibname.

personname =
## A person's name.
element personname { personname_attributes, personname_model }

## Attributes for \elementref{personname}.
personname_attributes =
  Common.attributes,
  Refable.attributes

## Content model for \elementref{personname}.
personname_model = Inline.model

#----------------------------------------------------------------------

contact =
## Generalized contact information for a document creator.
## Note that this element can be repeated to give different types 
## of contact information (using \attr{role}) for the same creator.
element contact { contact_attributes, contact_model }

## Attributes for \elementref{contact}.
contact_attributes = 
  Common.attributes,
  FrontMatter.attributes,
  Refable.attributes,

  ## indicates the type of contact information contained.
  ## Commonly useful values are specified, but is open-ended to support extension.
  attribute role { "affiliation" | "address" | "current_address" | "email" | "url"
                 | "thanks" | "dedicatory" | text }?

## Content model for \elementref{contact}.
contact_model = Inline.model

#======================================================================

date =
## Generalized document date.
## Note that this element can be repeated to give the dates
## of different events (using \attr{role}) for the same document.
element date { date_attributes, date_model }

## Attributes for \elementref{date}.
date_attributes = 
  Common.attributes, FrontMatter.attributes,

  ## indicates the relevance of the date to the document.
  ## Commonly useful values are specified, but is open-ended to support extension.
  attribute role { "creation" | "conversion" | "posted" | "received"
                 | "revised" | "accepted" | text }?

## Content model for \elementref{date}.
date_model = Inline.model

#======================================================================

abstract =
## A document abstract.
element abstract { abstract_attributes, abstract_model }

## Attributes for \elementref{abstract}.
abstract_attributes = Common.attributes, FrontMatter.attributes

## Content model for \elementref{abstract}.
abstract_model = Block.model

#======================================================================

acknowledgements =
## Acknowledgements for the document.
element acknowledgements { acknowledgements_attributes, acknowledgements_model }

## Attributes for \elementref{acknowledgements}.
acknowledgements_attributes = Common.attributes, FrontMatter.attributes

## Content model for \elementref{acknowledgements}.
acknowledgements_model = Inline.model

#======================================================================

keywords =
## Keywords for the document. The content is freeform.
element keywords { keywords_attributes, keywords_model }

## Attributes for \elementref{keywords}.
keywords_attributes = Common.attributes, FrontMatter.attributes

## Content model for \elementref{keywords}.
keywords_model = Inline.model

#======================================================================

classification =
## A classification of the document.
element classification { classification_attributes, classification_model }

## Attributes for \elementref{classification}.
classification_attributes = Common.attributes, FrontMatter.attributes,

  ## indicates what classification scheme was used.
  attribute scheme { text }?

## Content model for \elementref{classification}.
classification_model = Inline.model

#======================================================================
# Fallback

titlepage =
## block of random stuff marked as a titlepage
element titlepage { titlepage_attributes, titlepage_model }

## Attributes for \elementref{titlepage}.
titlepage_attributes = Sectional.attributes

## Content model for \elementref{titlepage}.
titlepage_model = (FrontMatter.class | SectionalFrontMatter.class | Block.class)*

#======================================================================
# Table(s) of Contents

TOC =
## (Generalized) Table Of Contents, represents table of contents
## as well as list of figures, tables, and other such things.
## This will generally be placed by a \cs{tableofcontents} command
## and filled in by postprocessing.
element TOC { TOC_attributes, TOC_model }

## Attributes for \elementref{TOC}.
TOC_attributes =
   Common.attributes,
   FrontMatter.attributes,

   ## indicates the kind of lists; space separated names of lists like "toc","lof", etc.
   attribute lists { text }?,

   ## indicates what kind of document elements to list, in the form of
   ## one or more tags such as \texttt{ltx:chapter} separated by \texttt{|}
   ## (suggestive of an xpath expression).
   attribute select { text }?,

   ## indicates the scope set of elements to include:
   ## \texttt{current} (default) is all in current document;
   ## \texttt{global} indicates all in the document set;
   ## otherwise an xml:id
   attribute scope { ("current" | "global" | text) }?,

   ## indicates what things to show in each entry
   attribute show { text }?,
   
   ## indicates how to format the listing
   attribute format { ("normal" | "short" | "veryshort" | text) }?

## Content model for \elementref{TOC}.
TOC_model = title?, toclist?

toclist =
## The actual table of contents list, filled in.
element toclist {toclist_attributes, toclist_model }

## Attributes for \elementref{toclist}.
toclist_attributes = Common.attributes

## Content model for \elementref{toclist}.
toclist_model = tocentry*

tocentry =
## An entry in a \elementref{toclist}.
element tocentry { tocentry_attributes, tocentry_model }

## Attributes for \elementref{tocentry}.
tocentry_attributes = Common.attributes

## Content model for \elementref{tocentry}.
tocentry_model = ( ref | toclist )*

#======================================================================

## Attributes shared by all sectional elements
Sectional.attributes =
  Common.attributes,
  Labelled.attributes,
  Backgroundable.attributes,

  ## Stores RDFa prefixes as space separated pairs,
  ## with the pairs being prefix and url separated by a colon;
  ## this should only appear at the root element.
  attribute rdf-prefixes { text }?

## Attributes for other elements that can be used in frontmatter.
FrontMatter.attributes =
  ## Records the name of the type of object this is to be used when composing the
  ## presentation.  The value of this attribute is often set by language localization packages.
  attribute name { text }?

## The content allowed for the front matter of each sectional unit,
## and the document.
SectionalFrontMatter.class = tags? | title | toctitle | creator

## The content allowed (in addition to \patternref{SectionalFrontMatter.class})
## for the front matter of a document.
FrontMatter.class =
  subtitle | date | abstract | acknowledgements
  | keywords | classification

## The content allowed a the end of a document.
## Note that this includes random trailing Block and Para material,
## to support articles with figures and similar data appearing `at end'.
BackMatter.class = bibliography | appendix | index | glossary | acknowledgements
                 | Para.class | Meta.class

Para.class |= TOC

#======================================================================
