XMLTODATABASE Workflow Application
Overview
The XMLTODATABASE workflow application lets you export data from any XML document to one or several databases. It is a synchronous system application that does not require the user to take action. The configuration of the SQL transaction is done via an XML document that enables SQL queries to be performed on ODBC, OLEDB, or other custom data sources.
How it works
The WorkflowGen engine calls the XMLTODATABASE application with the context and the parameters. XMLTODATABASE uses the context and the parameters to get the following:
The XML data document to export
The transactions document, which contains:
Information on how to connect to the database
Information on where the data should be taken in the XML data document (using XPaths)
After XMLTODATABASE has gathered all of the above information, it is ready to perform the export. Once the export is complete, it returns the context to WorkflowGen so that the workflow may continue.
Description of the XML transactions document
Overview
The XML transactions document specifies the SQL commands that will be executed on the databases. It is used for two main functions: connecting to the database, and mapping the fields of the query to the fields of the XML data document. Remember that the XML data document (generally named FORM_DATA
) can be constructed in many ways. For this reason, XPaths are used to map the database fields to the XML fields.
Structure
Any one XMLTODATABASE activity can have an unlimited number of databases and an unlimited number of commands per database. This means that the export can be done to several databases, and each database can have more than one command.
📌 Example of an XML transactions document
Attributes
transaction
node
transaction
nodedatabase
node
database
nodeYou can use either the
connectionstringname
orconnectionstring
attributes, but not both.It is strongly recommended to use a connection name rather than a connection string to simplify multi-environment management.
command
node
command
nodeConnection string name example
XMLTODATABASE transaction file
WorkflowGen web.config
file
web.config
fileLocation of the XML transactions document
There are four ways to define an XML transaction for an XMLTODATABASE action. In all of the following cases, the transaction document is defined as follows:
XMLTODATABASE first looks for a
TRANSACTIONS_TEXT
parameter.If this parameter is not found, it then looks for a
TRANSACTIONS_FILE
parameter.If this parameter is not found either, it then looks for a file with your transaction’s name.
If this file is not not found either, it then parses the
Transactions.xml
file to find a node with your transaction’s name.
The priority order, then, is as follows:
TRANSACTIONS_TEXT
parameter.TRANSACTIONS_FILE
parameter.MyTransaction.xml
file.Transactions.xml
file.
In the common file
In this case, the transaction file is located in the \wfgen\App_Data\Files\XmlToDatabase
folder, and named Transactions.xml
. The XMLTODATABASE application parses this file to find your transaction.
The XMLTODATABASE action contains the following parameters:
TRANSACTION
: IN direction text type dataXML
: IN direction file type data
In a specific file
If your transaction is not found inside the Transactions.xml
file, the XMLTODATABASE application looks for an .xml
file with the same name as your transaction. The transaction document should be created in the MY_TRANSACTION.xml
file.
The XMLTODATABASE action contains the TRANSACTION
and XML
parameters.
You can change from the common transaction file to a specific transaction file without updating your process definition by removing the transaction from the Transactions.xml
file and adding it in a file named with your transaction’s name.
In a process file data type
If you can’t access the web server's \App_Data
folder, or if you want to include your transaction in your process definition (to be exported and shared by an XPDL file), you can upload your transaction file in a process file data type. To do this:
Create a process file data type and upload your
MY_TRANSACTION.xml
file.Edit your XMLTODATABASE action, add a new parameter named
TRANSACTIONS_FILE
, and send the value of your process data.
In a process text data type
If you can’t access the \App_Data
folder of the web server, or if you want to include your transaction in your process definition (to be exported and shared by an XPDL file), you can write your transaction within a process text data type.
As of WorkflowGen version 7.15.0, the XML transaction contained in a TEXT process data no longer has a 4000-character limit for MS SQL Server database. This limit remains unchanged for Oracle database.
To do this:
Create a process text data type and write your transaction as a default value.
Edit your XMLTODATABASE action, add a new parameter named
TRANSACTIONS_TEXT
, and send the value of your process data:
It is not necessary to create process data. You can send the value of your XML transaction within the TRANSACTION_TEXT
parameter.
Date and numeric field formatting
You can specify which fields must be formatted as date or numeric values using the following parameters:
Date format generated into the SQL queries
DATE type fields are formatted as follows: yyyy-mm-dd hh:MM:ss
Numerical format generated into the SQL queries
Numeric fields are formatted as follows: XXXX.XX
📌 Example
Rule: All the nodes found in the XML document with the name
REQUEST_DATE
and the specific node situated at/MyData/MyExample/Date_Field
will be formatted as dateMethod:
XML_FIELDS_DATE = //*/REQUEST_DATE, /MyData/MyExample/Date_Field
Details of the transaction execution
The SQL commands can be launched as transactions. If errors occur, a rollback is launched and the initial state of the database is restored. The value of the transaction attribute of the database node must be set to yes
.
If the transaction handles many databases, the execution of the commands will be multi-transactional, meaning if an error occurs in a command in one of the databases, a rollback on all database transactions performed will be launched.
Test mode
The transactions can be tested before being executed on the database. The value of the constant XmlToDatabaseTestMode
in the configuration file must be set to Y
.
If this constant is set to Y
and you have specified using transactions on the database nodes, the transactions will not be committed at the end of the execution.
Description of the log file
If the XmlToDatabaseEnableTrace
parameter in the configuration file of the web service is set to Y
, a log file will be created in the \wfgen\App_Data\LogFiles\XmlToDatabase
directory.
The log entries are in the following format:
Date; [Database name;] Transaction name; SQL query; Execution result
Execution result
values are:
OK
if the query was run successfully, orERROR: Error code - Error description
if an error occurred.
📌 Examples
Possible execution errors
The following errors can occur during the execution of the transactions:
Export examples
📌 Example 1
XML file structure:
The command node could look like this:
The XPATH:
tags in the query will be replaced with /data/
, which is the XPath attribute value.
The PARAM:
tag is used to identify a WorkflowGen parameter instead of using an XML field.
XPaths that return no nodes will use
null
values.It is not possible to use the qualified XPath by using
XPATH::
instead ofXPATH:
.
📌 Example 2
The following is a more complex example using the loop
property.
XML file structure:
The command
nodes could look like this:
You must use two :
(colon) characters when you don't want to use the qualified XPath in the command
node, as shown in {XPATH::/Library/publishers/publisher}
above.
Last updated