Skip to main content

Batch Processing Using the Flexi2XML Tool

Data Conversion Tool for Importing/Exporting Data to/from ABRA Flexi Using XSLT Transformation

Written by Petr Pech

Flexi2XML lets you batch-import data into ABRA Flexi — both to a local and a remote instance. It requires the REST API to function. For instructions on how to obtain the tool, see the article Downloading Flexi2XML.


How the import works

The basis is a configuration file that specifies how and where the data should be uploaded. The process is then as follows:

  1. The tool finds all files matching the specified mask. The mask is entered as a regular expression, for example .*\.csv.

  2. It imports them to the specified address in the chosen format — the format is determined by the server — and records the output in the log.

  3. If the import succeeds without error, it renames the file so that it no longer matches the mask.

💡 If an import fails, the file is not renamed, and the tool will try to import it again the next time it runs. This means you can run the batch repeatedly, for example from a scheduler.


Configuration parameters

The tool is started with a reference to the configuration file:

flexibee2xml --load config.xml

The configuration file contains login and server details in the config section, and one or more action sections — each describing one group of files and the destination to which they should be uploaded:

<?xml version="1.0"?>
<config>
<username>jmeno</username>
<password>heslo</password>
<!-- identifikátor firmy, do které data nahrát -->
<company>demo</company>
<!-- server -->
<host>demo.flexibee.eu</host>
<!-- port, výchozí 5434 -->
<port>5434</port>
<!-- přípona, která bude přidána do názvu po přejmenování -->
<renameSuffix>-loaded</renameSuffix>
<!-- seznam akcí, které se mají provést -->
<action>
<!-- URL, kam nahrát data, začíná na / -->
<url>/faktura-vydana.csv?format=sofix&amp;encoding=windows-1250&amp;delimeter=;</url>
<!-- typ souboru, obvykle text/csv, text/xml nebo application/json -->
<contentType>text/csv</contentType>
<!-- maska pro výběr souborů -->
<mask>VFA.*\.csv</mask>
<directory>.</directory>
</action>
<action>
<url>/pokladni-pohyb.xml</url>
<contentType>text/xml</contentType>
<mask>items.*\.xml</mask>
<directory>.</directory>
</action>
</config>

🚨 The configuration file contains the username and password in plain text. Store it outside shared directories and restrict access rights to it — for batch uploads, create a separate user with only the necessary permissions, not an administrator account.

⚠️ In the value of url, the parameter separator & must be written as &amp;, otherwise the file is not valid XML. The format parameter refers to an XSLT transformation on the server side — make sure a transformation of that name exists in your version, otherwise the call will fail with an Unknown format error.


Supported parameters in the action section

Element

Meaning

url

The address to or from which to upload files. Starts with a slash.

mask

A regular expression specifying the list of files to import.

directory

The directory in which files matching the mask are searched for.

contentType

The Content-Type used for the HTTP request.

xslt

Applies this XSL transformation to the content (its XML form) before sending it.

delimeter

The delimiter used when converting from CSV to XML.

encoding

The character encoding used when converting from CSV to XML.

csv2xml

The name of the row element in XML when converting from CSV.

renameOnFailure

Rename files even if an error occurs.

log

The file to write conversion errors to.

successMessage, failMessage, requiredMessage

Messages shown to the user on success, on error, and when no file was converted.


Supported parameters in the config section

Element

Meaning

host

The address (DNS or IP) of the ABRA Flexi server.

port

The server port; the default is 5434.

username, password

The username and password of the user under which the import runs.

company

The identifier of the company to or from which the data will be uploaded — it becomes part of the URL.

directory, contentType, renameOnFailure

Default values for all actions; an individual action can override them.

renameDir

The directory to which successfully uploaded files will be moved.

renamePrefix, renameSuffix

The prefix and suffix that successfully uploaded files will be renamed with.

showProgress

Show the number of processed files and their status.

successMessage, failMessage

Messages shown to the user on success and on error.

⚠️ On Windows, there are two variants of the tool — flexibee2xml and flexibee2xml-cli. The former is compiled as a graphical application and does not open a command-line window; it is tidier, but does not display error messages. For debugging batches, therefore use the -cli variant.


Related

Did this answer your question?