Processing Collections with Extended Binding


Scenario

We want to display an extract of a user's purchases of the last two months in a document. The data required for this is already supplied from a specialist application as a valid connect file:

<OneOffixxConnectBatch xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schema.oneoffixx.com/OneOffixxConnectBatch/1"> <Settings> <Add key="CreateConnectorResult">true</Add> </Settings> <Entries> <OneOffixxConnect> <Arguments> <LanguageLcid>1031</LanguageLcid> <TemplateId>2e221a62-c9ec-4f4d-89d5-b0919c249867</TemplateId> </Arguments> <Function name="CustomInterfaceConnector" id="70E94788-CE84-4460-9698-5663878A295B"> <Arguments> <Interface Name="PurchaseInterface"> <Customer> <CustomerNumber>974853</CustomerNumber> <Name>Buyer</Name> <FirstName>Brian</FirstName> </Customer> <Purchases> <Purchase> <Id>927859198.123</Id> <Date>10.12.2019</Date> <Payment>Paid</Payment> <Delivery>Delivered</Delivery> <Amount>120.10</Amount> </Purchase> <Purchase> <Id>1234539198.527</Id> <Date>15.01.2020</Date> <Payment>Paid</Payment> <Delivery>Delivered</Delivery> <Amount>230.55</Amount> </Purchase> <Purchase> <Id>456454198.527</Id> <Date>15.01.2020</Date> <Payment>Paid</Payment> <Delivery>Delivered</Delivery> <Amount>15.55</Amount> </Purchase> <Purchase> <Id>877906786.527</Id> <Date>18.01.2020</Date> <Payment>Pending</Payment> <Delivery>Delivered</Delivery> <Amount>145.80</Amount> </Purchase> <Purchase> <Id>9678567.527</Id> <Date>09.02.2020</Date> <Payment>Pending</Payment> <Delivery>Pending</Delivery> <Amount>20.90</Amount> </Purchase> </Purchases> </Interface> </Arguments> </Function> </OneOffixxConnect> </Entries> </OneOffixxConnectBatch>

Since we do not know how many entries have to be mapped in the document, it is not possible to build the template statically. Therefore, we need an extended binding and a collection.


Definition of the collection in the interface definition

The first thing to do is to create the Connect interface definition:

<InterfaceDescription Name="PurchaseInterface"> <!-- Evaluation of the data for <Customer></Customer> --> <Node Id="PurchaseInterface.Customer.Name" XPath="./Customer/Name">[Customer Name]</Node> <Node Id="PurchaseInterface.Customer.FirstName" XPath="./Customer/FirstName">[Customer Firstname]</Node> <Node Id="PurchaseInterface.Customer.CustomerNumber" XPath="./Customer/CustomerNumber">[Customer Number]</Node> <!-- Evaluation of the data for <Purchases></Purchases> --> <NodeCollection Id="PurchaseInterface.Purchases" XPath="./Purchases/Purchase"> <Node Id="PurchaseInterface.Purchase.Id" XPath="./Id">[Puchase Id]</Node> <Node Id="PurchaseInterface.Purchase.Date" XPath="./Date">[Puchase Date]</Node> <Node Id="PurchaseInterface.Purchase.Payment" XPath="./Payment">[Pending]</Node> <Node Id="PurchaseInterface.Purchase.Delivery" XPath="./Delivery">[Pending]</Node> <Node Id="PurchaseInterface.Purchase.Amount" XPath="./Amount">[Amount]</Node> </NodeCollection> </InterfaceDescription>

Running the Connect file now results in the following data in the CustomXML part:

<Interfaces windowwidth="0" windowheight="0" minwindowwidth="0" maxwindowwidth="0" minwindowheight="0" maxwindowheight="0"> <NodeGroup id="PurchaseInterface" row="0" column="0" columnspan="0" label="PurchaseInterface" visible="True"> <Text id="PurchaseInterface.Customer.Name" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Customer.Name" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Buyer]]></Text> <Text id="PurchaseInterface.Customer.FirstName" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Customer.FirstName" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Brian]]></Text> <Text id="PurchaseInterface.Customer.CustomerNumber" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Customer.CustomerNumber" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[974853]]></Text> <Collection id="PurchaseInterface.Purchases"> <Element> <Text id="PurchaseInterface.Purchase.Id" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Id" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[927859198.123]]></Text> <Text id="PurchaseInterface.Purchase.Date" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Date" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[10.12.2019]]></Text> <Text id="PurchaseInterface.Purchase.Payment" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Payment" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Bezahlt]]></Text> <Text id="PurchaseInterface.Purchase.Delivery" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Delivery" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Geliefert]]></Text> <Text id="PurchaseInterface.Purchase.Amount" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Amount" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[120.10]]></Text> </Element> <Element> <Text id="PurchaseInterface.Purchase.Id" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Id" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[1234539198.527]]></Text> <Text id="PurchaseInterface.Purchase.Date" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Date" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[15.01.2020]]></Text> <Text id="PurchaseInterface.Purchase.Payment" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Payment" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Bezahlt]]></Text> <Text id="PurchaseInterface.Purchase.Delivery" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Delivery" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Geliefert]]></Text> <Text id="PurchaseInterface.Purchase.Amount" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Amount" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[230.55]]></Text> </Element> <Element> <Text id="PurchaseInterface.Purchase.Id" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Id" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[1234539198.527]]></Text> <Text id="PurchaseInterface.Purchase.Date" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Date" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[15.01.2020]]></Text> <Text id="PurchaseInterface.Purchase.Payment" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Payment" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Bezahlt]]></Text> <Text id="PurchaseInterface.Purchase.Delivery" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Delivery" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Geliefert]]></Text> <Text id="PurchaseInterface.Purchase.Amount" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Amount" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[15.55]]></Text> </Element> <Element> <Text id="PurchaseInterface.Purchase.Id" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Id" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[1234539198.527]]></Text> <Text id="PurchaseInterface.Purchase.Date" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Date" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[18.01.2020]]></Text> <Text id="PurchaseInterface.Purchase.Payment" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Payment" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Ausstehend]]></Text> <Text id="PurchaseInterface.Purchase.Delivery" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Delivery" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Geliefert]]></Text> <Text id="PurchaseInterface.Purchase.Amount" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Amount" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[145.80]]></Text> </Element> <Element> <Text id="PurchaseInterface.Purchase.Id" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Id" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[1234539198.527]]></Text> <Text id="PurchaseInterface.Purchase.Date" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Date" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[09.02.2020]]></Text> <Text id="PurchaseInterface.Purchase.Payment" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Payment" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Ausstehend]]></Text> <Text id="PurchaseInterface.Purchase.Delivery" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Delivery" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[Ausstehend]]></Text> <Text id="PurchaseInterface.Purchase.Amount" row="0" column="0" columnspan="0" multiline="False" multilinerows="3" locked="False" label="PurchaseInterface.Purchase.Amount" readonly="False" visible="True" required="False" regex="" validationmessage="" tooltip="" tracked="False"><![CDATA[20.90]]></Text> </Element> </Collection> </NodeGroup> </Interfaces>

The next step is to bring the content of the NodeGroup into the document. For Name, FirstName and CustomerNumber this can be done normally via the editor. From the following screenshot you can also see that the nodes of the collection are also available.

 

But: Since we have five possible values for a NodeId, these cannot be inserted just like that. If these nodes are inserted directly in the document, then the resulting document would look like this:


The Extended Binding

All entries are missing except the first one. This can only be solved with an extended Binding:

 

With this extended binding the document looks like this after generation

 

PrimeSoft AG, Bahnhofstrasse 4, 8360 Eschlikon, Switzerland