<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="http://www.w3.org/1999/xhtml" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://www.w3.org/1999/xhtml">

  <xs:annotation>
    <xs:documentation>
      This is the Ruby module for XHTML
      $Id: xhtml-ruby-1.xsd,v 1.3 2006/05/11 14:01:28 radu_coravu Exp $
    </xs:documentation>
    <xs:documentation source="xhtml-copyright-1.xsd"/>
  </xs:annotation>

  <xs:annotation>
    <xs:documentation>
      "Ruby" are short runs of text alongside the base text, typically
      used in East Asian documents to indicate pronunciation or to
      provide a short annotation. The full specification for Ruby is here:
      
        http://www.w3.org/TR/2001/REC-ruby-20010531/
      
      This module defines "Ruby " or "complex Ruby" as described
      in the specification:
      
        http://www.w3.org/TR/2001/REC-ruby-20010531/#complex
    
      Simple or Basic Ruby are defined in a separate module.
      
      This module declares the elements and their attributes used to
      support complex ruby annotation markup. Elements defined here
            * ruby, rbc, rtc, rb, rt, rp
      
      This module expects the document model to define the
      following content models
        + InlNoRuby.mix                 
    </xs:documentation>
    <xs:documentation source="http://www.w3.org/TR/2001/REC-ruby-20010531/"/>    
  </xs:annotation>

  
  <xs:group name="ruby.content.simple">
    <xs:sequence>
      <xs:element ref="rb"/>
      <xs:choice>
        <xs:element ref="rt"/>
        <xs:sequence>
          <xs:element ref="rp"/>
          <xs:element ref="rt"/>
          <xs:element ref="rp"/>
        </xs:sequence>
      </xs:choice>
    </xs:sequence>
  </xs:group>

  <xs:group name="ruby.content.complex">
    <xs:sequence>
      <xs:element ref="rbc"/>
      <xs:element ref="rtc" maxOccurs="2"/>
    </xs:sequence>
  </xs:group>

  <!--
   add to this group any common attributes for all Ruby elements
  -->
  <xs:attributeGroup name="ruby.common.attrib"/>
  
  <xs:group name="ruby.content">
    <xs:choice>
      <xs:group ref="ruby.content.simple"/>
      <xs:group ref="ruby.content.complex"/>
    </xs:choice>
  </xs:group>

  <xs:complexType name="ruby.type">
    <xs:group ref="ruby.content"/>
    <xs:attributeGroup ref="ruby.common.attrib"/>
  </xs:complexType>

  <xs:element name="ruby" type="ruby.type"><xs:annotation><xs:documentation>Ruby text is used to provide a short annotation of the associated base text. The ruby element is an inline (or text-level) element that serves as an overall container. It contains either the rb, rt and optional rp elements (simple ruby markup) or the rbc and rtc elements (complex ruby markup).</xs:documentation></xs:annotation></xs:element>

  <!--
   rbc (ruby base component) element 
  -->
  <xs:attributeGroup name="rbc.attlist">
    <xs:attributeGroup ref="ruby.common.attrib"/>
  </xs:attributeGroup>
  
  <xs:group name="rbc.content">
    <xs:sequence>
      <xs:element ref="rb"/>
    </xs:sequence>
  </xs:group>  

  <xs:complexType name="rbc.type">
    <xs:group ref="rbc.content"/>
    <xs:attributeGroup ref="rbc.attlist"/>
  </xs:complexType>

  <xs:element name="rbc" type="rbc.type"><xs:annotation><xs:documentation>The rbc (ruby base container) element serves as the container for rb elements in the case of complex ruby markup. Only one rbc element may appear inside a ruby element.</xs:documentation></xs:annotation></xs:element>

  <!--
   rtc (ruby text component) element
  -->
  <xs:attributeGroup name="rtc.attlist">
    <xs:attributeGroup ref="ruby.common.attrib"/>
  </xs:attributeGroup>
  
  <xs:group name="rtc.content">
    <xs:sequence>
      <xs:element ref="rt" maxOccurs="unbounded"/>
    </xs:sequence>  
  </xs:group>    

  <xs:complexType name="rtc.type">
    <xs:group ref="rt.content"/>  
    <xs:attributeGroup ref="rtc.attlist"/>
  </xs:complexType>

  <xs:element name="rtc" type="rtc.type"><xs:annotation><xs:documentation>The rtc (ruby text container) element serves as the container for rt elements in the case of complex ruby markup. One or two rtc elements may appear inside a ruby element to associate ruby texts with a single base text, represented by an rbc element. More than two rtc elements MUST NOT appear inside a ruby element.</xs:documentation></xs:annotation></xs:element>

  <!--
   rb (ruby base) element 
  -->
  <xs:attributeGroup name="rb.attlist">
    <xs:attributeGroup ref="ruby.common.attrib"/>
  </xs:attributeGroup>

  <xs:group name="rb.content">
    <xs:sequence>
       <xs:group ref="InlNoRuby.mix" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:group>      

  <xs:complexType name="rb.type" mixed="true">
    <xs:group ref="rb.content"/>
    <xs:attributeGroup ref="rb.attlist"/>
  </xs:complexType>
    
  <xs:element name="rb" type="rb.type"><xs:annotation><xs:documentation>The rb (ruby base) element serves to markup the base text. For simple ruby markup, only one rb element may appear. For complex ruby markup, multiple rb elements may appear inside an rbc element. Each rb element is associated with a corresponding rt element, for fine-grained control of ruby presentation.</xs:documentation></xs:annotation></xs:element>

  <!--
   rt (ruby text) element 
  -->
  <xs:attributeGroup name="rt.attlist">
    <xs:attributeGroup ref="ruby.common.attrib"/>
    <xs:attribute name="rbspan" type="Number" default="1"/>
  </xs:attributeGroup>

  <xs:group name="rt.content">
    <xs:sequence>
       <xs:group ref="InlNoRuby.mix" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
  </xs:group>      
  
  <xs:complexType name="rt.type" mixed="true">
    <xs:group ref="rt.content"/>  
    <xs:attributeGroup ref="rt.attlist"/>
  </xs:complexType>

  <xs:element name="rt" type="rt.type"><xs:annotation><xs:documentation>The rt element is the markup for ruby text. For simple ruby markup, only one rt element may appear. For complex ruby markup, multiple rt elements may appear inside an rtc element, and each rt element contains the ruby text for the relevant base text, represented by the corresponding rb element.</xs:documentation></xs:annotation></xs:element>

  <!-- rp (ruby parenthesis) element  -->
  <xs:attributeGroup name="rp.attlist">
    <xs:attributeGroup ref="ruby.common.attrib"/>
  </xs:attributeGroup>
  
  <xs:group name="rp.content">
    <xs:sequence/>
  </xs:group>      
  

  <xs:complexType name="rp.type" mixed="true">
    <xs:group ref="rp.content"/>
    <xs:attributeGroup ref="rp.attlist"/>
  </xs:complexType>

  <xs:element name="rp" type="rp.type"><xs:annotation><xs:documentation>The rp element can be used in the case of simple ruby markup to specify characters that can denote the beginning and end of ruby text when user agents do not have other ways to present ruby text distinctively from the base text. Parentheses (or similar characters) can provide an acceptable fallback. In this situation, ruby text will only degrade to be rendered inline and enclosed in the fallback parentheses. This is the least inappropriate rendering under the condition that only inline rendering is available. The rp element cannot be used with complex ruby markup.</xs:documentation></xs:annotation></xs:element>

</xs:schema>