Validation of an XML workflow definition

There is a tool for validating an XML process definition : validate-flowdef.sh (for Windows, it's validate-flowdef.bat). This tool can save a lot of time to flow designers. It is much more time consuming to run the whole OpenWFE suite and then have to browse the logs/engine.log for the errors. A few validation runs are worth it before releasing the process definition in the wild.

Beware one thing : the validator is not running the workflow, it's just building it, thus, it won't resolve participant names for you. If you make a mistake in a participant name, the validator won't detect it. Perhaps later versions of the validator will check in the participant-map to test if the referenced participant names do really exist. The validator will never be able to assess if a dynamically determined participant name is valid.

Here's the usage :



USAGE :

  ./bin/validate-flowdef.sh {flowDefinitionURL} [schema-validation]

  This command will complain if the given URL points to an invalid
  flow definition.
  If [schema-validation] is present and set to 'true', XSD schema validation
  will occur.


Consider this flow definition :


<?xml version="1.0" encoding="UTF-8"?> 
<process-definition name="flow" revision="x.x">
    <sequence>
        <participant ref="role-alpha" />
        <set field="customer_name" value="fill this field" />
        <set field="flag" value="true" type="boolean" />
        <participant ref="role-bravo" />
        <praticipant ref="role-charly" />
    </sequence>
</process-definition>

Here is the validation run :


openwfe-1.4.6$ bin/validate-flowdef.sh path_to_flows/flow__x.x.xml
$OPENWFE_HOME set to ./

       --- preparing services for validation ---


       --- initiating validation ---

2 [main] WARN openwfe.org.engine.wfibuilder.WorkflowInstanceBuilder  - loadWorkflow() failed to load workflow file:./process-definitions/flow__1.0.xml
openwfe.org.engine.wfibuilder.BuildException: Unmapped expression 'praticipant'
        at openwfe.org.engine.impl.wfibuilder.XmlWorkflowInstanceBuilder.determineAndInstantiateExpression(XmlWorkflowInstanceBuilder.java:509)
        at openwfe.org.engine.impl.wfibuilder.XmlWorkflowInstanceBuilder.buildExpression(XmlWorkflowInstanceBuilder.java:436)
        at openwfe.org.engine.expressions.AbstractCompositeFlowExpression.build(AbstractCompositeFlowExpression.java:273)
        at openwfe.org.engine.impl.wfibuilder.XmlWorkflowInstanceBuilder.buildExpression(XmlWorkflowInstanceBuilder.java:441)
        at openwfe.org.engine.impl.wfibuilder.XmlWorkflowInstanceBuilder.buildSubProcess(XmlWorkflowInstanceBuilder.java:658)
        at openwfe.org.engine.impl.wfibuilder.XmlWorkflowInstanceBuilder.buildSubProcess(XmlWorkflowInstanceBuilder.java:675)
        at openwfe.org.engine.impl.wfibuilder.XmlWorkflowInstanceBuilder.buildWorkflow(XmlWorkflowInstanceBuilder.java:718)
        at openwfe.org.engine.impl.wfibuilder.XmlWorkflowInstanceBuilder.loadWorkflow(XmlWorkflowInstanceBuilder.java:386)
        at openwfe.org.engine.impl.wfibuilder.XmlWorkflowDefinitionValidator.main(XmlWorkflowDefinitionValidator.java:209)

       !! process-definitions/flow__1.0.xml is NOT valid !!

  ! openwfe.org.engine.wfibuilder.BuildException :
    Failed to build wfdefinition from file:./process-definitions/flow__1.0.xml
  ! openwfe.org.engine.wfibuilder.BuildException :
    Unmapped expression 'praticipant'

openwfe-1.4.6$

The validator exits at the first error detected. Just after the 'NOT valid !!' message, a pretty-printed version of the errors is printed and should help fix your XML process definition.

If 'schema-validation' is turned on (the last param of the validate-flow.sh command tool), the validator will use XSD validation against the process definition. To take advantage of this feature, your 'process-definition' root element should look like this :



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

<process-definition 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://www.openwfe.org/flowdef.xsd"
    name="my_flow" 
    revision="0.0.1"
>

(...)


If your system has no access to the Internet, you should store the XSD schema locally and reference it like this :



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

<process-definition 
    xsi:noNamespaceSchemaLocation="file:/my_schemas/flowdef.xsd"
    name="my_flow" 
    revision="0.0.1"
>

(...)


XSD schema validation is not always a good thing : it cannot accomodate with subprocesses called directly with their name as a tag. This flow will not be validated if schema validation is turned on :


<process-definition 
    xsi:noNamespaceSchemaLocation="file:/my_schemas/flowdef.xsd"
    name="my_flow" 
    revision="0.0.1"
>
    <!-- body -->

    <sequence>
        <supervised-participant rref="role-alpha" />
        <supervised-participant rref="role-bravo" />
    </sequence>


    <!-- subdefs -->

    <process-definition name="supervised-participant">
        <concurrence>
            <participant ref="${rref}" />
            <participant ref="supervisor" />
                <!-- copy to supervisor -->
        </concurrence>
    </process-definition>

</process-definition>

The XSD validation will not acknowledge the 'reminded-participant' tag.