<?xml version='1.0' encoding='utf-8'?>
<grammar xmlns='http://relaxng.org/ns/structure/1.0'
         xmlns:a='http://bulletin.cstug.cz/ns/annotation'
         xmlns:s='http://www.ascc.net/xml/schematron'
         ns='http://bulletin.cstug.cz/ns/CSTUGbulletin'
         datatypeLibrary='http://www.w3.org/2001/XMLSchema-datatypes'>

<a:title>Relax NG Schema for CSTUG Bulletin v. 1.0</a:title>
<a:hr/>

<a:annotation>
This is a Relax NG schema for <a:i>C<a:sub>S</a:sub></a:i>TUG bulletin table of contents, abstracts
and keywords. The elements will have its own namespace <a:code><a:cstugns/></a:code>, attributes
will have empty namespace. Some elements will belong to other namespaces. The types will be defined
using <a:a title='XML Schema Datatype Library' href='http://www.w3.org/TR/xmlschema-2/'>XML Schema
Datatype Library</a:a>.
</a:annotation>

<a:annotation>
The schema contains Schematron 1.3 assertions intended for use with <a:code>relames.jar</a:code>
plugin for <a:code>msv</a:code>. If you run validation from a command line, you must use
<a:code>relames.jar</a:code> explicitely, otherwise the assertions will be ignored just as comments
and pure Relax NG validation will be performed. Similarly, if you run validation from the
<a:code>JARVTask</a:code> in Ant, you must specify <a:code>schemaLanguage&#160;=
'http://relaxng.org/ns/structure/1.0+http://www.ascc.net/xml/schematron'</a:code>.
</a:annotation>

<a:annotation>
As you will se later, information is often spread accross several files. The assertions verify only
data items which must always link to the same file. Some conditions are therefore not validated but
there is not a great risk that they will be wrong.
</a:annotation>

<a:annotation>
The assertions do not verify that the author and keyword id's refer to existing information in the
respective file although it could be implemented. Use the stylesheet <a:code>unknown.xsl</a:code>
for this purpose.
</a:annotation>

<a:annotation>
The schema is used for the whole group of documents. The <a:a title='start'
href='#start'><a:elem>start</a:elem></a:a>
element is defined at the end of this file (see the table of contents above).
</a:annotation>

<a:annotation>
The schema is documented via elements from a special namespace. A processing instruction links a
stylesheet designed for pretty-printing in Mozilla. It works partially even in MS Internet Explorer
but nesting of the code is lost. The <a:code>name</a:code> attributes of the <a:elem>ref</a:elem>
elements are transformed to hyperlinks to the <a:elem>define</a:elem> elements where the pattern is
defined. The description of each pattern contains a list of links to patterns where it is used.
</a:annotation>

<a:annotation>
Please do not save this file alone. It requires a stylesheet for pretty-printing. You can find all
files zipped into a single archive at <a:a  title='XML files repository'
href='http://bulletin.cstug.cz/xml/'>http://bulletin.cstug.cz/xml</a:a>.
</a:annotation>

<a:annotation>
The information will always be spread to several XML files. Their home location is, as written
above, <a:a  title='XML files repository'
href='http://bulletin.cstug.cz/xml/'>http://bulletin.cstug.cz/xml</a:a>. However, we would like to
allow their placement in private local copies, redistribution on a CD or DVD etc. In order to make
it easier, there will always be an index document containing the links to other files. The first
four attributes mean:
<a:ul>
<a:li><a:b>toc:</a:b> <a:a title='toc' href='#def.toc'>table of contents</a:a></a:li>
<a:li><a:b>keywords:</a:b> <a:a title='keywords' href='#def.kwdlist'>list of keywords</a:a></a:li>
<a:li><a:b>authors:</a:b> <a:a title='authors' href='#def.authlist'>list of authors</a:a></a:li>
<a:li><a:b>acronyms:</a:b> <a:a title='acronyms' href='#def.acrolist'>list of acronyms</a:a></a:li>
</a:ul>
The links may be either relative or absolute. It is always preferable to use relative links. If you
really need absolute links, put all files to the same directory and define the absolute part in the
<a:code>base</a:code> attribute. The templates in the supplied stylesheets obtain the URL as
<a:elem>xsl:value-of select='concat(@base, @toc)'/</a:elem>. The element optionally contains the
date and time of last modification. The contents is empty. All linked files must point back to the
index document by an <a:a title='indexhref' href='#def.xhref'>indexhref attribute</a:a>.
</a:annotation>
<define name='def.index'>
  <element name='index'>
    <attribute name='toc'>
      <data type='anyURI'/>
    </attribute>
    <attribute name='keywords'>
      <data type='anyURI'/>
    </attribute>
    <attribute name='authors'>
      <data type='anyURI'/>
    </attribute>
    <attribute name='acronyms'>
      <data type='anyURI'/>
    </attribute>
    <optional>
      <attribute name='base'>
        <data type='anyURI'/>
      </attribute>
    </optional>
    <optional>
      <ref name='def.lastmod'/>
    </optional>
    <empty/>
  </element>
