<?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: math.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:rng="http://relaxng.org/ns/structure/1.0" xmlns:ctrl="http://nwalsh.com/xmlns/schema-control/" xmlns="http://relaxng.org/ns/structure/1.0">
  <start combine="choice">
    <choice>
      <ref name="db.equation"/>
      <ref name="db.informalequation"/>
    </choice>
  </start>
  <define name="db.formal.blocks" combine="choice">
    <ref name="db.equation"/>
  </define>
  <define name="db.informal.blocks" combine="choice">
    <ref name="db.informalequation"/>
  </define>
  <define name="db.math.inlines">
    <ref name="db.inlineequation"/>
  </define>
  <define name="db.domain.inlines" combine="choice">
    <ref name="db.math.inlines"/>
  </define>
  <define name="db.initializer.inlines" combine="choice">
    <ref name="db.mathphrase"/>
  </define>
  <!-- ====================================================================== -->
  <define name="db.equation.content">
    <choice>
      <oneOrMore>
        <ref name="db.mediaobject"/>
      </oneOrMore>
      <oneOrMore>
        <ref name="db.mathphrase"/>
      </oneOrMore>
    </choice>
  </define>
  <define name="db.inlineequation.content">
    <choice>
      <oneOrMore>
        <ref name="db.inlinemediaobject"/>
      </oneOrMore>
      <oneOrMore>
        <ref name="db.mathphrase"/>
      </oneOrMore>
    </choice>
  </define>
  <!-- ====================================================================== -->
  <div>
    <db:refname>equation</db:refname>
    <db:refpurpose>A displayed mathematical equation</db:refpurpose>
    <define name="db.equation.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.equation.label.attribute">
      <ref name="db.label.attribute"/>
    </define>
    <define name="db.equation.attlist">
      <interleave>
        <optional>
          <ref name="db.equation.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
        <optional>
          <ref name="db.equation.label.attribute"/>
        </optional>
        <optional>
          <ref name="db.pgwide.attribute"/>
        </optional>
        <optional>
          <ref name="db.floatstyle.attribute"/>
        </optional>
      </interleave>
    </define>
    <define name="db.equation.info">
      <ref name="db._info.title.only"/>
    </define>
    <define name="db.equation">
      <element name="equation">
        <ref name="db.equation.attlist"/>
        <ref name="db.equation.info"/>
        <optional>
          <ref name="db.alt"/>
        </optional>
        <ref name="db.equation.content"/>
        <optional>
          <ref name="db.caption"/>
        </optional>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>informalequation</db:refname>
    <db:refpurpose>A displayed mathematical equation without a title</db:refpurpose>
    <define name="db.informalequation.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.informalequation.attlist">
      <interleave>
        <optional>
          <ref name="db.informalequation.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
      </interleave>
    </define>
    <define name="db.informalequation.info">
      <ref name="db._info.title.forbidden"/>
    </define>
    <define name="db.informalequation">
      <element name="informalequation">
        <ref name="db.informalequation.attlist"/>
        <ref name="db.informalequation.info"/>
        <optional>
          <ref name="db.alt"/>
        </optional>
        <ref name="db.equation.content"/>
        <optional>
          <ref name="db.caption"/>
        </optional>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>inlineequation</db:refname>
    <db:refpurpose>A mathematical equation or expression occurring inline</db:refpurpose>
    <define name="db.inlineequation.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.inlineequation.attlist">
      <interleave>
        <optional>
          <ref name="db.inlineequation.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
      </interleave>
    </define>
    <define name="db.inlineequation">
      <element name="inlineequation">
        <ref name="db.inlineequation.attlist"/>
        <optional>
          <ref name="db.alt"/>
        </optional>
        <ref name="db.inlineequation.content"/>
      </element>
    </define>
  </div>
  <!-- ====================================================================== -->
  <div>
    <db:refname>mathphrase</db:refname>
    <db:refpurpose>A mathematical phrase that can be represented with ordinary text and a small amount of markup</db:refpurpose>
    <define name="db.mathphrase.role.attribute">
      <attribute name="role"/>
    </define>
    <define name="db.mathphrase.attlist">
      <interleave>
        <optional>
          <ref name="db.mathphrase.role.attribute"/>
        </optional>
        <ref name="db.common.attributes"/>
        <ref name="db.common.linking.attributes"/>
      </interleave>
    </define>
    <define name="db.mathphrase">
      <element name="mathphrase">
        <ref name="db.mathphrase.attlist"/>
        <zeroOrMore>
          <choice>
            <ref name="db._text"/>
            <ref name="db.ubiq.inlines"/>
            <ref name="db._emphasis"/>
          </choice>
        </zeroOrMore>
      </element>
    </define>
  </div>
</grammar>
