<?xml version="1.0" encoding="utf-8"?>

<workflow xmlns="http://eprints.org/ep3/workflow" xmlns:epc="http://eprints.org/ep3/control">

  <flow>

    <stage ref="type"/>
    <stage ref="files"/>
    <epc:if test="type = 'article'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'book_section'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'monograph'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'conference_item'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="event" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'book'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'thesis'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'patent'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'software'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'standalone_pres'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
    <epc:if test="type = 'other'">
      <stage ref="core" />
      <stage ref="pubinfo" />
      <stage ref="status" />
      <stage ref="abstract" />
      <stage ref="affiliations" />
      <stage ref="subjects" />
      <stage ref="notes" />
    </epc:if>
  </flow>

  <stage name="core">
    <epc:if test="type = 'article'">
      <component><field ref="title" /></component>
      <component><field ref="creators" /></component>
    </epc:if>
    <epc:if test="type = 'book_section'">
      <component><field ref="title" /></component>
      <component><field ref="creators" /></component>
      <component><field ref="editors" /></component>
    </epc:if>
    <epc:if test="type = 'monograph'">
      <component><field ref="title" /></component>
      <component><field ref="monograph_type" /></component>
      <component><field ref="creators" /></component>
    </epc:if>
    <epc:if test="type = 'conference_item'">
      <component><field ref="title" /></component>
      <component><field ref="pres_type" /></component>
      <component><field ref="creators" /></component>
    </epc:if>
    <epc:if test="type = 'book'">
      <component><field ref="title" /></component>
      <component><field ref="creators" /></component>
      <component><field ref="editors" /></component>
    </epc:if>
    <epc:if test="type = 'thesis'">
      <component><field ref="title" /></component>
      <component><field ref="thesis_type" /></component>
      <component><field ref="creators" /></component>
    </epc:if>
    <epc:if test="type = 'patent'">
      <component><field ref="title" /></component>
      <component><field ref="creators" /></component>
    </epc:if>
    <epc:if test="type = 'software'">
      <component><field ref="title" /></component>
      <component><field ref="creators" /></component>
    </epc:if>
    <epc:if test="type = 'standalone_pres'">
      <component><field ref="title" /></component>
      <component><field ref="pres_type" /></component>
      <component><field ref="creators" /></component>
    </epc:if>
    <epc:if test="type = 'other'">
      <component><field ref="title" /></component>
      <component><field ref="creators" /></component>
    </epc:if>
  </stage>

  <stage name="subjects">
    <epc:if test="type = 'article'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'book_section'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'monograph'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'conference_item'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'book'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'thesis'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'patent'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'software'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'standalone_pres'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
    <epc:if test="type = 'other'">
      <component type='Field::Subject'><field ref="subjects" /></component>
    </epc:if>
  </stage>

  <stage name="notes">
    <epc:if test="type = 'article'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'book_section'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'monograph'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'conference_item'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'book'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'thesis'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'patent'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'software'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'standalone_pres'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
    <epc:if test="type = 'other'">
      <component><field ref="note" /></component>
      <component><field ref="suggestions" /></component>
      <component><field ref="author_permission" /></component>
      <component><field ref="copyright_confirmed" /></component>
    </epc:if>
  </stage>

  <stage name="affiliations">
    <epc:if test="type = 'article'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'book_section'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'monograph'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'conference_item'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'book'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'thesis'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'patent'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'software'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'standalone_pres'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
    <epc:if test="type = 'other'">
      <component type='Field::Subject'><field ref="affiliations" /></component>
    </epc:if>
  </stage>

  <stage name="status">
    <epc:if test="type = 'article'">
      <component><field ref="ispublished" /></component>
      <component><field ref="refereed" /></component>
    </epc:if>
    <epc:if test="type = 'book_section'">
      <component><field ref="ispublished" /></component>
      <component><field ref="refereed" /></component>
    </epc:if>
    <epc:if test="type = 'monograph'">
      <component><field ref="ispublished" /></component>
    </epc:if>
    <epc:if test="type = 'conference_item'">
      <component><field ref="ispublished" /></component>
      <component><field ref="refereed" /></component>
    </epc:if>
    <epc:if test="type = 'book'">
      <component><field ref="ispublished" /></component>
      <component><field ref="refereed" /></component>
    </epc:if>
    <epc:if test="type = 'thesis'">
      <component><field ref="ispublished" /></component>
    </epc:if>
    <epc:if test="type = 'software'">
      <component><field ref="ispublished" /></component>
    </epc:if>
    <epc:if test="type = 'standalone_pres'">
      <component><field ref="ispublished" /></component>
      <component><field ref="refereed" /></component>
    </epc:if>
    <epc:if test="type = 'other'">
      <component><field ref="ispublished" /></component>
    </epc:if>
  </stage>

  <stage name="abstract">
    <epc:if test="type = 'article'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
    <epc:if test="type = 'book_section'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
    <epc:if test="type = 'monograph'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
    <epc:if test="type = 'conference_item'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
    <epc:if test="type = 'book'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
    <epc:if test="type = 'thesis'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
    <epc:if test="type = 'patent'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
    <epc:if test="type = 'software'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
    </epc:if>
    <epc:if test="type = 'standalone_pres'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
    <epc:if test="type = 'other'">
      <component><field ref="abstract" /></component>
      <component><field ref="keywords" /></component>
      <component><field ref="referencetext" /></component>
    </epc:if>
  </stage>

  <stage name="event">
    <epc:if test="type = 'conference_item'">
      <component><field ref="event_title" /></component>
      <component><field ref="event_type" /></component>
      <component><field ref="event_location" /></component>
      <component><field ref="event_dates" /></component>
    </epc:if>
  </stage>

  <stage name="pubinfo">
    <epc:if test="type = 'article'">
      <component><field ref="publication" /></component>
      <component><field ref="volume" /></component>
      <component><field ref="number" /></component>
      <component><field ref="pagerange" /></component>
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="id_number" /></component>
      <component><field ref="official_url" /></component>
      <component><field ref="issn" /></component>
    </epc:if>
    <epc:if test="type = 'book_section'">
      <component><field ref="pagerange" /></component>
      <component><field ref="book_title" /></component>
      <component><field ref="volume" /></component>
      <component><field ref="place_of_pub" /></component>
      <component><field ref="publisher" /></component>
      <component><field ref="pages" /></component>
      <component><field ref="id_number" /></component>
      <component><field ref="series" /></component>
      <component><field ref="number" /></component>
      <component><field ref="isbn" /></component>
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="official_url" /></component>
    </epc:if>
    <epc:if test="type = 'monograph'">
      <component><field ref="institution" /></component>
      <component><field ref="department" /></component>
      <component><field ref="place_of_pub" /></component>
      <component><field ref="publisher" /></component>
      <component><field ref="id_number" /></component>
      <component><field ref="pages" /></component>
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="official_url" /></component>
    </epc:if>
    <epc:if test="type = 'conference_item'">
      <component><field ref="pagerange" /></component>
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="official_url" /></component>
    </epc:if>
    <epc:if test="type = 'book'">
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="place_of_pub" /></component>
      <component><field ref="publisher" /></component>
      <component><field ref="pages" /></component>
      <component><field ref="series" /></component>
      <component><field ref="volume" /></component>
      <component><field ref="number" /></component>
      <component><field ref="isbn" /></component>
      <component><field ref="official_url" /></component>
    </epc:if>
    <epc:if test="type = 'thesis'">
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="official_url" /></component>
      <component><field ref="institution" /></component>
      <component><field ref="department" /></component>
      <component><field ref="pages" /></component>
    </epc:if>
    <epc:if test="type = 'patent'">
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="official_url" /></component>
      <component><field ref="patent_applicant" /></component>
      <component><field ref="id_number" /></component>
      <component><field ref="pages" /></component>
    </epc:if>
    <epc:if test="type = 'software'">
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="official_url" /></component>
      <component><field ref="place_of_pub" /></component>
      <component><field ref="publisher" /></component>
      <component><field ref="id_number" /></component>
    </epc:if>
    <epc:if test="type = 'standalone_pres'">
      <component><field ref="institution" /></component>
      <component><field ref="department" /></component>
      <component><field ref="place_of_pub" /></component>
      <component><field ref="series" /></component>
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="pages" /></component>
      <component><field ref="official_url" /></component>
    </epc:if>
    <epc:if test="type = 'other'">
      <component><field ref="date" /></component>
      <component><field ref="date_type" /></component>
      <component><field ref="official_url" /></component>
      <component><field ref="place_of_pub" /></component>
      <component><field ref="publisher" /></component>
      <component><field ref="id_number" /></component>
    </epc:if>
  </stage>



  <stage name="type">
    <component><field ref="type" required="yes" /></component>
  </stage>

  <stage name="files">
    <component type="XHTML"><epc:phrase ref="Plugin/InputForm/Component/Upload:help" /></component>
    <component type="Upload">
      <field ref="format" />
      <field ref="formatdesc" />
      <field ref="security" />
      <field ref="license" />
      <field ref="date_embargo" />
<!--  <field ref="language" /> -->
    </component>
  </stage>

</workflow>

