<?xml encoding="UTF-8"?>

<!-- RELAX NG Schema for OpenMath 2 -->

<!-- default namespace om = "http://www.openmath.org/OpenMath" -->

<!-- OM2: allow OMR -->

<!ENTITY % omel "OMS|OMV|OMI|OMB|OMSTR|OMF|OMA|OMBIND|OME|OMATTR|OMR">

<!ENTITY % attvar "OMATTR">

<!-- things which can be variables -->

<!ENTITY % omvar "OMV|%attvar;">

<!-- OM2: common attributes -->

<!ENTITY % cdbase "
  cdbase CDATA #IMPLIED">

<!ENTITY % common.attributes "
  id ID #IMPLIED">

<!ENTITY % compound.attributes "
  %common.attributes;
  %cdbase;">

<!ENTITY % attlist.OMS "
  name NMTOKEN #REQUIRED
  cd NMTOKEN #REQUIRED
  %cdbase;">

<!-- symbol -->

<!ELEMENT OMS EMPTY>
<!ATTLIST OMS
  %common.attributes;
  %attlist.OMS;>

<!ENTITY % attlist.OMV "
  name NMTOKEN #REQUIRED">

<!-- variable -->

<!ELEMENT OMV (%omel;)?>
<!ATTLIST OMV
  %common.attributes;
  %attlist.OMV;>

<!-- integer -->

<!ELEMENT OMI (#PCDATA)>
<!ATTLIST OMI
  %common.attributes;>

<!-- byte array -->

<!ELEMENT OMB (#PCDATA)>
<!ATTLIST OMB
  %common.attributes;>

<!-- string -->

<!ELEMENT OMSTR (#PCDATA)>
<!ATTLIST OMSTR
  %common.attributes;>

<!ENTITY % attlist.OMF "
  dec CDATA #IMPLIED
  hex CDATA #IMPLIED">

<!-- floating point -->

<!ELEMENT OMF EMPTY>
<!ATTLIST OMF
  %common.attributes;
  %attlist.OMF;>

<!-- apply constructor -->

<!ELEMENT OMA (%omel;)+>
<!ATTLIST OMA
  %compound.attributes;>

<!-- binding constructor and variable -->

<!ELEMENT OMBIND ((%omel;),OMBVAR,(%omel;))>
<!ATTLIST OMBIND
  %compound.attributes;>

<!ELEMENT OMBVAR (%omvar;)+>
<!ATTLIST OMBVAR
  %common.attributes;>

<!-- error -->

<!ELEMENT OME (OMS,(%omel;)*)>
<!ATTLIST OME
  %common.attributes;>

<!-- attribution constructor and attribute pair constructor -->

<!ELEMENT OMATTR (OMATP,(%omel;))>
<!ATTLIST OMATTR
  %compound.attributes;>

<!-- OM2: allow OMFOREIGN  -->

<!ELEMENT OMATP (OMS,(%omel;|OMFOREIGN))+>
<!ATTLIST OMATP
  %compound.attributes;>

<!-- OM2: OMFOREIGN  -->

<!ELEMENT OMFOREIGN ANY>
<!ATTLIST OMFOREIGN
  %compound.attributes;>

<!-- Any elements not in the om namespace (valid om is allowed as a descendant) -->

<!-- OM object constructor -->

<!ELEMENT OMOBJ (%omel;)>
<!ATTLIST OMOBJ
  %compound.attributes;>

<!ENTITY % attlist.OMOBJ "
  version (1.0|1.2|2.0) #REQUIRED">

<!ENTITY % attlist.OMR "
  xlink:href CDATA #REQUIRED
  xlink:type (simple) #REQUIRED
  xlink:show (embed) #REQUIRED">

<!-- OM2: OMR -->

<!ELEMENT OMR EMPTY>
<!ATTLIST OMR
  xmlns:xlink CDATA #FIXED 'http://www.w3.org/1999/xlink'
  %common.attributes;
  %attlist.OMR;>
