OpenMath 2 Table of Contents

Previous: A CD Files
This: B OpenMath Schema in Relax NG XML Syntax (Normative)
Next: C Restricting the OpenMath Schema (Non-Normative)

Appendix B
OpenMath Schema in Relax NG XML Syntax (Normative)

This is the Relax NG Schema described in Section 3.1 expressed according to the Relax NG XML Syntax.

    

<grammar
 xmlns="http://relaxng.org/ns/structure/1.0" ns="http://www.openmath.org/OpenMath" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <ref name="OMOBJ"/>
  </start>
  <!-- OpenMath object constructor -->
  <define name="OMOBJ">
    <element name="OMOBJ">
      <ref name="compound.attributes"/>
      <optional>
        <attribute name="version">
          <data type="string"/>
        </attribute>
      </optional>
      <ref name="omel"/>
    </element>
  </define>
  <!-- Elements which can appear inside an OpenMath object -->
  <define name="omel">
    <choice>
      <ref name="OMS"/>
      <ref name="OMV"/>
      <ref name="OMI"/>
      <ref name="OMB"/>
      <ref name="OMSTR"/>
      <ref name="OMF"/>
      <ref name="OMA"/>
      <ref name="OMBIND"/>
      <ref name="OME"/>
      <ref name="OMATTR"/>
      <ref name="OMR"/>
    </choice>
  </define>
  <!-- things which can be variables -->
  <define name="omvar">
    <choice>
      <ref name="OMV"/>
      <ref name="attvar"/>
    </choice>
  </define>
  <define name="attvar">
    <element name="OMATTR">
      <ref name="common.attributes"/>
      <group>
        <ref name="OMATP"/>
        <choice>
          <ref name="OMV"/>
          <ref name="attvar"/>
        </choice>
      </group>
    </element>
  </define>
  <define name="cdbase">
    <optional>
      <attribute name="cdbase">
        <data type="anyURI"/>
      </attribute>
    </optional>
  </define>
  <!-- attributes common to all elements -->
  <define name="common.attributes">
    <optional>
      <attribute name="id">
        <data type="ID"/>
      </attribute>
    </optional>
  </define>
  <!-- attributes common to all elements that construct compount OM objects. -->
  <define name="compound.attributes">
    <ref name="common.attributes"/>
    <ref name="cdbase"/>
  </define>
  <!-- symbol -->
  <define name="OMS">
    <element name="OMS">
      <ref name="common.attributes"/>
      <attribute name="name">
        <data type="NCName"/>
      </attribute>
      <attribute name="cd">
        <data type="NCName"/>
      </attribute>
      <ref name="cdbase"/>
    </element>
  </define>
  <!-- variable -->
  <define name="OMV">
    <element name="OMV">
      <ref name="common.attributes"/>
      <attribute name="name">
        <data type="NCName"/>
      </attribute>
    </element>
  </define>
  <!-- integer -->
  <define name="OMI">
    <element name="OMI">
      <ref name="common.attributes"/>
      <data type="string">
        <param name="pattern">\s*(-\s?)?[0-9]+(\s[0-9]+)*\s*</param>
      </data>
    </element>
  </define>
  <!-- byte array -->
  <define name="OMB">
    <element name="OMB">
      <ref name="common.attributes"/>
      <data type="base64Binary"/>
    </element>
  </define>
  <!-- string -->
  <define name="OMSTR">
    <element name="OMSTR">
      <ref name="common.attributes"/>
      <text/>
    </element>
  </define>
  <!-- IEEE floating point number -->
  <define name="OMF">
    <element name="OMF">
      <ref name="common.attributes"/>
      <choice>
        <attribute name="dec">
          <data type="double"/>
        </attribute>
        <attribute name="hex">
          <data type="string">
            <param name="pattern">[0-9A-F]+</param>
          </data>
        </attribute>
      </choice>
    </element>
  </define>
  <!-- apply constructor -->
  <define name="OMA">
    <element name="OMA">
      <ref name="compound.attributes"/>
      <oneOrMore>
        <ref name="omel"/>
      </oneOrMore>
    </element>
  </define>
  <!-- binding constructor -->
  <define name="OMBIND">
    <element name="OMBIND">
      <ref name="compound.attributes"/>
      <ref name="omel"/>
      <ref name="OMBVAR"/>
      <ref name="omel"/>
    </element>
  </define>
  <!-- variables used in binding constructor -->
  <define name="OMBVAR">
    <element name="OMBVAR">
      <ref name="common.attributes"/>
      <oneOrMore>
        <ref name="omvar"/>
      </oneOrMore>
    </element>
  </define>
  <!-- error constructor -->
  <define name="OME">
    <element name="OME">
      <ref name="common.attributes"/>
      <ref name="OMS"/>
      <zeroOrMore>
        <choice>
          <ref name="omel"/>
          <ref name="OMFOREIGN"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <!-- attribution constructor and attribute pair constructor -->
  <define name="OMATTR">
    <element name="OMATTR">
      <ref name="compound.attributes"/>
      <ref name="OMATP"/>
      <ref name="omel"/>
    </element>
  </define>
  <define name="OMATP">
    <element name="OMATP">
      <ref name="compound.attributes"/>
      <oneOrMore>
        <ref name="OMS"/>
        <choice>
          <ref name="omel"/>
          <ref name="OMFOREIGN"/>
        </choice>
      </oneOrMore>
    </element>
  </define>
  <!-- foreign constructor -->
  <define name="OMFOREIGN">
    <element name="OMFOREIGN">
      <ref name="compound.attributes"/>
      <optional>
        <attribute name="encoding">
          <data type="string"/>
        </attribute>
      </optional>
      <zeroOrMore>
        <choice>
          <ref name="omel"/>
          <ref name="notom"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <!--
    Any elements not in the om namespace
    (valid om is allowed as a descendant)
  -->
  <define name="notom">
    <choice>
      <element>
        <anyName>
          <except>
            <nsName/>
          </except>
        </anyName>
        <zeroOrMore>
          <attribute>
            <anyName/>
          </attribute>
        </zeroOrMore>
        <zeroOrMore>
          <choice>
            <ref name="omel"/>
            <ref name="notom"/>
          </choice>
        </zeroOrMore>
      </element>
      <text/>
    </choice>
  </define>
  <!-- reference constructor -->
  <define name="OMR">
    <element name="OMR">
      <ref name="common.attributes"/>
      <attribute name="href">
        <data type="anyURI"/>
      </attribute>
    </element>
  </define>
</grammar>

  
OpenMath 2 Table of Contents

Previous: A CD Files
This: B OpenMath Schema in Relax NG XML Syntax (Normative)
Next: C Restricting the OpenMath Schema (Non-Normative)