</define>

<a:annotation>
The contents of some elements may be either present in the same file or may be included from
another file. Inclusion will use standard XML mechanisms. We will therefore need a subset of
XInclude.
</a:annotation>
<define name='xincl'>
  <element name='include' ns='http://www.w3c.org/2001/XInclude'>
    <attribute name='href'>
      <data type='anyURI'/>
    </attribute>
    <optional>
      <attribute name='parseType'>
        <value>xml</value>
      </attribute>
    </optional>
  </element>
</define>

<a:annotation>
Some elements need information on language. We will make advantage of the <a:code>lang</a:code>
attribute. The texts in the bulletin are in Czech, Slovak, English and German only. We will
therefore limit the values to the <a:a href='http://www.id3.org/iso639-2.html'
title='ISO 639-2'>ISO&#160;639-2</a:a> codes
of these languages only but the repertoire may be extended in the future if it becomes necessary.
</a:annotation>
<define name='def.lang.attr'>
  <attribute name='lang'>
    <choice>
      <value>cze</value>
      <value>slo</value>
      <value>eng</value>
      <value>ger</value>
    </choice>
  </attribute>
</define>

<a:annotation>
Some elements require a token as its ID.
</a:annotation>
<define name='def.id'>
  <attribute name='id'>
    <data type='NMTOKEN'/>
  </attribute>
</define>

<a:annotation>
Each principal element (the one which can appear in <a:a title='start'
href='#start'><a:elem>start</a:elem></a:a>)
must point to the <a:a title='index' href='#def.index'>index document</a:a>. The link may be either
relative or absolute.
</a:annotation>
<define name='def.xhref'>
  <attribute name='indexhref'>
    <data type='anyURI'/>
  </attribute>
</define>

<a:annotation>
Some elements may optionally have an attribute containing the date (and time) of the last
modification according to ISO&#160;8601. It is allowed to specify either the date or the full time.
The time is used to distinguis several releases within the same day.  The attribute
represents the date/time when the document was physically modified.  It may differ from the file
timestamp.
</a:annotation>

<define name='def.lastmod'>
  <attribute name='lastModified'>
    <choice>
      <data type='dateTime'/>
      <data type='date'/>
    </choice>
  </attribute>
</define>

<a:annotation>
The list of acronyms is used to store associations of the ID's and real texts. The root element
must contain a link to the <a:a title='index' href='#def.index'>index file</a:a>.
</a:annotation>
<define name='def.acrolist'>
  <element name='acronymList'>
    <ref name='def.xhref'/>
    <ref name='def.lastmod'/>
    <zeroOrMore>
      <ref name='def.acronym'/>
    </zeroOrMore>
  </element>
</define>


<a:annotation>
Each acronym assigns an ID's to the HTML and T<a:sub>E</a:sub>X representation of logos. The text version is
used in the plain text output and as a sort key. Optional <a:elem>meaning</a:elem> can be used for
explanation. The acronym ID must be unique.
</a:annotation>
<define name='def.acronym'>
  <element name='acronym'>
    <ref name='def.id'/>
    <interleave>
      <ref name='def.TeX'/>
      <ref name='def.html'/>
      <ref name='def.text'/>
      <optional>
        <ref name='def.meaning'/>
      </optional>
    </interleave>
    <s:report test='following-sibling::node()/@id = @id'>
      The "id" attribute of the "acronym" element must be unique.
    </s:report>
  </element>
</define>

<a:annotation>
The T<a:sub>E</a:sub>X part may contain text and references to other acronyms.
</a:annotation>
<define name='def.TeX'>
  <element name='TeX'>
    <ref name='text.or.acro'/>
  </element>
</define>

