Please enable JavaScript to view this site.

InterFormNG2 Manual

In this example we will split up this input XML file into multiple PDF files - one for each document:

 

NG2WorkflowTransformOrSplit0002

A simple way to split up the input XML file is to use either the Transform or split or the Split XML workflow component:

 

NG2SplitXML0003

 

Here we refer to the /Root/Document path, which you can insert via the magnifying glass on the split component, if you have loaded a sample XML file in the workflow.

 

A limitation of the split is, that the header data - CompanyInfo, Greeting and Barcode is outside the Document subtrees and thus not included in each of the splitted files, but we can fix that by changing the XML file before the split.

 

First we need to create a new text file with the extension .xsl, that contains this text:

 

<?xml version="1.0" encoding="UTF-8"?>

 -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

   <!-- Identity template, copies everything as is -->

 -<xsl:template match="@*|node()">

   -<xsl:copy>

     <xsl:apply-templates select="@*|node()"/>

   -</xsl:copy>

 </xsl:template>

     <!-- Add CompanyInfo to each document -->

       -<xsl:template match="Document">

         -<xsl:copy>

         <xsl:copy-of select="@*"/>

         <xsl:copy-of select="node()"/>

         <xsl:copy-of select="/Root/CompanyInfo"/>

         <xsl:copy-of select="/Root/Greeting"/>

         <xsl:copy-of select="/Root/Barcode"/>

         </xsl:copy>

 </xsl:template>

</xsl:stylesheet>

 

This is an XSLT stylesheet, which duplicates the header nodes into each document.

 

If we now load this stylesheet file into the Library as a transformation, then we can refer to it in the workflow above in an XSL transformation before the split:

 

NG2SplitXML0004

 

We also now save the splitted XML files to the file system to see the result: (The read from file is cut off)

 

NG2SplitXML0005

 

The result is XML files like the one below:

 

NG2SplitXML0006

 

If you now even also want to insert the Root node of the new, splitted files, then you can add it with another XSLT stylesheet with this inside:

 

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

 <Root>

   <xsl:apply-templates/>

 </Root>

</xsl:template>

 

<xsl:template match="@*|node()">

 <xsl:copy>

   <xsl:apply-templates/>

 </xsl:copy>

</xsl:template>

 

</xsl:stylesheet>

 

We can now again load this .xsl file as a transform file in the Library and refer to that in the workflow like below:

 

NG2SplitXML0007

 

The final workflow now looks like this:

 

NG2SplitXML0008

 

And the final XML files looks like this:

 

NG2SplitXML0009

 

We can now finally create PDF files instead of output XML files:

 

NG2SplitXML0010