OpenMath 2 Table of Contents

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

Appendix C
Restricting the OpenMath Schema (Non-Normative)

Relax NG allows one to state constraints such as if the cd attribute of OMS is arith1 then the name attribute must be one of lcm, gcd, plus etc. Thus it is easy to use a stylesheet to generate for any given CD, a Relax NG schema that expresses the constraint that an OMS naming that CD must only use symbols defined in the specified dictionary. Similarly it is possible to use the role information contained in the CD to restrict which symbols can be the first child of an OMBIND or the odd-numbered children of an OMATP.

The modularisation mechanisms of Relax NG then allow one to include these schema for all the CDs that you want to allow and, for example, to replace the regexp-based validation of the OMS attributes by explicit lists of allowed CD names, and for each CD Name, a list of allowed symbol names.

For example, a CD-specific Relax NG Schema for the arith1 CD shown in Appendix A.2 would look like:

<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="">
  <define name="cd.attlist.OMS" combine="choice">
    <attribute name="cd">
      <value type="string">arith1</value>
    </attribute>
    <attribute name="name">
      <choice>
        <value type="string">lcm</value>
        <value type="string">gcd</value>
        <value type="string">plus</value>
        <value type="string">unary_minus</value>
        <value type="string">minus</value>
        <value type="string">times</value>
        <value type="string">divide</value>
        <value type="string">power</value>
        <value type="string">abs</value>
        <value type="string">root</value>
        <value type="string">sum</value>
        <value type="string">product</value>
      </choice>
    </attribute>
  </define>
</grammar>
or, using the Relax NG compact syntax:
  cd.attlist.OMS |= 
  attribute cd {string "arith1" },
  attribute name {
  string "lcm" |
  string "gcd" |
  string "plus" |
  string "unary_minus" |
  string "minus" |
  string "times" |
  string "divide" |
  string "power" |
  string "abs" |
  string "root" |
  string "sum" |
  string "product" }

To build a schema that allows only symbols from arith1 we just need to include the OpenMath schema described in Section 3.1.1, override the attribute declarations for OMS, and then include the schema for arith1. For example:

    <?xml version="1.0" encoding="UTF-8"?>
    <grammar xmlns="http://relaxng.org/ns/structure/1.0">
      <include href="openmath.rng">
        <define name="attlist.OMS">
          <ref name="cd.attlist.OMS"/>
        </define>
      </include>
      <include href="arith1.rng"/>
    </grammar>
  
or, in the compact syntax:
    include "openmath.rnc" {
    attlist.OMS = cd.attlist.OMS}
    
    include "arith1.rnc"
  
Using this approach it is possible to include as many files as required.

OpenMath 2 Table of Contents

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