<a:annotation>
The HTML part can contain any markup from namespaces different from this one. References to other
acronyms can also be used.
</a:annotation>
<define name='def.html'>
  <element name='html'>
    <oneOrMore>
      <ref name='def.html.content'/>
    </oneOrMore>
  </element>
</define>

<a:annotation>
The content model for the <a:elem>html</a:elem> element must be defined separately because it can
be used recursively.
</a:annotation>
<define name='def.html.content'>
  <choice>
    <text/>
    <element>
      <anyName>
        <except>
          <nsName/>
        </except>
      </anyName>
      <zeroOrMore>
        <ref name='def.html.content'/>
      </zeroOrMore>
    </element>
    <ref name='def.acro'/>
  </choice>
</define>

<a:annotation>
The text part may only contain plain text.
</a:annotation>
<define name='def.text'>
  <element name='text'>
    <text/>
  </element>
</define>

<a:annotation>
The meaning may only contain plain text.
</a:annotation>
<define name='def.meaning'>
  <element name='meaning'>
    <text/>
  </element>
</define>

<a:annotation>
The contents of the reference to an acronym will be the <a:a title='acronym'
href='#def.acronym'>acronym's ID</a:a>. We decided to put the ID
to the contents instead of the attribute so that users, who do not process the document with our
stylesheets which expadn references, see at least something.

</a:annotation>
<define name='def.acro'>
  <element name='acro'>
    <data type='NMTOKEN'/>
  </element>
</define>

<a:annotation>
The following pattern will be used repeatedly.
</a:annotation>
<define name='text.or.acro'>
  <oneOrMore>
    <choice>
      <text/>
      <ref name='def.acro'/>
    </choice>
  </oneOrMore>
</define>

<a:annotation>
The keywords are stored in their own file. The root element must contain a link to the <a:a
title='index' href='#def.index'>index file</a:a>.
</a:annotation>
<define name='def.kwdlist'>
  <element name='keywordList'>
    <ref name='def.xhref'/>
    <ref name='def.lastmod'/>
    <zeroOrMore>
      <ref name='def.keyword'/>
    </zeroOrMore>
  </element>
</define>

<a:annotation>
<a:p>Each keyword has its (human readable) identifier and text which may <a:a
title='acronym reference' href='#def.acro'>refer to an acronym</a:a>. The Czech
text is mandatory, the English and Slovak translations are optional. The name of the child element
is taken from the 3-letter language code according to <a:a
href='http://www.id3.org/iso639-2.html' title='ISO 639-2'>ISO&#160;639-2</a:a>. However, the
acronyms or product names have the same form in all languages. In such a case we use the
alement named ALL. No other language variants are then allowed.</a:p>
<a:p>You can make use of one of the supplied stylesheets: <a:code>kwd.xsl</a:code> for
XSLT&#160;1.0 or <a:code>kwd2.xsl</a:code> for XSLT&#160;2.0. They expand the keyword in the
following way:</a:p>
<a:ol>
<a:li>If the element of the required language exists, it is expanded by applying the templates
(mainly <a:elem>acro</a:elem>).</a:li>
<a:li>If the Czech version exists (it must exist in each valid document) it is used.</a:li>
<a:li>The first child element is used. However, this might happen only if the document is not valid
because all valid documents must have the Czech version.</a:li>
</a:ol>
<a:p>The keyword ID must be unique.</a:p>
</a:annotation>
<define name='def.keyword'>
  <element name='keyword'>
    <ref name='def.id'/>
    <choice>
      <element name='ALL'>
        <ref name='text.or.acro'/>
      </element>
      <interleave>
        <element name='cze'>
          <ref name='text.or.acro'/>
        </element>
        <optional>
          <element name='slo'>
            <ref name='text.or.acro'/>
          </element>
        </optional>
        <optional>
          <element name='eng'>
            <ref name='text.or.acro'/>
          </element>
        </optional>
      </interleave>
    </choice>
    <s:report test='following-sibling::node()/@id = @id'>
      The "id" attribute of the "keyword" element must be unique.
    </s:report>
  </element>
</define>

<a:annotation>
The list of authors is used to replace author names with ID's. The root element must contain a link
to the <a:a title='index' href='#def.index'>index file</a:a>.
</a:annotation>
<define name='def.authlist'>
  <element name='authorList'>
    <ref name='def.xhref'/>
    <ref name='def.lastmod'/>
    <zeroOrMore>
      <ref name='def.author'/>
    </zeroOrMore>
  </element>
