XSLT extension functions

When you use the Adapter for File System (XSLT) activity, extension functions can be called from the XSLT processor to perform actions that cannot be done by standard XSLT functionality.

The following extension functions are available. Any variables in the below examples must be defined in the XSLT script.

SetFileName(fileName)

Defines the output file name.

The file path can be absolute or relative. In case of a relative path, the configured base directory is used as the root.

Parameters:

  • fileName – Output file.

Example:

<xsl:variable name="dummy"
select="XBOUNDCustomFunctions:SetFileName
(concat('xbBatch\', $BatchID,'\',$xmlFile))"/>

SetPerBatchTriggerFileName(fileName)

Creates a trigger file at the end of processing to tell the target system that the root document is completely exported.

The file path can be absolute or relative. In case of a relative path, the configured base directory is used as the root.

Parameters:

  • fileName – Trigger file name.

Example:

<xsl:variable name="dummy"
select="XBOUNDCustomFunctions:SetPerBatchTriggerFileName
(concat('xbBatch\', $BatchID,'\',$xmlFile))"/>

SetPerDocTriggerFileName(fileName)

Creates a trigger file for each document, telling the target system that the document is exported.

This file path can be absolute or relative. In case of a relative path, the configured base directory is used as the root.

Parameters:

  • fileName – Trigger file name.

Example:

<xsl:variable name="dummy"
select="XBOUNDCustomFunctions:SetPerDocTriggerFileName
(concat('xbBatch\', $DocID,'\',$xmlFile))"/>

CreateDirectory(directoryName)

Creates all directories and subdirectories for the given path. If a directory already exists, no error is reported.

Parameters:

  • directoryName – Path to the directories to create. Relative or absolute.

Example:

<xsl:variable name="dummy"
select="XBOUNDCustomFunctions:CreateDirectory
('c:\temp\export\')"/>

DeleteDirectory(directoryName)

Deletes the given directory and all of its subdirectories. If the directory does not exist, no error is reported. This is performed at the end. Several directories can be deleted if this is called more than one time.

Parameters:

  • directoryName – Name of the directory to be deleted (last component of the path). Relative or absolute.

Example:

<xsl:variable name="dummy"
select="XBOUNDCustomFunctions:DeleteDirectory
('c:\temp\export\')"/>

GetOrCreateDocID(documentNode, counterName)

Creates and returns a number for each document that has been specified by documentNode, which is unique per process and per counterName.

If this is called multiple times, the number from the first call is returned.

Counting starts with 1. The maximum value is 9,223,372,036,854,775,807.

For processes, a counter named counterName is created, if it does not yet exist, and is used.

For documents, a field named counterName and the value of the counter are created.

Parameters:

  • documentNode – XPath that points to the reference document.

  • counterName – Name of the counter according to the XBOUND field-naming rules.

Returns:

  • The counter value.

Example:

<xsl:variable name="batchID"
select="format-number
(XBOUNDCustomFunctions:GetOrCreateDocID
(/document, 'BatchID'), '000000000')"/>

SaveMedium(mediumNode, fileName)

Exports a medium as a file.

Parameters:

  • mediumNode – XPath that points to the XML element of the medium to export.

  • fileName – File name (including path, absolute or relative) of the file to create.

Example:

<xsl:variable name="dummy"
select="XBOUNDCustomFunctions:SaveMedium
(.,$CompleteFileName)"/>

CreateArchive(type, includedFiles, fileBusy, fileReady)

Creates a tar archive after the XSLT processing.

The paths in the tar archive are relative to the path contained in the includedFiles parameter.

If this is called multiple times, only the last call is valid.

Parameters:

  • type – Desired archiving process: tar.

  • includedFiles – The files that are to be included in the archive. Wildcards (*) are allowed.

  • fileBusy – Name of the archive file during creation.

  • fileReady – Name of the archive file when finished.

Example:

<xsl:variable name="dummy3"
select="XBOUNDCustomFunctions:CreateArchive
('tar','C:\temp\export','export.bsy', 'export.tar')"/>

GetCurrentDateTime(format)

Returns the current DateTime value according to the specified format.

Parameters:

  • format – Format according to .NET syntax.

Returns:

  • The current DateTime, formatted.

Example:

<xsl:variable name="DateTimeNow"
select="XBOUNDCustomFunctions:GetCurrentDateTime
('dd.mm.yyyy hh:MM:ss')"/>

ConvertDateTime(givenDateTime, givenFormat, resultFormat)

Converts a DateTime value formatted in givenFormat to a DateTime value formatted in resultFormat.

Parameters:

  • givenDateTime – The given DateTime.

  • givenFormat – Format of givenDateTime (.NET syntax).

  • resultFormat – Format that the result has (.NET syntax).

Returns:

  • The reformatted value.

Example:

<xsl:variable name="DateTimeNow"
select="xboundCustomFunctions:GetCurrentDateTime
('dd.mm.yyyy hh:MM:ss')"/>

XbCreateField(parentNode, fieldName, fieldValue)

Creates an XBOUND field in the specified document or field group with the specified name and value.

Parameters:

  • parentNode – XPath that points to the XML element of the document or field group to create the field in.

  • fieldName – Name of the field to be created.

  • fieldValue – Value of the field to be created.

Example:

<xsl:variable name="dummy2"
select="XBOUNDCustomFunctions:XbCreateField
(., $xbMyFieldName, $xbMyFieldValue)"/>

XbUpdateField(parentNode, fieldName, fieldValue)

Updates an XBOUND field in the specified document or field group with the specified name and value. (This is done by deleting and recreating fields with the specified name. If the specified field value exceeds 255 characters, it is split across two fields.)

Parameters:

  • parentNode – XPath that points to the XML element of the document or field group to update the field in.

  • fieldName – Name of the field to be updated.

  • fieldValue – Value of the field to be updated.

Example:

<xsl:variable name="dummy2"
select="XBOUNDCustomFunctions:XbUpdateField
(., $xbMyFieldName, $xbMyFieldValue)"/>

XbDeleteField(parentNode, fieldName)

Deletes all XBOUND fields in the specified document or field group with the specified name.

Parameters:

  • parentNode – XPath that points to the XML element of the document or field group to delete the field in.

  • fieldName – Name of the field to be deleted.

Example:

<xsl:variable name="dummy2"
select="XBOUNDCustomFunctions:XbDeleteField
(., $xbMyFieldName, $xbMyFieldValue)"/>

XbCreateDocument(parentNode, documentName)

Creates an XBOUND document with the specified name and null document type in the specified parent document.

Parameters:

  • parentNode – XPath that points to the XML element of the parent document to create the document in.

  • documentName – Name of the document to be created.

Example:

<xsl:variable name="dummy3"
select="XBOUNDCustomFunctions:XbCreateDocument
(., $xbMyDocumentName)"/>

DBBeginTransaction(connectionString)

Opens a connection to the SQL Server database with the specified connection string and begins a transaction.

Parameters:

  • connectionString – Connection string for the SQL Server database.

Example:

<xsl:variable name="DB-Transaction-Open"
select="XBOUNDCustomFunctions:DBBeginTransaction
('Server=localhost; Database=Northwind; Trusted_Connection=True;')"/>

DBInsert(tableName, columnsCommaSeparated, valueSet)

Inserts a new entry into the table with the specified name.

Parameters:

  • tableName – Name of the table to insert the entry into.

  • columnsCommaSeparated – Names of the columns in the table, separated by a comma.

  • valueSet – Values to be inserted into the specified columns.

Example:

<xsl:variable name="table" select="EC:node-set($TABLE)"/>
<xsl:variable name="DB-Insert"
select="XBOUNDCustomFunctions:DBInsert
('TEST','A,B', $table/row[1]/col/text())"/>

ReadCSVFromFile(file, delimiters)

Reads data from a comma-separated values (CSV) file.

Parameters:

  • file – File from which to read the data.

  • delimiters – One or more delimMiter characters.

Example:

<xsl:for-each select="XBOUNDCustomFunctions:ReadCSVFromFile
('D:\Testdaten\XSLT\Personen.csv',',')/record">
<xsl:value-of select="field[3]"/>::
<xsl:value-of select="field[2]"/>::
<xsl:value-of select="field[1]"/>
<xsl:text> </xsl:text> </xsl:for-each>

Send[Warning|Info|Debug]LogMessage(message, category, docGUID)

Sends a log message.

Parameters:

  • message – Message to be sent.

  • category – Message category (optional).

  • docGUID – Document identifier (optional).

Example:

<xsl:variable name="dummy"
select="xboundCustomFunctions:SendInfoLogMessage
(concat('SendInfoLogMessage', ./@txt))"/>

ThrowException(message, category, docGUID)

Throws an exception.

Parameters:

  • message – Message that is thrown with the exception.

  • category – Exception category (optional).

  • docGUID – Document identifier (optional).

Example:

<xsl:variable name="dummy"
select="xboundCustomFunctions:ThrowException
(concat('Export Abort ', ./@txt))"/>

XML batch structure

XSLT file

The XSLT Script Editor