<?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="graph">
    <element>
      <name ns="">graph</name>
      <ref name="attlist.graph"/>
      <zeroOrMore>
        <ref name="x"/>
      </zeroOrMore>
      <zeroOrMore>
        <ref name="y"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="attlist.graph" combine="interleave">
    <optional>
      <attribute a:defaultValue="vbar">
        <name ns="">type</name>
        <choice>
          <value>vbar</value>
          <value>hbar</value>
          <value>line</value>
          <value>pie</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <define name="attlist.graph" combine="interleave">
    <optional>
      <attribute>
        <name ns="">background</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.graph" combine="interleave">
    <optional>
      <attribute>
        <name ns="">color</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.graph" combine="interleave">
    <optional>
      <attribute a:defaultValue="1">
        <name ns="">legend</name>
        <choice>
          <value>0</value>
          <value>1</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <define name="x">
    <element>
      <name ns="">x</name>
      <ref name="attlist.x"/>
      <ref name="field"/>
    </element>
  </define>
  <define name="attlist.x" combine="interleave">
    <empty/>
  </define>
  <define name="y">
    <element>
      <name ns="">y</name>
      <ref name="attlist.y"/>
      <oneOrMore>
        <ref name="field"/>
      </oneOrMore>
    </element>
  </define>
  <define name="attlist.y" combine="interleave">
    <empty/>
  </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="attlist.field" combine="interleave">
    <optional>
      <attribute>
        <name ns="">string</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.field" combine="interleave">
    <optional>
      <attribute>
        <name ns="">key</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.field" combine="interleave">
    <optional>
      <attribute>
        <name ns="">domain</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.field" combine="interleave">
    <optional>
      <attribute>
        <name ns="">fill</name>
        <choice>
          <value>0</value>
          <value>1</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <define name="attlist.field" combine="interleave">
    <optional>
      <attribute>
        <name ns="">empty</name>
        <choice>
          <value>0</value>
          <value>1</value>
        </choice>
      </attribute>
    </optional>
  </define>
  <define name="attlist.field" combine="interleave">
    <optional>
      <attribute>
        <name ns="">color</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.field" combine="interleave">
    <optional>
      <attribute>
        <name ns="">timedelta</name>
        <text/>
      </attribute>
    </optional>
  </define>
  <define name="attlist.field" combine="interleave">
    <optional>
      <attribute a:defaultValue="linear">
        <name ns="">interpolation</name>
        <choice>
          <value>constant-left</value>
          <value>constant-right</value>
          <value>constant-center</value>
          <value>linear</value>
        </choice>
      </attribute>
    </optional>
  </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="graph"/>
          <ref name="x"/>
          <ref name="y"/>
          <ref name="field"/>
        </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="graph"/>
    </choice>
  </start>
</grammar>