</define>

<a:annotation>
The author's ID must be a NMTOKEN which can be used for sorting. The surname, first name nad
initials may contain <a:a title='acronym reference' href='#def.acro'>references to acronyms</a:a>. The
full name can sometimes be expressed as
an acronym. In such cases this optional child is preferred to concatenation of the initials and he
surname. Again the author ID must be unique.
</a:annotation>
<define name='def.author'>
  <element name='author'>
    <ref name='def.id'/>
    <interleave>
      <element name='surname'>
        <ref name='text.or.acro'/>
      </element>
      <element name='firstname'>
        <ref name='text.or.acro'/>
      </element>
      <element name='initials'>
        <ref name='text.or.acro'/>
      </element>
      <optional>
        <element name='fullname'>
          <ref name='text.or.acro'/>
        </element>
      </optional>
    </interleave>
    <s:report test='following-sibling::node()/@id = @id'>
      The "id" attribute of the "author" element must be unique.
    </s:report>
  </element>
</define>

<a:annotation>
The main table of contents will be in its own file. The volumes may be directly present in the
element or included via XInclude. The ISSN* elements have fixed values.
</a:annotation>
<define name='def.toc'>
  <element name='toc'>
    <ref name='def.xhref'/>
    <optional>
      <ref name='def.lastmod'/>
    </optional>
    <attribute name='ISSNprinted'>
      <value>1211-6661</value>
    </attribute>
    <attribute name='ISSNonline'>
      <value>1213-8185</value>
    </attribute>
    <zeroOrMore>
      <choice>
        <ref name='xincl'/>
        <ref name='def.volume'/>
      </choice>
    </zeroOrMore>
  </element>
</define>

<a:annotation>
Each volume can be stored in its own file, therefore it must contain the link to the <a:a
title='index' href='#def.index'>index file</a:a>.
This link is usually unused if the elements are contained within the toc file as children of the
<a:a href='#def.toc'><a:elem>toc</a:elem></a:a> element. The element needs an ID which is identical to the
year of publication. Another attribute is the volume. The issues can either appear as immediate
children or included via XInclude.
</a:annotation>
<define name='def.volume'>
  <element name='volume'>
    <ref name='def.xhref'/>
    <optional>
      <ref name='def.lastmod'/>
    </optional>
    <attribute name='year'>
      <ref name='def.year.type'/>
    </attribute>
    <attribute name='id'>
      <ref name='def.year.type'/>
    </attribute>
    <attribute name='volume'>
      <data type='positiveInteger'/>
    </attribute>
    <zeroOrMore>
      <choice>
        <ref name='xincl'/>
        <ref name='def.issue'/>
      </choice>
    </zeroOrMore>
    <s:assert test='@year = @id'>
      The "year" and "id" attributes of the "volume" element must be equal.
    </s:assert>
    <s:assert test='@year - 1990 = @volume'>
      The "volume" attributes of the "volume" element is incorrect.
    </s:assert>
  </element>
</define>

<a:annotation>
The year and the ID of the volume will share the same type.
</a:annotation>
<define name='def.year.type'>
  <data type='positiveInteger'>
    <param name='minInclusive'>1991</param>
  </data>
</define>

<a:annotation>
<a:p>Each issue can appear in its own file or can be present in the file of <a:a
href='#def.volume'><a:elem>volume</a:elem></a:a>. The link to the <a:a titile='index'
href='#def.index'>index file</a:a> is therefore mandatory
(but see the <a:a href='#def.volume'>comment for volumes</a:a>). The ID contains both the year and
issue number so that it is unique. Generally you are not able to ask the year and the volume number
if the issue resides in its own file. The year can thus be obtained as the part of the ID before
the slash and the volume number is calculated by subtracting 1990 from the year. The first and last
page of the whole issue are optional but they must either both be given or both omitted. The
<a:code>href</a:code> attribute contains the link to the web page with contents of the issue, the
optional <a:code>pdfref</a:code> attribute links to the PDF version of the issue provided it is
already available.</a:p>

