<?xml version="1.0" encoding="UTF-8"?>
<!--
  This file is part of DocBook V5.0
  
  Copyright 1992-2008 HaL Computer Systems, Inc.,
  O'Reilly & Associates, Inc., ArborText, Inc., Fujitsu Software
  Corporation, Norman Walsh, Sun Microsystems, Inc., and the
  Organization for the Advancement of Structured Information
  Standards (OASIS).
  
  Release: $Id: index.rnc 8931 2010-10-20 13:29:20Z nwalsh $
  
  Permission to use, copy, modify and distribute the DocBook schema
  and its accompanying documentation for any purpose and without fee
  is hereby granted in perpetuity, provided that the above copyright
  notice and this paragraph appear in all copies. The copyright
  holders make no representation about the suitability of the schema
  for any purpose. It is provided "as is" without expressed or implied
  warranty.
  
  If you modify the DocBook schema in any way, label your schema as a
  variant of DocBook. See the reference documentation
  (http://docbook.org/tdg5/en/html/ch05.html#s-notdocbook)
  for more information.
  
  Please direct all questions, bug reports, or suggestions for changes
  to the docbook@lists.oasis-open.org mailing list. For more
  information, see http://www.oasis-open.org/docbook/.
  
  ======================================================================
-->
<grammar ns="http://docbook.org/ns/docbook" xmlns:db="http://docbook.org/ns/docbook" xmlns:s="http://purl.oclc.org/dsdl/schematron" xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start combine="choice">
    <choice>
      <ref name="db.setindex"/>
      <ref name="db.index"/>
      <ref name="db.indexdiv"/>
    </choice>
  </start>
  <define name="db.ubiq.inlines" combine="choice">
    <ref name="db.indexterm"/>
  </define>
  <define name="db.indexing.inlines" combine="choice">
    <ref name="db.indexterm"/>
  </define>
  <define name="db.nopara.blocks" combine="choice">
    <ref name="db.indexterm"/>
  </define>
  <define name="db.navigation.components" combine="choice">
    <ref name="db.index"/>
  </define>
  <define name="db.setindex.components" combine="choice">
    <ref name="db.setindex"/>
  </define>
  <define name="db.info.elements" combine="choice">
    <ref name="db.itermset"/>
  </define>
  <!-- ====================================================================== -->
  <define name="db.significance.enumeration">
    <choice>
      <value>normal</value>
      <a:documentation>Normal</a:documentation>
      <value>preferred</value>
      <a:documentation>Preferred</a:documentation>
    </choice>
  </define>
  <define name="db.significance.attribute">
    <attribute name="significance">
      <db:refpurpose>Specifies the significance of the term</db:refpurpose>
      <ref name="db.significance.enumeration"/>
    </attribute>
  </define>
  <define name="db.zone.attribute">
    <attribute name="zone">
      <db:refpurpose>Specifies the IDs of the elements to which this term applies</db:refpurpose>
      <data type="IDREFS"/>
    </attribute>
  </define>
  <define name="db.indexterm.pagenum.attribute">
    <attribute name="pagenum">
      <db:refpurpose>Indicates the page on which this index term occurs in some version of the printed document</db:refpurpose>
    </attribute>
  </define>
  <define name="db.scope.enumeration">
    <choice>
      <value>all</value>
      <a:documentation>All indexes</a:documentation>
      <value>global</value>
      <a:documentation>The global index (as for a combined index of a set of books)</a:documentation>
      <value>local</value>
      <a:documentation>The local index (the index for this document only)</a:documentation>
    </choice>
  </define>
  <define name="db.scope.attribute">
    <attribute name="scope">
      <db:refpurpose>Specifies the scope of the index term</db:refpurpose>
      <ref name="db.scope.enumeration"/>
    </attribute>
  </define>
  <define name="db.sortas.attribute">
    <attribute name="sortas">
      <db:refpurpose>Specifies the string by which the term is to be sorted; if unspecified, the term content is used</db:refpurpose>
    </attribute>
  </define>
  <define name="db.index.type.attribute">
    <attribute name="type">
      <db:refpurpose>Specifies the target index for this term</db:refpurpose>
    </attribute>
  </define>
  <!-- ====================================================================== -->
  <div>
    <db:refname>itermset</db:refname>
    <db:refpurpose>A set of index terms in the meta-information of a document</db:refpurpose>
    <define name="db.itermset.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.itermset.attlist">
      <interleave>
        <optional>
          <ref name="db.itermset.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
      </interleave>
    </define>
    <define name="db.itermset">
      <element name="itermset">
        <ref name="db.itermset.attlist"/>
        <oneOrMore>
          <ref name="db.indexterm.singular"/>
        </oneOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <define name="db.indexterm.contentmodel">
    <optional>
      <ref name="db.primary"/>
    </optional>
    <optional>
      <choice>
        <group>
          <ref name="db.secondary"/>
          <optional>
            <choice>
              <group>
                <ref name="db.tertiary"/>
                <optional>
                  <choice>
                    <ref name="db.see"/>
                    <oneOrMore>
                      <ref name="db.seealso"/>
                    </oneOrMore>
                  </choice>
                </optional>
              </group>
              <ref name="db.see"/>
              <oneOrMore>
                <ref name="db.seealso"/>
              </oneOrMore>
            </choice>
          </optional>
        </group>
        <ref name="db.see"/>
        <oneOrMore>
          <ref name="db.seealso"/>
        </oneOrMore>
      </choice>
    </optional>
  </define>
  <!-- ====================================================================== -->
  <div>
    <db:refname>indexterm</db:refname>
    <db:refpurpose>A wrapper for an indexed term</db:refpurpose>
    <define name="db.indexterm.singular.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.indexterm.singular.class.attribute">
      <attribute name="class">
        <db:refpurpose>Identifies the class of index term</db:refpurpose>
        <value>singular</value>
        <a:documentation>A singular index term</a:documentation>
      </attribute>
    </define>
    <define name="db.indexterm.singular.attlist">
      <interleave>
        <optional>
          <ref name="db.indexterm.singular.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.significance.attribute"/>
        </optional>
        <optional>
          <ref name="db.zone.attribute"/>
        </optional>
        <optional>
          <ref name="db.indexterm.pagenum.attribute"/>
        </optional>
        <optional>
          <ref name="db.scope.attribute"/>
        </optional>
        <optional>
          <ref name="db.index.type.attribute"/>
        </optional>
        <optional>
          <ref name="db.indexterm.singular.class.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.indexterm.singular">
      <element name="indexterm">
        <ref name="db.indexterm.singular.attlist"/>
        <ref name="db.indexterm.contentmodel"/>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>indexterm</db:refname>
    <db:refpurpose>A wrapper for an indexed term that covers a range</db:refpurpose>
    <define name="db.indexterm.startofrange.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.indexterm.startofrange.class.attribute">
      <attribute name="class">
        <db:refpurpose>Identifies the class of index term</db:refpurpose>
        <value>startofrange</value>
        <a:documentation>The start of a range</a:documentation>
      </attribute>
    </define>
    <define name="db.indexterm.startofrange.attlist">
      <interleave>
        <optional>
          <ref name="db.indexterm.startofrange.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.significance.attribute"/>
        </optional>
        <optional>
          <ref name="db.zone.attribute"/>
        </optional>
        <optional>
          <ref name="db.indexterm.pagenum.attribute"/>
        </optional>
        <optional>
          <ref name="db.scope.attribute"/>
        </optional>
        <optional>
          <ref name="db.index.type.attribute"/>
        </optional>
        <ref name="db.indexterm.startofrange.class.attribute"/>
      </interleave>
    </define>
    <define name="db.indexterm.startofrange">
      <element name="indexterm">
        <ref name="db.indexterm.startofrange.attlist"/>
        <ref name="db.indexterm.contentmodel"/>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>indexterm</db:refname>
    <db:refpurpose>Identifies the end of a range associated with an indexed term</db:refpurpose>
    <define name="db.indexterm.endofrange.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.indexterm.endofrange.class.attribute">
      <attribute name="class">
        <db:refpurpose>Identifies the class of index term</db:refpurpose>
        <value>endofrange</value>
        <a:documentation>The end of a range</a:documentation>
      </attribute>
    </define>
    <define name="db.indexterm.endofrange.startref.attribute">
      <attribute name="startref">
        <db:refpurpose>Points to the start of the range</db:refpurpose>
        <data type="IDREF"/>
      </attribute>
    </define>
    <define name="db.indexterm.endofrange.attlist">
      <interleave>
        <optional>
          <ref name="db.indexterm.endofrange.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <ref name="db.indexterm.endofrange.class.attribute"/>
        <ref name="db.indexterm.endofrange.startref.attribute"/>
      </interleave>
    </define>
    <define name="db.indexterm.endofrange">
      <element name="indexterm">
        <ref name="db.indexterm.endofrange.attlist"/>
        <empty/>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>indexterm</db:refname>
    <db:refpurpose>A wrapper for terms to be indexed</db:refpurpose>
    <define name="db.indexterm">
      <choice>
        <ref name="db.indexterm.singular"/>
        <ref name="db.indexterm.startofrange"/>
        <ref name="db.indexterm.endofrange"/>
      </choice>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>primary</db:refname>
    <db:refpurpose>The primary word or phrase under which an index term should be sorted</db:refpurpose>
    <define name="db.primary.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.primary.attlist">
      <interleave>
        <optional>
          <ref name="db.primary.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.sortas.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.primary">
      <element name="primary">
        <ref name="db.primary.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>secondary</db:refname>
    <db:refpurpose>A secondary word or phrase in an index term</db:refpurpose>
    <define name="db.secondary.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.secondary.attlist">
      <interleave>
        <optional>
          <ref name="db.secondary.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.sortas.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.secondary">
      <element name="secondary">
        <ref name="db.secondary.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>tertiary</db:refname>
    <db:refpurpose>A tertiary word or phrase in an index term</db:refpurpose>
    <define name="db.tertiary.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.tertiary.attlist">
      <interleave>
        <optional>
          <ref name="db.tertiary.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.sortas.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.tertiary">
      <element name="tertiary">
        <ref name="db.tertiary.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>see</db:refname>
    <db:refpurpose>Part of an index term directing the reader instead to another entry in the index</db:refpurpose>
    <define name="db.see.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.see.attlist">
      <interleave>
        <optional>
          <ref name="db.see.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
      </interleave>
    </define>
    <define name="db.see">
      <element name="see">
        <ref name="db.see.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>seealso</db:refname>
    <db:refpurpose>Part of an index term directing the reader also to another entry in the index</db:refpurpose>
    <define name="db.seealso.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.seealso.attlist">
      <interleave>
        <optional>
          <ref name="db.seealso.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
      </interleave>
    </define>
    <define name="db.seealso">
      <element name="seealso">
        <ref name="db.seealso.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>index</db:refname>
    <db:refpurpose>An index to a book or part of a book</db:refpurpose>
    <define name="db.index.status.attribute">
      <ref name="db.status.attribute"/>
    </define>
    <define name="db.index.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.index.attlist">
      <interleave>
        <optional>
          <ref name="db.index.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.label.attribute"/>
        </optional>
        <optional>
          <ref name="db.index.status.attribute"/>
        </optional>
        <optional>
          <ref name="db.index.type.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.index.info">
      <ref name="db._info"/>
    </define>
    <!--
      Yes, db.indexdiv* and db.indexentry*; that way an <index/> is valid.
      Authors can use an empty index to indicate where a generated index should
      appear.
    -->
    <define name="db.index">
      <element name="index">
        <ref name="db.index.attlist"/>
        <ref name="db.index.info"/>
        <zeroOrMore>
          <ref name="db.all.blocks"/>
        </zeroOrMore>
        <choice>
          <zeroOrMore>
            <ref name="db.indexdiv"/>
          </zeroOrMore>
          <zeroOrMore>
            <ref name="db.indexentry"/>
          </zeroOrMore>
          <ref name="db.segmentedlist"/>
        </choice>
      </element>
    </define>
  </div>
  <!--  ====================================================================== -->
  <div>
    <db:refname>setindex</db:refname>
    <db:refpurpose>An index to a set of books</db:refpurpose>
    <define name="db.setindex.status.attribute">
      <ref name="db.status.attribute"/>
    </define>
    <define name="db.setindex.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.setindex.attlist">
      <interleave>
        <optional>
          <ref name="db.setindex.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.label.attribute"/>
        </optional>
        <optional>
          <ref name="db.setindex.status.attribute"/>
        </optional>
        <optional>
          <ref name="db.index.type.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.setindex.info">
      <ref name="db._info"/>
    </define>
    <define name="db.setindex">
      <element name="setindex">
        <ref name="db.setindex.attlist"/>
        <ref name="db.setindex.info"/>
        <zeroOrMore>
          <ref name="db.all.blocks"/>
        </zeroOrMore>
        <choice>
          <zeroOrMore>
            <ref name="db.indexdiv"/>
          </zeroOrMore>
          <zeroOrMore>
            <ref name="db.indexentry"/>
          </zeroOrMore>
        </choice>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>indexdiv</db:refname>
    <db:refpurpose>A division in an index</db:refpurpose>
    <define name="db.indexdiv.status.attribute">
      <ref name="db.status.attribute"/>
    </define>
    <define name="db.indexdiv.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.indexdiv.attlist">
      <interleave>
        <optional>
          <ref name="db.indexdiv.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.label.attribute"/>
        </optional>
        <optional>
          <ref name="db.indexdiv.status.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.indexdiv.info">
      <ref name="db._info.title.req"/>
    </define>
    <define name="db.indexdiv">
      <element name="indexdiv">
        <ref name="db.indexdiv.attlist"/>
        <ref name="db.indexdiv.info"/>
        <zeroOrMore>
          <ref name="db.all.blocks"/>
        </zeroOrMore>
        <choice>
          <oneOrMore>
            <ref name="db.indexentry"/>
          </oneOrMore>
          <ref name="db.segmentedlist"/>
        </choice>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>indexentry</db:refname>
    <db:refpurpose>An entry in an index</db:refpurpose>
    <define name="db.indexentry.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.indexentry.attlist">
      <interleave>
        <optional>
          <ref name="db.indexentry.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
      </interleave>
    </define>
    <define name="db.indexentry">
      <element name="indexentry">
        <ref name="db.indexentry.attlist"/>
        <ref name="db.primaryie"/>
        <zeroOrMore>
          <choice>
            <ref name="db.seeie"/>
            <ref name="db.seealsoie"/>
          </choice>
        </zeroOrMore>
        <zeroOrMore>
          <ref name="db.secondaryie"/>
          <zeroOrMore>
            <choice>
              <ref name="db.seeie"/>
              <ref name="db.seealsoie"/>
              <ref name="db.tertiaryie"/>
            </choice>
          </zeroOrMore>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>primaryie</db:refname>
    <db:refpurpose>A primary term in an index entry, not in the text</db:refpurpose>
    <define name="db.primaryie.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.primaryie.attlist">
      <interleave>
        <optional>
          <ref name="db.primaryie.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <optional>
          <ref name="db.linkends.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.primaryie">
      <element name="primaryie">
        <ref name="db.primaryie.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>secondaryie</db:refname>
    <db:refpurpose>A secondary term in an index entry, rather than in the text</db:refpurpose>
    <define name="db.secondaryie.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.secondaryie.attlist">
      <interleave>
        <optional>
          <ref name="db.secondaryie.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <optional>
          <ref name="db.linkends.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.secondaryie">
      <element name="secondaryie">
        <ref name="db.secondaryie.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>tertiaryie</db:refname>
    <db:refpurpose>A tertiary term in an index entry, rather than in the text</db:refpurpose>
    <define name="db.tertiaryie.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.tertiaryie.attlist">
      <interleave>
        <optional>
          <ref name="db.tertiaryie.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <optional>
          <ref name="db.linkends.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.tertiaryie">
      <element name="tertiaryie">
        <ref name="db.tertiaryie.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>seeie</db:refname>
    <db:refpurpose>A <db:quote>See</db:quote>
entry in an index, rather than in the text</db:refpurpose>
    <define name="db.seeie.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.seeie.attlist">
      <interleave>
        <optional>
          <ref name="db.seeie.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <optional>
          <ref name="db.linkend.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.seeie">
      <element name="seeie">
        <ref name="db.seeie.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>seealsoie</db:refname>
    <db:refpurpose>A <db:quote>See also</db:quote>
 entry in an index, rather than in the text</db:refpurpose>
    <define name="db.seealsoie.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.seealsoie.attlist">
      <interleave>
        <optional>
          <ref name="db.seealsoie.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <optional>
          <ref name="db.linkends.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.seealsoie">
      <element name="seealsoie">
        <ref name="db.seealsoie.attlist"/>
        <zeroOrMore>
          <ref name="db.all.inlines"/>
        </zeroOrMore>
      </element>
    </define>
  </div>
</grammar>
