<?xml version="1.0" encoding="iso-8859-1"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">

<define name="ruby">
  <element name="ruby">
    <ref name="ruby.attlist"/>
    <choice>
      <group>
        <ref name="rb"/>
        <choice>
          <ref name="rt"/>
          <group>
            <ref name="rp"/>
            <ref name="rt"/>
            <ref name="rp"/>
          </group>
        </choice>
      </group>
      <group>
        <ref name="rbc"/>
        <ref name="rtc"/>
        <optional>
          <ref name="rtc"/>
        </optional>
      </group>
    </choice>
  </element>
</define>

<define name="ruby.attlist">
  <ref name="Common.attrib"/>
</define>

<define name="rbc">
  <element name="rbc">
    <ref name="rbc.attlist"/>
    <oneOrMore>
      <ref name="rb"/>
    </oneOrMore>
  </element>
</define>

<define name="rbc.attlist">
  <ref name="Common.attrib"/>
</define>

<define name="rtc">
  <element name="rtc">
    <ref name="rtc.attlist"/>
    <oneOrMore>
      <ref name="rt"/>
    </oneOrMore>
  </element>
</define>

<define name="rtc.attlist">
  <ref name="Common.attrib"/>
</define>

<define name="rb">
  <element name="rb">
    <ref name="rb.attlist"/>
    <ref name="Inline.model"/>
  </element>
</define>

<define name="rb.attlist">
  <ref name="Common.attrib"/>
</define>

<define name="rt">
  <element name="rt">
    <ref name="rt.attlist"/>
    <ref name="Inline.model"/>
  </element>
</define>

<define name="rt.attlist">
  <ref name="Common.attrib"/>
  <optional>
    <attribute name="rt">
      <ref name="Number.datatype"/>
    </attribute>
  </optional>
</define>

<define name="rp">
  <element name="rp">
    <ref name="rp.attlist"/>
    <text/>
  </element>
</define>

<define name="rp.attlist">
  <ref name="Common.attrib"/>
</define>

<define name="Inline.class" combine="choice">
  <ref name="ruby"/>
</define>

</grammar>