Imixs Workflow ...the open source workflow technology for business applications

RESTful API

Transform a XML file using XSL transformation

Based on a XSL template you can transform external XML data into the Imixs XML format. The result of thus a transformation can be posted to the Imixs Workflow REST service. This is how a interface between an external system and the Imixs Workflow engine can be realized.

The following example shows how to transform xml data and post the result to a Imixs Workfow server.

The XML Data

This is a sample of a xml data structure provided by an external system. The structure contains several 'Documents' containing detail information and DocumentLevelFields

<?xml version="1.0" encoding="UTF-8"?>
        <Documents>
                <Document>
                        <Identifier>DOC1</Identifier>
                        <Type>Imixs-RG</Type>
                        <Valid>true</Valid>
                        <Reviewed>true</Reviewed>
                        <ErrorMessage></ErrorMessage>
                        <DocumentLevelFields>
                                <DocumentLevelField>
                                        <Name>RG-NR</Name>
                                        <Value>05052011</Value>
                                        <Type>STRING</Type>
                                        <Page>PG0</Page>
                                        <FieldOrderNumber>1</FieldOrderNumber>
                                </DocumentLevelField>
                        </DocumentLevelFields>
                </Document>
                <Document>
                        <Identifier>DOC2</Identifier>
                        <Type>Imixs-RG</Type>
                        <Valid>true</Valid>
                        <Reviewed>true</Reviewed>
                        <ErrorMessage></ErrorMessage>
                        <DocumentLevelFields>
                                <DocumentLevelField>
                                        <Name>RG-NR</Name>
                                        <Value>44032011</Value>
                                        <Type>STRING</Type>
                                        <Page>PG0</Page>
                                        <FieldOrderNumber>1</FieldOrderNumber>
                                </DocumentLevelField>
                        </DocumentLevelFields>
                        
                </Document>
        </Documents>
</Batch>
  

Transforming the XML Data with XSLT

With a XSL template you can now transform the given XML data into the Imixs EntityCollection xml format. This xml format of an Imixs EntityCollection has the following structure:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<collection>
        <entity>
                <item>
                        <name>numsequencenummer</name>
                        <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">1</value>
                </item>
                <item>
                        <name>namlasteditor</name>
                        <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">sally</value>
                </item>
                <item>
                        <name>$uniqueid</name>
                        <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">13189f34ce7-5668d41
                        </value>
                </item>
                <item>
                        <name>_ordernumber</name>
                        <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">345</value>
                </item>
        </entity>
        <entity>
                <item>
                        <name>numsequencenummer</name>
                        <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">2</value>
                </item>
                <item>
                        <name>namlasteditor</name>
                        <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">Karl</value>
                </item>
                <item>
                        <name>$uniqueid</name>
                        <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">13189f34ce7-5668d41
                        </value>
                </item>
                <item>
                        <name>_ordernumber</name>
                        <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">345555</value>
                </item>
        </entity>
</collection>

See details about the xml format in the XML Section.

To transform the external xml a simple xsl template can be used like shown in the following example

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

        <xsl:template match="/">
                <collection>
                        <xsl:apply-templates select="Batch/Documents/Document[Type='Imixs-RG']">
                        </xsl:apply-templates>
                </collection>
        </xsl:template>

        <xsl:template match="Batch/Documents/Document[Type='Imixs-RG']">
                <entity>
                
                <!-- setting General Workflow Settings -->
                        <item>
                                <name>type</name>
                                <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                        xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">workitem</value>
                        </item>
                        <item>
                                <name>namcreator</name>
                                <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                        xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">ephesoft-batch-process</value>
                        </item>
                        
                        <item>
                                <name>$modelversion</name>
                                <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                        xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">office-de-0.0.1</value>
                        </item>
                        
                        <item>
                                <name>$processid</name>
                                <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                        xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">4000</value>
                        </item>
                        <item>
                                <name>$activityid</name>
                                <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                        xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:int">20</value>
                        </item>
                        
                        
                        <!-- extract _ordernumber -->
                        <item>
                                <name>_ordernumber</name>
                                <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                        xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:string">
                                        <xsl:value-of
                                                select="DocumentLevelFields/DocumentLevelField[Name='RG-NR']/Value" />
                                </value>
                        </item>
                </entity>
        </xsl:template>
</xsl:stylesheet>  

This xsl template selects all Document nodes with the type='Imixs-RG'. For each document node the condition xsl:apply-templates creates a new entity tag with different item nodes. The template creates the entity tag and provides some workitem fields with fixed values. In the last section of the xsl:template a value from the provided DocumentLevelField tag is extracted and transformed into an item with the name '_ordernumer' and the corresponding value.

The result of such a transformation can be used to be posted to the Imixs Rest Service interface. See the section: Post XML Data.