Splitting and Repeating Over XML Files
The XML Split and Repeat task will take a large XML file and split it into a series of smaller XML files, then loop through each of the files it generates running a series of sub tasks for each one. Essentially, this task combines the XML Split and File Repeater tasks into one.
Settings
Input File
Required
The XML file to split.
Output Files Format
Required
Used to control the format of the output files generated by the task, the name is built up of the input file appended with a unique value based on this setting. Defaults to Number. The following options are available: -
- Number - will append an incrementing number starting from 1 e.g. an input of
orders.xmlcould result inorders_123.xml - Timestamp - will append a timestamp e.g. an input of
orders.xmlcould result inorders_201912051559315403023.xml
Note
This setting does not apply when using the Split By Value XPath setting. In this scenario, the split value is appended to the input file name. For example, an input of orders.xml split by payment method could result in orders_paypal.xml.
Output Folder
Required
The output folder for the split XML files. All output files generated by the task will be created in this folder with a name based on Input File and Output Files Format.
Ignore Empty Nodes
Required
Set to True to ignore nodes that contain no data. When enabled, any empty nodes in the Input File will not appear in the output files.
Record Limit
Required
The maximum number of records each XML file should contain. Defaults to 200. Only integer values greater than or equal to 1 will be accepted.
Note
This setting does not apply when using the Split By Value XPath setting. In this scenario, all of the records in a each group will appear in their respective output file.
Retention Option
Required
Used to control what happens to the XML split files generated by this task once each one has been looped over. The following options are available:
- None - The split files will be left in the output folder.
- Archive - The split files will be moved to the workflow's working directory, so they can be archived by the Archive Workflow Data task.
- Delete - The split files will be deleted from the output folder.
Split By Value XPath
Optional
Groups records into separate files based on the value of a specific element. The element must be specified in the form of an XPath Query, which will be evaluated relative to the one specified in the XPath Query setting. For example, if you are splitting product records, you could set this to Warehouse to group the products by warehouse.
XPath Query
Required
The XPath query that specifies each row of data that needs to be split e.g. Company/Products/Product
Zynk Settings
Examples
A sample input file is shown below, containing two stock transactions to be split into separate files. To achieve this, the XPath Query setting should be set to Company/StockTransactions/StockTransaction, and the Record Limit should be set to 1.
<?xml version="1.0"?>
<Company xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<StockTransactions>
<StockTransaction>
<UniqueId>1</UniqueId>
<StockTransactionType>AdjustmentIn</StockTransactionType>
<StockCode>BOARD001</StockCode>
<StockTransactionDate>2006-12-31T00:00:00</StockTransactionDate>
<Reference>STK TAKE</Reference>
<Details>Whiteboard - Drywipe (900 x 1200)</Details>
<Qty>2</Qty>
<CostPrice>15</CostPrice>
<SalesPrice>0</SalesPrice>
<StockTransactionNumber>1</StockTransactionNumber>
</StockTransaction>
<StockTransaction>
<UniqueId>2</UniqueId>
<StockTransactionType>AdjustmentIn</StockTransactionType>
<StockCode>BOARD002</StockCode>
<StockTransactionDate>2006-12-31T00:00:00</StockTransactionDate>
<Reference>STK TAKE</Reference>
<Details>Whiteboard - Drywipe (1000 x 1500)</Details>
<Qty>2</Qty>
<CostPrice>17</CostPrice>
<SalesPrice>0</SalesPrice>
<StockTransactionNumber>2</StockTransactionNumber>
</StockTransaction>
</StockTransactions>
</Company>
Two output files will be created, as shown below, each including a single stock transaction:
<?xml version="1.0"?>
<Company xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<StockTransactions>
<StockTransaction>
<UniqueId>1</UniqueId>
<StockTransactionType>AdjustmentIn</StockTransactionType>
<StockCode>BOARD001</StockCode>
<StockTransactionDate>2006-12-31T00:00:00</StockTransactionDate>
<Reference>STK TAKE</Reference>
<Details>Whiteboard - Drywipe (900 x 1200)</Details>
<Qty>2</Qty>
<CostPrice>15</CostPrice>
<SalesPrice>0</SalesPrice>
<StockTransactionNumber>1</StockTransactionNumber>
</StockTransaction>
</StockTransactions>
</Company>
<?xml version="1.0"?>
<Company xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<StockTransactions>
<StockTransaction>
<UniqueId>2</UniqueId>
<StockTransactionType>AdjustmentIn</StockTransactionType>
<StockCode>BOARD002</StockCode>
<StockTransactionDate>2006-12-31T00:00:00</StockTransactionDate>
<Reference>STK TAKE</Reference>
<Details>Whiteboard - Drywipe (1000 x 1500)</Details>
<Qty>2</Qty>
<CostPrice>17</CostPrice>
<SalesPrice>0</SalesPrice>
<StockTransactionNumber>2</StockTransactionNumber>
</StockTransaction>
</StockTransactions>
</Company>