<a:p>The element contains a few Schematron assertions. Notice that sometimes the last article may
end at the cover page which is traditionally reserved just for the colophon. Thus the number of
pages need not be strictly divisible by&#160;4.</a:p>
</a:annotation>
<define name='def.issue'>
  <element name='issue'>
    <ref name='def.xhref'/>
    <ref name='def.issue.id'/>
    <ref name='def.issue.num'/>
    <attribute name='href'>
      <data type='anyURI'/>
    </attribute>
    <optional>
      <ref name='def.lastmod'/>
    </optional>
    <optional>
      <attribute name='pdfref'>
        <data type='anyURI'/>
      </attribute>
    </optional>
    <optional>
      <attribute name='firstPage'>
        <data type='positiveInteger'/>
      </attribute>
      <attribute name='lastPage'>
        <data type='positiveInteger'/>
      </attribute>
    </optional>
    <oneOrMore>
      <ref name='def.article'/>
    </oneOrMore>
    <s:assert test='substring-after(@id, "/") = @num'>
      The "id" and "num" attributes have conflicting values.
    </s:assert>
    <s:assert test='not(contains(@num, "-")) or
number(substring-before(@num, "-")) &lt; number(substring-after(@num, "-"))'>
      The number of a multiple issue is invalid.
    </s:assert>
    <s:assert test='not(@firstPage) or @firstPage &lt; @lastPage'>
      The last page must be greater than the first page.
    </s:assert>
    <s:assert test='not(@firstPage) or (@lastPage - @firstPage + 1) mod 4 &lt;= 1'>
      The number of pages must be divisible by 4.
    </s:assert>
  </element>
</define>

<a:annotation>
Sometimes several issues are published together, thus the number is defined by the following
pattern.
</a:annotation>
<define name='def.issue.num'>
  <attribute name='num'>
    <data type='string'>
      <param name='pattern'>[1-4](-[2-4])?</param>
    </data>
  </attribute>
</define>

<a:annotation>
This is the pattern for the issue ID as <a:a href='#def.issue'>discussed above</a:a>.
</a:annotation>
<define name='def.issue.id'>
  <attribute name='id'>
    <data type='string'>
      <param name='pattern'>[0-9]{4}/[1-4](-[2-4])?</param>
    </data>
  </attribute>
</define>

<a:annotation>
<a:p>The articles are usually included in the <a:a href='#def.issue'><a:elem>issue</a:elem></a:a>
element. The only mandatory attributes are therefore its serial number and ID and the language of
the main body of the article. The number of the first page is mandatory, the number of the last
page is optional. For reasons
<a:a href='#def.bibliography'>explained later</a:a> we allow to insert optionally also the year,
volume and issue number. However, it is mandatory either to include all of them or omit all of
them. Another attribute, which can optionally be included for the same reason, is the link to the
web page.</a:p>

<a:p>The <a:elem>article</a:elem> elements may also appear in the bibliography listings. In such a
case their order will be random and some assertions thus make no sense. Moreover, some material
(mainly photos) may be placed between articles and they do not belong to any of them. Thus
sometimes <a:code>firstPage[n] - lastPage[n-1] &gt; 1</a:code>.</a:p>
</a:annotation>
<define name='def.article'>
  <element name='article'>
    <ref name='def.lang.attr'/>
    <attribute name='serial'>
      <data type='positiveInteger'/>
    </attribute>
    <ref name='art.id'/>
    <attribute name='firstPage'>
      <data type='positiveInteger'/>
    </attribute>
    <optional>
      <attribute name='lastPage'>
        <data type='positiveInteger'/>
      </attribute>
    </optional>
    <optional>
      <attribute name='year'>
        <ref name='def.year.type'/>
      </attribute>
      <attribute name='volume'>
        <data type='positiveInteger'/>
      </attribute>
      <ref name='def.issue.num'/>
    </optional>
    <optional>
      <attribute name='href'>
        <data type='anyURI'/>
      </attribute>
    </optional>
    <ref name='def.article.content'/>
    <s:assert test='@serial = substring-after(@id, "#")'>
      The "serial" and "id" attributes are in conflict.
    </s:assert>
    <s:assert test='not (parent::node()[local-name() = "issue"]) or
not (preceding-sibling::node()[local-name() = "article"]) or number(@serial) = 1
+ number(preceding-sibling::node()[local-name()="article"][1]/@serial)'>
      The "serial" attribute is not an increment.
    </s:assert>
    <s:assert test='not (parent::node()[local-name() = "issue"]) or
preceding-sibling::node()[local-name()="article"] or @serial = 1'>
      The first "article" element must have serial="1".
    </s:assert>
    <s:assert test='not(@num) or not(contains(@num, "-")) or
