<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <include href="common.rng"/>
  <start combine="choice">
    <ref name="Workflow"/>
  </start>
  <define name="Workflow">
    <element name="workflow">
      <ref name="Service"/>
    </element>
  </define>
  <define name="Implementation" combine="interleave">
    <ref name="Flow"/>
  </define>
  <!-- Mobyle Dataflow Definition -->
  <define name="Flow">
    <element name="flow">
      <oneOrMore>
        <ref name="Task"/>
      </oneOrMore>
      <zeroOrMore>
        <ref name="Link"/>
      </zeroOrMore>
    </element>
  </define>
  <define name="Task">
    <element name="task">
      <interleave>
        <attribute name="id">
          <data type="string"/>
        </attribute>
        <attribute name="service">
          <data type="string"/>
        </attribute>
        <optional>
          <attribute name="service_url">
            <data type="string"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="server">
            <data type="string"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="suspend">
            <data type="boolean"/>
          </attribute>
        </optional>
        <optional>
          <element name="description">
            <text/>
          </element>
        </optional>
        <optional>
          <element name="position">
            <text/>
          </element>
        </optional>
        <zeroOrMore>
          <element name="inputValue">
            <attribute name="name"/>
            <choice>
              <attribute name="reference">
                <data type="anyURI"/>
              </attribute>
              <text/>
            </choice>
          </element>
        </zeroOrMore>
      </interleave>
    </element>
  </define>
  <define name="Link">
    <element name="link">
      <interleave>
        <optional>
          <attribute name="id">
            <data type="string"/>
          </attribute>
        </optional>
        <optional>
          <attribute name="fromTask">
            <data type="string"/>
          </attribute>
        </optional>
        <attribute name="fromParameter">
          <data type="NMTOKEN"/>
        </attribute>
        <optional>
          <attribute name="toTask">
            <data type="string"/>
          </attribute>
        </optional>
        <attribute name="toParameter">
          <data type="NMTOKEN"/>
        </attribute>
      </interleave>
    </element>
  </define>
  <define name="InterfaceType" combine="interleave">
    <choice>
      <value>form</value>
      <value>job_input</value>
      <value>job_output</value>
      <value>graph</value>
    </choice>
  </define>
</grammar>
