Batch Processor Service
The Batch Processor service merges XML documents or document fragments.
The following table provides an overview of the Batch Processor service:
System name | BatchProcessorService |
Graphical Process Modeler (GPM) category | All Services |
Description |
The Batch Processor service is used to merge XML documents or document fragments. If specified, XML documents can be translated through a map before being merged. The use of document streaming in the Batch Processor service allows the processing of large documents, allowing fast and efficient merges. Note: This service does not support WTX maps.
|
Business usage | Use the Batch Processor service when you want to create one document out of multiple XML documents, but only fragments of the documents need to be merged and some values need to be replaced. |
Usage example | Fragments of documents need to be combined into one document, and some values need to be replaced. The Batch Processor sends each document through a map, which replaces some of the values in the document. Then a fragment of each document is parsed out and added to an output document. Each document goes through the same process. Once all documents have been processed and added to the output document, the output document is placed in process data. |
Preconfigured? | Yes |
Requires third party files? | No |
Platform availability | All supported platforms. |
Related services | No |
Application requirements | No |
Initiates business processes? | No |
Invocation | Runs as part of a business process. |
Business process context considerations | None |
Returned status values | Returned status values:
|
Restrictions | None. Any number of configurations can be created, but typically a single configuration can be used by any number of business processes. |
Persistence level | None |
Testing considerations | To test it, create a configuration or use the existing configuration, then run it from a business process as shown in the business process examples later in this section. |
Implementing the Batch Processor Service
- Create a Batch Processor service configuration. For information, see Managing Services and Adapters.
- Configure the Batch Processor service. For information, see Configuring the Batch Processor Service.
- Use the Batch Processor service in a business process.
Configuring the Batch Processor Service
To configure the Batch Processor service, you must specify field settings in the application and in the GPM.
Field | Description |
---|---|
Config | Name of the service configuration. |
prefix_document(prefix_document) | The content of the XML document referenced will be added to the beginning of the output document. If a document does not exist with the value specified, XPath will be applied to the value and the text retrieved by xpath added to the beginning of the document (xpath and text needs to be placed in ProcessData). If the xpath does not exist either, nothing will be added. The value has to match the name of a document or xpath. If neither exists, nothing will be added to the beginning of the output document. Optional. |
suffix_document(suffix_document) | The content of the XML document referenced will be added to the end of the output document. If a document does not exist with the value specified, xpath will be applied to the value and the text retrieved by xpath added to the end of the document (xpath and text needs to be placed in ProcessData). If the xpath does not exist either, nothing will be added. The value has to match the name of a document or xpath. If neither exists, nothing will be added to the beginning of the output document. Optional. |
input_document(input_document) | This document contains references to other documents that will be added between the prefix_document and suffix_document. In case of XML documents, each one referenced might be partially added, translated using a map, and/or have values replaced. |
use_xml | Indicates XML processing. Valid values: true (default), false. Optional. If nothing is specified for this field when a business process is created, the default is used. |
Business Process (BPML) Example: XML Processing
The following BPML runs the Batch Processor service. Three wfd parameters are defined: prefix_document, suffix_document, and input_document:
<process name="default">
<operation name="BatchProcessor">
<participant name="BatchProcessorService"/>
<output message="BatchProcessorInputMessage">
<assign to="input_document">InputDocument</assign>
<assign to="prefix_document">PrefixDocument</assign>
<assign to="suffix_document">SuffixDocument</assign>
<assign to="use_xml">true</assign>
<assign to="." from="*"></assign>
</output>
<input message="inmsg">
<assign to="." from="*"></assign>
</input>
</operation>
</process>
- The prefix_document name is PrefixDocument and suffix_document name is SuffixDocument. If the PrefixDocument exists, content of this document will be added to the beginning of the output document.
- If the PrefixDocument does not exist, the Batch Processor Service will look in ProcessData and apply xpath to PrefixDocument. If /ProcessData/PrefixDocument element exists, the value for that element will be added to the beginning of the output document.
- If the PrefixDocument does not exist, nor does /ProcessData/PrefixDocument element, nothing will be added to the beginning of the output document.
- The same processing rules that apply to PrefixDocument also apply to SuffixDocument, except that the SuffixDocument will be added to the end of the output document
- The input_document name is InputDocument. If InputDocument does not exist, an error will be thrown. The InputDocument contains references to other documents that enables the service to pass the output to the PrimaryDocument.
- The field use_xml indicates that XML processing is used.
The following example show a PrefixDocument that is added to the beginning of the output document:
<BatchProcessorOutput>
The following example shows a SuffixDocument that is added to the end of the output document:
</BatchProcessorOutput>
The following example shows an InputDocument:
<batchProcessor>
<fragment docname="Doc1" mapname="BatchProcessorMap1">
<replaceList>
<value>valueoffirstiteminmap1</value>
<value>valueoffseconditeminmap1</value>
<value>valueoffthirditeminmap1</value>
</replaceList>
<replaceList>
<value>valueoffirstiteminmap2</value>
<value>valueoffseconditeminmap2</value>
<value>valueoffthirditeminmap2</value>
</replaceList>
</fragment>
<fragment docname=" Doc2" mapname="BatchProcessorMap2”
xpath=” /example1/element1/batch">
<replaceList>
<value>valueoffirstiteminmap3</value>
<value>valueoffseconditeminmap3</value>
</replaceList>
</fragment>
</batchProcessor>
- This document has to be structured as the example shown below with batch processor and fragment elements.
- The fragment element has three attributes: docname, mapname, xpath. The docname is mandatory, whereas xpath and mapname are optional.
- The docname is the name of the document whose content will be added to the output document.
- The mapname is the name of the map that will translate the document.
- The xpath is applied to the document once it has been translated, and will parse out a document fragment. This document fragment will then be added to the output document.
- If value elements exist under the replaceList element, these are used for replacing values in the map. Behind the scenes, these values will be placed in ProcessData as batchProcessingVar1, batchProcessingVar2, etc. The map can then (if desired) pick up these values and replace values during translation of a document. To add this rule to a map, go to Standard Rule. Under “Please enter the Xpath to evaluate”, enter batchProcessingVar1/text() etc.
- Doc1 is added to the output document twice, but with different replacement values. Doc2 will then be added once, but only a fragment of the document will be added (since xpath is specified).
Because the InputDocument contains two replaceList under the fragment for Doc1, this document is added twice to the output document. The first time, the map replaces 3 values. The second time, the map replaces the 3 values with different values. The following example shows the Doc1 referenced in the InputDocument and added to the output document:
<example1>
<element1>
<batch>
<value>111</value>
<value>222</value>
<value>333</value>
</batch>
<tag1>tag1</tag1>
<tag2>tag2</tag2>
<tag3>tag3</tag3>
</element1>
</example1>
Because the InputDocument contains one replaceList under the fragment for Doc2, this document is added once to the output document. The map will replace 2 values. XPath is applied to the document and the remaining document fragment is added to the output document. The following example shows Doc2 referenced in the InputDocument and added to the output document:
<example2>
<element1>
<batch>
<value>111</value>
<value>222</value>
</batch>
<tag1>tag1</tag1>
<tag2>tag2</tag2>
<tag3>tag3</tag3>
</element1>
</example2>
The following example shows the result of invoking the Batch Processor service with the documents:
<BatchProcessorOutput>
<example1>
<element1>
<batch>
<value>valueoffirstiteminmap1</value>
<value>valueoffseconditeminmap1</value>
<value>valueoffthirditeminmap1</value>
</batch>
<tag1>tag1</tag1>
<tag2>tag2</tag2>
<tag3>tag3</tag3>
</element1>
</example1>
<example1>
<element1>
<batch>
<value>valueoffirstiteminmap2</value>
<value>valueoffseconditeminmap2</value>
<value>valueoffthirditeminmap2</value>
</batch>
<tag1>tag1</tag1>
<tag2>tag2</tag2>
<tag3>tag3</tag3>
</element1>
</example1>
<batch>
<value>valueoffirstiteminmap3</value>
<value>valueoffseconditeminmap3value>
</batch>
</BatchProcessorOutput>