number(substring-before(@num, "-")) &lt; number(substring-after(@num, "-"))'>
      The number of a multiple issue within "article" is invalid.
    </s:assert>
    <s:assert test='not(@num) or concat(@year, "/", @num, "#", @serial) = @id'>
      The "year", "num", "serial", and "id" attributes of the "article" element are in conflict.
    </s:assert>
    <s:report test='@lastPage and number(@lastPage) &lt; number(@firstPage)'>
      The last page of the "article" must not be less than the first page.
    </s:report>
    <s:report test='parent::node()[local-name() = "issue"] and
preceding-sibling::node()[local-name() = "article"] and
number(@firstPage) &lt; number(preceding-sibling::node()[local-name() = "article"]/@firstPage)'>
      Page numbering conflict (first page).
    </s:report>
    <s:report test='parent::node()[local-name() = "issue"] and
preceding-sibling::node()[local-name() = "article"] and
number(@firstPage) &lt; number(preceding-sibling::node()[local-name() = "article"]/@lastPage)'>
      Page numbering conflict (last page).
    </s:report>
  </element>
</define>

<a:annotation>
The article ID consists of the issue ID followed by the hash mark and the serial number.
</a:annotation>
<define name='art.id'>
  <attribute name='id'>
    <data type='string'>
      <param name='pattern'>[0-9]{4}/[1-4](-[2-4])?#[0-9]+</param>
    </data>
  </attribute>
</define>

<a:annotation>
The article must always have a title in the main language. Author(s), keyword(s) and abstract(s)
are optional. If the titles and abstracts are present in several languages, they must always be
given as adjacent elements.
</a:annotation>
<define name='def.article.content'>
  <interleave>
    <ref name='article.title'/>
    <ref name='article.authors'/>
    <ref name='article.abstract'/>
    <ref name='article.keywords'/>
  </interleave>
</define>

<a:annotation>
The title must contain the language specification (it is the language of the title). Its text may
contain references to acronyms. If the language of the article is not English, we often provide an
English translation of the title. In the future we wish to translate most titles into English, even
if the translation does not appear in the bulletin. The titles in a particular language must not be
duplicated.
</a:annotation>
<define name='article.title'>
  <oneOrMore>
    <element name='title'>
      <ref name='def.lang.attr'/>
      <ref name='text.or.acro'/>
      <s:report test='following-sibling::node()[local-name()="title"]/@lang = @lang'>
        The "title" language must not be duplicated.
      </s:report>
    </element>
  </oneOrMore>
</define>

<a:annotation>
Article authors will be defined by <a:a title="Author's ID" href='#def.author'>authors' ID's</a:a>
in the body of the element. Remember that their order is important. The same author must not be
entered twice.
</a:annotation>
<define name='article.authors'>
  <zeroOrMore>
    <element name='author'>
      <data type='NMTOKEN'/>
      <s:report test='following-sibling::node()[local-name()="author"] = .'>
        The author tokens must not be duplicated.
      </s:report>
    </element>
  </zeroOrMore>
</define>

<a:annotation>
Similarly the keywords are also given as <a:a title='Keyword ID' href='#def.keyword'>keyword
ID's</a:a> in the element body but their order is irrelevant. The keywords must not be duplicated.
</a:annotation>
<define name='article.keywords'>
  <zeroOrMore>
    <element name='keyword'>
      <data type='NMTOKEN'/>
      <s:report test='following-sibling::node()[local-name()="keyword"] = .'>
        The keyword tokens must not be duplicated.
      </s:report>
    </element>
  </zeroOrMore>
</define>

<a:annotation>
<a:p>Abstracts have similar semantics as <a:a href='#article.title'><a:elem>title</a:elem></a:a>
with the only exception that they need not be present. However, in the future we would like to
translate all existing abstracts into English and possibly even provide abstracts to other
articles.</a:p>

<a:p>The abstract contains usually a few lines of text which are best represented with a plain text
and possibly acronyms. Sometimes it may have a complex structure. In such a case the markup must be
enclosed within one or more <a:elem>para</a:elem> elements.</a:p>

<a:p>The abstract in a particular language must not be duplicated.</a:p>
</a:annotation>
<define name='article.abstract'>
  <zeroOrMore>
    <element name='abstract'>
      <ref name='def.lang.attr'/>
      <ref name='def.abstract.contents'/>
      <s:report test='following-sibling::node()[local-name()="abstract"]/@lang = @lang'>
        The "abstract" language must not be duplicated.
      </s:report>
    </element>
  </zeroOrMore>
