<config>
  <subConfigs>

    <subConfig type="workflow" id="buildIndexWorkflow">
      <objectType>cheshire3.workflow.SimpleWorkflow</objectType>
      <workflow>
        <!-- input type: documentFactory -->
        <log level="info">Loading documents</log>
        <object type="recordStore" function="begin_storing"/>
        <object type="database" function="begin_indexing"/>
        <for-each>
          <log level="info">"Loading: " + input.filename</log>
          <object type="workflow" ref="buildIndexSingleWorkflow"/>
        </for-each>
        <object type="recordStore" function="commit_storing"/>
        <object type="database" function="commit_metadata"/>
        <object type="database" function="commit_indexing"/>
      </workflow>
    </subConfig>

    <subConfig type="workflow" id="buildIndexSingleWorkflow">
      <objectType>cheshire3.workflow.SimpleWorkflow</objectType>
      <workflow>
        <!-- input type:  document -->
        <object type="workflow" ref="PreParserWorkflow"/>
        <try>
          <object type="parser" ref="LxmlParser"/>
        </try>
        <except>
          <log level="error">Unparsable Record</log>
        </except>
        <else>
        	<try>
	        	<object type="recordStore" function="create_record"/>
		        <object type="database" function="add_record"/>
		        <object type="database" function="index_record"/>
		        <log level="info">Loaded Record</log>
	        </try>
	        <except>
	        	<log level="error">"Record not loaded " + str(err)</log>
	        </except>
        </else>
      </workflow>
    </subConfig>

    <subConfig type="workflow" id="PreParserWorkflow">
      <objectType>cheshire3.workflow.SimpleWorkflow</objectType>
      <workflow>
        <!-- input type: document -->
        <object type="parser" ref="MagicRedirectPreParser"/>
      </workflow>
    </subConfig>
    
    <subConfig type="workflow" id="ReSTToMetsPreParserWorkflow">
    	<docs>Converts ReStructuredText to METS wrapped XML.</docs>
    	<objectType>cheshire3.workflow.SimpleWorkflow</objectType>
    	<workflow>
    		<!-- input type: Document -->
    		<object type="preParser" ref="RstToXmlPreParser"/>
    		<object type="preParser" ref="METSWrappingPreParser"/>
    	</workflow>
    </subConfig>
    
    <subConfig type="workflow" id="PdfToMetsPreParserWorkflow">
    	<docs>Converts PDF to METS wrapped XML.</docs>
    	<objectType>cheshire3.workflow.SimpleWorkflow</objectType>
    	<workflow>
    		<!-- input type: Document -->
    		<object type="preParser" ref="PdfXmlPreParser"/>
    		<object type="preParser" ref="METSWrappingPreParser"/>
    	</workflow>
    </subConfig>
    
    <subConfig type="workflow" id="TxtToMetsPreParserWorkflow">
    	<docs>Convert plain-text to METS wrapped XML</docs>
    	<objectType>cheshire3.workflow.SimpleWorkflow</objectType>
    	<workflow>
    		<!-- input type: Document -->
    		<object type="preParser" ref="TxtToXmlPreParser"/>
    		<object type="preParser" ref="METSWrappingPreParser"/>
    	</workflow>
    </subConfig>
    
    <subConfig type="workflow" id="HtmlToMetsPreParserWorkflow">
    	<docs>Convert HTML to METS wrapped XML</docs>
    	<objectType>cheshire3.workflow.SimpleWorkflow</objectType>
    	<workflow>
    		<!-- input type: Document -->
    		<object type="preParser" ref="HtmlFixupPreParser"/>
    		<object type="preParser" ref="METSWrappingPreParser"/>
    	</workflow>
    </subConfig>
    
  </subConfigs>

</config>
