Index data

Index data

You can create an index data XML output file with the advanced workflow component, Index data. The index file can e.g. be used for archiving

You can use a transform component to convert the XML into another format before saving it to a file.

 

The index data component only accepts printable as input, so it cannot be inserted in any place in the workflow. You need to make sure, that the previous workflow component output a printable output e.g. PDF. You can e.g. not place the index data component after the create PDF file component, as the output from that is XML.

 

Here is an sample workflow, where the Index data component is used:

    NG2IndexData0004

 

In the generated document, all the specified index values will be under an element called "IndexValues". Additional metadata will be in the element "MetaDataValues". The elements md5, sha-1 and sha-256 are hash values of the document that was previously created from the template. If the created document was saved to the file system, then the file name element will have the file name of the document.

 

The index data component has these parameters:

    
  1. Add index element
    Click this blue icon to add more lines below. This will more detail nodes to the output XML file. Click the trash can icon on the far right to delete a line.
  2.  Index label
    The name of the label/node in the output XML file.
  3.  Index value
    The value to insert for the index label. This should normally be a dynamic value. In the example above I have loaded a sample XML file in the workflow and referenced it via the magnifying glass.

With the demo invoice xml file and the definition above the output file will look like this:

    


Below you can see an example of how the index data component can be used in the workflow:

    NG2IndexData0003

 

You might want to ensure, that the file name of the index data file is the same as the PDF file, that was generated. You can do that, if you setup the second To filesystem component up like this:

    

 

Notice the functions setup for the file name:

concat(substring($interform.plugin.archiver.fileName,1,string-length($interform.plugin.archiver.fileName)-4),'.xml')

 and that the file name conflict resolution is setup to overwrite.

 

The problem is, that the PDF file, that we created first might be given a different name, that we think, because a file already existed with the same name. One of the file name conflict resolutions is to give the PDF file a number at the end to generate a unique name. The clever thing is however, that the predefined output variable, $interform.plugin.archiver.fileName contains the final name of the PDF file after running the first To file system component.

 

The challenge is then to convert the extension from .pdf into .xml.

One way to do that is to remove the last 4 characters of the original file name and then append '.xml' to the file name, and that is exactly what is done here:
concat(substring($interform.plugin.archiver.fileName,1,string-length($interform.plugin.archiver.fileName)-4),'.xml')

The concat concatenates two strings:

  1. The initial part of the PDF file name.
  2. .xml

The initial part (without .pdf) is found by taking a substring of the full file name, but reducing the length with 4, so if the PDF file is called e.g. 'Invoice_1234.pdf', then the length is 16. We then subtract 4 and do a substring to the the first 12 characters: ''Invoice_1234' and then concat it with '.xml' to get ''Invoice_1234.xml'.

 

The workflow above use these components:

  1. Create PDF document to create an internal PDF in the payload.
  2. To filesystem to copy the PDF file into a file.
  3. Index data to build up an index file.
  4. To filesystem to write the index data into a file.

    • Related Articles

    • XML Node Selection & Referencing

      XPath provides multiple ways to reference and navigate through an XML structure. Learn how to select specific nodes using direct references, index numbers, conditions, and relationships with other nodes. Connecting preceding or following node sets to ...
    • Shorten meta data names

      Use this to remove a common prefix from all meta data keys in the current workflow. This can be handy, if a lot of meta data keys are entered from an external resource, when the workflow was called. So to make it easier to refer to the meta data ...
    • Shortcut Set meta data components

      The shortcut set meta data components can be used for assigning a value to various meta data keys. The meta data keys are then used by other functions in the workflow. The set meta data components are: Log info key - With this you can set a value for ...
    • Add data to spooled files via SQL

      If you want to add data from a database into a spooled file via SQL, then you should consider these options: Enrich spooled file from database workflow component inside your workflow. You can also consider to use the ng:databaseLookup function for a ...
    • Advanced Set meta data workflow components

      The advanced set meta data workflow components are: Email details. Sets various email meta data like subject, receivers and sender. Extra PCL commands. With this you can add your own PCL commands in the PCL output from InterFormNG2 e.g. for tray ...