</define>

<a:annotation>
As written above, the abstract contents is a simple text or one or more paragraphs.
</a:annotation>
<define name='def.abstract.contents'>
  <choice>
    <ref name='text.or.acro'/>
    <ref name='def.paragraphs'/>
  </choice>
</define>

<a:annotation>
The paragraphs are enclosed in the <a:elem>para</a:elem> elements.
</a:annotation>
<define name='def.paragraphs'>
  <oneOrMore>
    <element name='para'>
      <ref name='def.para.contents'/>
    </element>
  </oneOrMore>
</define>

<a:annotation>
The paragraphs may contain simple text with acronyms or a few markup elements borrowed from HTML.
</a:annotation>
<define name='def.para.contents'>
  <zeroOrMore>
    <choice>
      <ref name='text.or.acro'/>
      <ref name='def.para.elements'/>
    </choice>
  </zeroOrMore>
</define>

<a:annotation>
The paragraph elements consists of lists and inline elements.
</a:annotation>
<define name='def.para.elements'>
  <choice>
    <element name='ol'>
      <ref name='def.list'/>
    </element>
    <element name='ul'>
      <ref name='def.list'/>
    </element>
    <ref name='def.inline'/>
  </choice>
</define>

<a:annotation>
The list elements contain one or more <a:elem>li</a:elem> elements.
</a:annotation>
<define name='def.list'>
  <zeroOrMore>
    <element name='li'>
      <zeroOrMore>
        <ref name='def.inline'/>
      </zeroOrMore>
    </element>
  </zeroOrMore>
</define>

<a:annotation>
The inline elements are basically font changing commands and, of course, plain text. Element
<a:elem>cmd</a:elem> represents the <a:code>\cmd</a:code> macro.
</a:annotation>
<define name='def.inline'>
  <choice>
    <ref name='text.or.acro'/>
    <element name='b'>
      <ref name='inline.contents'/>
    </element>
    <element name='i'>
      <ref name='inline.contents'/>
    </element>
    <element name='tt'>
      <ref name='inline.contents'/>
    </element>
    <element name='em'>
      <ref name='inline.contents'/>
    </element>
    <element name='quote'>
      <ref name='inline.contents'/>
    </element>
    <element name='cmd'>
      <ref name='inline.contents'/>
    </element>
  </choice>
</define>

<a:annotation>
The inline elements may contain a text with acronyms and other inline elements.
</a:annotation>
<define name='inline.contents'>
  <zeroOrMore>
    <choice>
      <ref name='text.or.acro'/>
      <ref name='def.inline'/>
    </choice>
  </zeroOrMore>
</define>

<a:annotation>
The main purpose of the list of references is to retrieve information on articles into the
T<a:sub>E</a:sub>X file. It is, however, allowed to store the retrieved information also as an XML
file. The root element must always contain the link to the <a:a title='index'
href='#def.index'>index file</a:a>. Its contents is either a list of requested bibliography entries
or retrieved articles (usually with the full information as discussed <a:a
href='#def.article'>in the description of the <a:elem>article</a:elem> element</a:a>). The two
types of elements must not be mixed.
</a:annotation>
<define name='def.bibliography'>
  <element name='bibliography'>
    <ref name='def.xhref'/>
    <optional>
      <ref name='def.lastmod'/>
    </optional>
    <choice>
      <zeroOrMore>
        <ref name='def.cite'/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name='def.article'/>
      </zeroOrMore>
    </choice>
  </element>
</define>

<a:annotation>
The <a:elem>cite</a:elem> element needs an ID which is identical to <a:a title='Article ID'
href='#def.article'>the ID of the cited article.</a:a>
</a:annotation>
<define name='def.cite'>
  <element name='cite'>
    <ref name='art.id'/>
    <empty/>
  </element>
</define>

<a:annotation>
Start of the grammar.
</a:annotation>
<start>
  <choice>
    <ref name='def.index'/>
    <ref name='def.acrolist'/>
    <ref name='def.kwdlist'/>
    <ref name='def.authlist'/>
    <ref name='def.toc'/>
    <ref name='def.volume'/>
    <ref name='def.issue'/>
    <ref name='def.bibliography'/>
  </choice>
</start>

</grammar>
