Skip to content

XML Database

Emakin uses an XML NoSQL database for storing large XML datasets. This is particularly suitable given Emakin's heavy reliance on XML data. Data is stored as a single large XML document with nested elements. Access is provided via server-side scripts using Xml.Load and $XmlRepository.Query methods, and on forms using the XML Database Query data source.

Emakin utilizes two types of XML databases: Domain and Process databases. The Process database is disabled by default and requires explicit administrator enablement.

Domain Database

The Domain database is shared across all processes within a domain. It's used for storing domain-wide data. All queries use XQuery. Emakin provides Save and Load functions for simpler operations. Save overwrites existing nodes; Load uses XQuery for retrieval.

Saving Data to the Domain Database

This example uses XmlNode.Save to store the Customer node under the Customer/<Id> path:

1
$Xml.Save('Customer', 'Customer/' + $Xml.Evaluate('Id'));

Loading Data from the Domain Database

This example uses XmlNode.Load to retrieve the Customer node:

1
$Xml.SelectSingle('Customer').Load('Customer[Id=1]');

More complex XQuery queries are also supported (see XQuery documentation). For example:

1
2
3
4
5
6
7
$Xml.Load('for $c in /Customer ' +
        'where $c/Id=1 ' +
        'return ' +
        '  <Customer> ' +
        '    <Id>{ $c/Id }</Id> ' +
        '    <Name>{ $c/Name }</Name> ' +
        '  </Customer> ');

Process Database

The Process database is automatically created for each process and stores workflow data for reporting and statistics. This data mirrors the relational database but in a more compact XML format, facilitating report generation.

Note

The Process database is disabled by default and requires administrator enablement.

Instance Data

Instance metadata (within <Instance> tags) includes workflow details and a list of completed work items. A background job ("Instance Xml Database Replication") updates the database upon work item completion. Use the Background Jobs Manager to monitor this job.

Example Instance Data:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
<Instance>
    <Id>...</Id>
    <Number>...</Number>
    <State>...</State>
    <Start>...</Start>
    <End>...</End>
    <WorkItems>
        <WorkItem>
            <Id>...</Id>
            <Name>...</Name>
            <State>...</State>
            <Start>...</Start>
            <End>...</End>
            <CompletedBy>...</CompletedBy>
            <DataId>...</DataId>
            <DataRoot>...</DataRoot>
        </WorkItem>
        ...
    </WorkItems>
</Instance>

Form Data

Form data (within <form> tags) is similarly stored and updated upon work item completion. A background job ("Form Data Xml Database Replication") manages this update.

Example Form Data:

1
2
3
4
5
<form Id="...">
    <MyRoot>
        <MyField>MyValue</MyField>
    </MyRoot>
</form>