Import structured data via generic mapping
For some reasons, Northwest Products may have decided to use their own XML data format. They do not want to convert it to the standard Kofax Capture XML Import Connector format. However, they do not want to bound to the same batch class/document class names. Instead, they want to provide additional attributes in the incoming XML data to select a particular batch class and form type. This requires generic XML mapping.
To link other documents from the controlling XML, all needed to be imported at the same time. For example, in the case of folder import, use trigger files or subfolder processing.
These are their sample XML input document and XML schema.
<?xml version="1.0" encoding="UTF-8"?>
<OrdersGeneric xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="OrderGeneric.xsd">
<Order PONumber="42367" BatchClassName="KfxSampleXmlMappingBatch" FormTypeName="KfxSampleXmlMappingForm">
<ShipTo>
<FirstName>Martin</FirstName>
<LastName>Janeway</LastName>
</ShipTo>
<Articles>
<Article>
<Quantity>1</Quantity>
<ItemNr>638</ItemNr>
<Description>LANG STERLING PIE SERVER</Description>
<UnitPrice>32.95</UnitPrice>
<Amount>32.95</Amount>
</Article>
</Articles>
<Subtotal>32.95</Subtotal>
<SalesTax>2.55</SalesTax>
<Shipping>5.00</Shipping>
<Total>40.50</Total>
</Order>
</OrdersGeneric>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="OrdersGeneric">
<xs:complexType><xs:sequence>
<xs:element name="Order" maxOccurs="unbounded">
<xs:complexType><xs:sequence>
<xs:element name="ShipTo">
<xs:complexType><xs:sequence>
<xs:element name="FirstName" type="xs:string"/>
<xs:element name="LastName" type="xs:string"/>
</xs:sequence></xs:complexType>
</xs:element>
<xs:element name="Articles">
<xs:complexType><xs:sequence>
<xs:element name="Article">
<xs:complexType><xs:sequence>
<xs:element name="Quantity" type="xs:integer"/>
<xs:element name="ItemNr" type="xs:unsignedInt"/>
<xs:element name="Description" type="xs:string"/>
<xs:element name="UnitPrice" type="xs:decimal"/>
<xs:element name="Amount" type="xs:decimal"/>
</xs:sequence></xs:complexType>
</xs:element>
</xs:sequence></xs:complexType>
</xs:element>
<xs:element name="Subtotal" type="xs:decimal"/>
<xs:element name="SalesTax" type="xs:decimal"/>
<xs:element name="Shipping" type="xs:decimal"/>
<xs:element name="Total" type="xs:decimal"/>
</xs:sequence>
<xs:attribute name="PONumber" type="xs:int" use="required"/>
<xs:attribute name="BatchClassName" type="xs:string"/>
<xs:attribute name="FormTypeName" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence></xs:complexType>
</xs:element>
</xs:schema>
- Add a new XML type "GenericOrders" using the XML file and the schema file.
- Add a new destination. Assign it to any available batch class (this batch class will only be used if the batch class specified in the XML input is not available). Do not forget to add a proper routing rule.
- Select "GenericOrders" as the XML type of the destination and select Generic XML mapping.
- Select to import original content (to Kofax Capture) but deactivate any conversions to TIF or PDF.
-
Create the desired mapping via MapForce and save it. Restart
KC Plug-In
afterwards.
Alternatively, if you do not have MapForce, you can use the sample files from Samples\DemoMapping\GenericMapping\SampleGenericMapping. Click Show files for Visual Designer and copy all sample files to this folder.
These are the usual steps in generic mapping:
- Map XML elements or attributes in the input.xml carrying class names directly to the corresponding attributes in the output.xml (see 1 in the screen shot below).
- Required source elements or attributes in the input.xml document must be mapped to the corresponding name/value attribute pair in the output.xml document. The element’s/attribute’s name would control the name, and its value controls the value attribute in the corresponding position in the output.xml (see 2 in the screen shot below). This can be accomplished via MapForce’s function block name(). If there are several element/attribute pairs to be mapped as separate index fields on the same output hierarchy (such as in the same document), it is necessary to duplicate the IndexField element in the output.xml to get more instances of the IndexField and map other source elements there. For example, see how source elements “Subtotal” and “SalesTax” have been mapped in the step 2 below)
- All received attachments and even the XML file itself are listed in the Pages sequence in the input.xml. If they should also be imported to Kofax Capture, the corresponding “ImportFileName” attribute must be explicitly mapped to the “ImportFileName” (and optionally to “OriginalFileName”) attribute of the desired Page in the output.xml. See 3 in the screen shot.

During the generation of the mapping in MapForce, it is possible to see how the sample XML document (of the destination's XML type) would be mapped using the current mapping. In our case, it would look like this:
<?xml version="1.0" encoding="UTF-8"?>
<Batch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:/ProgramData/Kofax/KCIC-E~1/KCPLUG~1/config/Schemas/SampleGenericDestination2/output.xsd" BatchClassName="KfxSampleXmlMappingBatch">
<Documents>
<Document FormTypeName="KfxSampleXmlMappingForm">
<IndexFields>
<IndexField Name="Subtotal" Value="32.95"/>
<IndexField Name="SalesTax" Value="2.55"/>
</IndexFields>
<Pages>
<Page ImportFileName="filename.ext" OriginalFileName="filename.ext"/>
</Pages>
</Document>
</Documents>
</Batch>
Once all desired mappings are done, the final mapping would look like this:
