When it comes to XML data connection in LiveCycle Designer, it can be very frustrating since we cannot embed/make data connection with more than one XML as we can do it in OLEDB data connection. But the bigger problem is, if we are embedding an XML and made the data binding of that particular field to a particular node of the XML while submitting the data it would export all those value that are in XML instead of the field values in the form. So the data connection is of little use.
1. We can use XSLT transformation to transform the out going data from the form. But if we are not using any LiveCycle server then it again becomes frustrating. We have to make the data mapping for all those fields whose value need to be exported to the values which it will fetch from the XML we are embedding. So it becomes tricky over there. We need to know the details about XML Schema and how to apply the style sheet to the XML.
2. The Simpler one : We can directly read the node values and do a bit of scripting to remove the excess nodes prior submitting.
For example :
Lets say we are embedding the following XML in a form to a DropDown field.
The field name in the form is Cust_id. What we need is that when the form is submitted it should export only the value which is selected in the DropDown. i.e. Cust_id.
Step – 1:
In the docReady event of the Cust_id we can write the folowing script.
var list = $record.CustomerInformation.nodes;
for (var i = 0; i < list.length; i++)
Explanation : – First it will store all the nodes in a variable (Array) called list.
– We have to loop through the entire array length by using list.length.
– After that using the addItem() function we can add the values based upon the nodes in the XML.
Here we have to set the binding of the field to “Normal” . As we have not made any data connection. So it would export only the field values.
Step 2 :
In the click/mouseUp event of the submit button we will write the following script.