Transforming output to CSV format using a custom XSLT file

You can use custom XML transformations (XSLT files) to transform output data to your liking. This is useful if you need to change the format of the output data, or if you need to add additional information to the output. For example, you could use XML transforms to create output in comma-separated value (CSV) format. This example demonstrates how to create output in comma-separated value (CSV) format (hash-separated in this example), using the following XML:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="">
<xsl:output method="text" encoding="utf-8"/>
 <xsl:template match="/">
 <xsl:value-of select="Batches/Batch/Documents/Document/Parties/Party[Type='supplier']/ExternalId"/>
 <xsl:value-of select="Batches/Batch/Documents/Document/HeaderFields/HeaderField[Type='invoicenumber']/Text"/>
 <xsl:value-of select="Batches/Batch/Documents/Document/HeaderFields/HeaderField[Type='invoicedate']/Text"/>
 <xsl:value-of select="Batches/Batch/Documents/Document/HeaderFields/HeaderField[Type='invoicecurrency']/Text"/>
 <xsl:value-of select="Batches/Batch/Documents/Document/HeaderFields/HeaderField[Type='invoicetotalvatincludedamount']/Text"/>

The XSLT above exports five fields from each invoice to a text file and separates each value with a hash character (#). Line 3 specifies that the output is saved in a text file.

Kofax AP Essentials supports XSLT version 1.0. Other versions are not supported.

You can use XPath and the latest XML schema for Kofax AP Essentials to specify the fields you want to include in your output.

  1. Paste the code above into a text editor, such as Notepad, and save the file with the extension .xslt.

    If you use SFTP as the target system, the encoding of the XSLT file must match the encoding used by the target system. You must also specify this in the Encoding setting.

    In this example, you can see the encoding is specified in two places; both must match the Encoding setting, which also matches the target system.

  2. Navigate to the Resources view and click ADD.
  3. Use the dialog that appears to select the file you created. The file appears in the Resources view after it uploads.
    Resources that contain executable code must be approved by Kofax personnel before they can be used.
  4. Select a target system service that supports XSL transformations and click Configuration. These target-system services support XSL transformations:
  5. Use the view that appears to specify the XSLT file you created in step one in the XSL transformation box.
  6. Process an invoice through Kofax AP Essentials.
  7. Use Kofax AP Essentials Connect to download the output data. For each invoice you process, an image file and a text file containing the hash-separated output is created.

    Example output  

Transforming output with line items

Download this XSLT file to see an example similar to the one above, but with line items.