<?xml version="1.0"?>
<grammar
    xmlns="http://relaxng.org/ns/structure/1.0"
    xmlns:mal="http://projectmallard.org/1.0/"
    xmlns:cache="http://projectmallard.org/cache/1.0/"
    ns="http://projectmallard.org/1.0/">

<start>
  <ref name="cache_cache"/>
</start>

<define name="cache_cache">
  <element name="cache:cache">
    <optional>
      <attribute name="version">
        <text/>
      </attribute>
    </optional>
    <oneOrMore>
      <ref name="cache_page"/>
    </oneOrMore>
  </element>
</define>

<define name="cache_page">
  <element name="page">
    <ref name="cache_page_attr"/>
    <ref name="mal_page_attr"/>
    <optional>
      <ref name="mal_info"/>
    </optional>
    <ref name="mal_block_title"/>
    <optional>
      <ref name="mal_block_subtitle"/>
    </optional>
    <zeroOrMore>
      <ref name="cache_section"/>
    </zeroOrMore>
  </element>
</define>

<define name="cache_page_attr">
  <group>
    <attribute name="cache:href">
      <text/>
    </attribute>
  </group>
</define>

<define name="mal_page_id" combine="choice">
  <attribute name="id">
    <text/>
  </attribute>
</define>

<define name="cache_section">
  <element name="section">
    <ref name="cache_section_attr"/>
    <ref name="mal_section_attr"/>
    <optional>
      <ref name="mal_info"/>
    </optional>
    <ref name="mal_block_title"/>
    <optional>
      <ref name="mal_block_subtitle"/>
    </optional>
    <zeroOrMore>
      <ref name="cache_section"/>
    </zeroOrMore>
  </element>
</define>

<define name="cache_section_attr">
  <empty/>
</define>

<define name="mal_section_id" combine="choice">
  <attribute name="id">
    <text/>
  </attribute>
</define>

</grammar>
