<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
         xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0">
  <define name="calendar">
    <element>
      <name ns="">calendar</name>
      <ref name="attlist.calendar"/>
      <zeroOrMore>
        <ref name="field"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="attlist.calendar" combine="interleave">
    <attribute>
      <name ns="">dtstart</name>
      <text/>
    </attribute>
  </define>
  <define name="attlist.calendar" combine="interleave">
    <optional>
      <attribute>
        <name ns="">dtend</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.calendar" combine="interleave">
    <optional>
      <attribute>
        <name ns="">mode</name>
        <choice>
          <value>day</value>
          <value>week</value>
          <value>month</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <define name="attlist.calendar" combine="interleave">
    <optional>
      <attribute a:defaultValue="1">
        <name ns="">editable</name>
        <choice>
          <value>0</value>
          <value>1</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <define name="attlist.calendar" combine="interleave">
    <optional>
      <attribute>
        <name ns="">color</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.calendar" combine="interleave">
    <optional>
      <attribute>
        <name ns="">background_color</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.calendar" combine="interleave">
    <optional>
      <attribute>
        <name ns="">width</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.calendar" combine="interleave">
    <optional>
      <attribute>
        <name ns="">height</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="field">
    <element>
      <name ns="">field</name>
      <ref name="attlist.field"/>
      <empty/>
    </element>
  </define>
  <define name="attlist.field" combine="interleave">
    <attribute>
      <name ns="">name</name>
      <text/>
    </attribute>
  </define>
  <define name="data">
    <element>
      <name ns="">data</name>
      <ref name="attlist.data"/>
      <zeroOrMore>
        <ref name="xpath"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="attlist.data" combine="interleave">
    <empty/>
  </define>
  <define name="xpath">
    <element>
      <name ns="">xpath</name>
      <ref name="attlist.xpath"/>
      <zeroOrMore>
        <choice>
          <ref name="field"/>
          <ref name="calendar"/>
        </choice>
      </zeroOrMore>
    </element>
  </define>
  <define name="attlist.xpath" combine="interleave">
    <attribute>
      <name ns="">expr</name>
      <text/>
    </attribute>
  </define>
  <define name="attlist.xpath" combine="interleave">
    <optional>
      <attribute a:defaultValue="inside">
        <name ns="">position</name>
        <choice>
          <value>inside</value>
          <value>replace</value>
          <value>replace_attributes</value>
          <value>after</value>
          <value>before</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <start>
    <choice>
      <ref name="data"/>
      <ref name="calendar"/>
    </choice>
  </start>
</grammar>
