A spooled file can be split into smaller files depending on the contents e.g. to split up a larger spooled file with many invoices into individual invoices.
If the other spooled file split functions are not enough, then you can consider this workflow component: Split spool (complex key).
This advanced, converted workflow component has these parameters:
Subset expression
This is a page selection criteria, that you can use in order to select specific pages of the input spooled file. This is matched with the key expression, so that the key(s) are extracted on pages, that match the condition for the subset. If you have loaded a sample spooled file (which is recommended) you can use the magnifying glass to select the spooled file data for the condition.
You can add multiple sets of conditions and keys with the add more icon.
Key expression
This is combined with the subset above in the way that if the condition in the subset expression is true, then the key value is found via this expression. In the example above we search for 'Invoice No' in line 13 and if it is found then the invoice number is extracted in line 13, but if the text 'Invoice No' is found in line 14, then the invoice number is extracted from line 14.
Action for pages without key
With this option you can decide what should happen with pages, where no subset expression is true. The possible values are:
Add to current document: With this value the pages are added to the previous key. In this way you can split up documents where the key (e.g. invoice number) is only found on the first page of each document.
Throw away: With this value all pages without a key are not included in the splitted output files. This can be considered, if you want to remove some pages, that are not really needed.
Save key value as
Here you can state a workflow variable, that should receive the value found in the spooled file as key value position. Notice, that you should write the variable without a dollar sign as above. After the split spool component you can e.g. create PDF files, that are using the variable as a part of the PDF file name or path.
Grouping rule
The field "Grouping rule (XPath for group name)" can be used to specify a rule for grouping pages. This can be used to group the split pages together in a smaller number of spooled files.
The rule is an XPath expression that must output the name of the group that the split pages should be placed in.
For instance, say you have three pages with key values 1001, 1002, 1003. If you do not specify a grouping rule, then this will result in 3 spooled files after the split.
If you saved your variable as "customerNo", then you can create a grouping rule like this:
if (number($customerNo) < 1003) then 'g1' else 'g2'
Now the output will be only two spooled files instead of three, one containing the pages with key value 1001 and 1002, another containing the page with key value 1003.
The name of the spooled file's group can be found as the workflow variable, "interform.spooled.groupName".
Example of use: You can find an example of how you can implement a split definition with variables in the section, Example: Use variables for naming output files.