InfoPathGen
Dealing With Changes to a Form's Data Source [InfoPath 2003 SDK Documentation]
Applies to:
- Microsoft Office InfoPath 2003
For information on Service Pack 1 updates to working with XML schemas or files as data sources, see "Replace the data source with an updated XML Schema" in the InfoPath 2003 Help. For information on improvements to working with databases or Web services, see "Update the main data connection to a database or Web service".
When you design a form, Microsoft Office InfoPath 2003 assumes that the form's data source is in it's final state. InfoPath doesn't adapt to changes in the form's data source. This article discusses how to update the data source information in your form when the source schema changes.
Note You should create a backup copy of your form files before you modify them.

Change the naming scheme of the form's data source
Difficulty Level of Change: Easy
Effect of Change: All XML forms will become incompatible with the data source schema unless they are updated with the new naming convention.
For each item that is renamed in the data source, a corresponding item has to be updated in the InfoPath form files. For XML schema-based solutions, this will encompass the following files and changes:
- The form definition file (.xsf) All xmlToEdit [ http://msdn.microsoft.com/en-us/library/aa205254(office.11).aspx ] elements in the form definition file (.xsf) must be modified to correspond to the new naming conventions. If your form is based on an ActiveX Data Objects (ADO) or an XML Web service data source, then you must update the query strings to conform to the new names.
- The form's XML template file Element and attribute entries in the form's XML template file that correspond to the changed items in the data source must be changed to reflect the new names.
- All Infopath-generated XML schema (.xsd) files Element and attribute entries in the form's XML schema files that correspond to the changed items in the data source must be changed to reflect the new names.
- All InfoPath-generated XML stylesheet (.xsl) files Any XML stylesheet files in the solution must be updated with the new data source naming conventions. The xsl:apply-templates element and the value of the match attribute of xsl:template elements must be modified to reflect the new names.
- The form's script files Scripting code may refer to data in XPath statements. Those XPath statements that correspond to the changed items in the data source must be changed to reflect the new names.

Add data elements to an existing data source
Difficulty Level of Change: Moderately Difficult
Effect of Change: All XML forms will open with the new schema except when the schema additions are required.
Adding data elements to a data source will require consequent changes to the structure of the data to facilitate use of the added elements in InfoPath.
- The form definition file (.xsf) If your form is based on an ActiveX Data Objects (ADO) or an XML Web service data source, then you must update the query strings to retrieve the added items.
- The form's XML template file The form's XML template file must be modified to conform to the new schema.
- All Infopath-generated XML schema (.xsd) files All element and attribute entries in the form's XML schema files must be modified to conform to the new schema.

Delete data elements from an existing data source
Difficulty Level of Change: Difficult
Effect of Change: All XML forms will become incompatible with the data source schema unless they are updated to reflect the new structure. Views may fail to render some content if template matches fail.
Deleting data elements from a data source requires that you remove the corresponding references to the removed data elements from the form. The following files should be modified when you remove data elements from your form's data source:
- The form definition file (.xsf) If your form is based on an ActiveX Data Objects (ADO) or an XML Web service data source, then you must remove references to the deleted data elements from the query strings.
- The form's XML template file Element and attribute entries in the form's XML template file that correspond to the deleted data elements must be removed.
- All Infopath-generated XML schema (.xsd) files Element and attribute entries in the form's XML schema files that correspond to the deleted data elements must be removed.
- All InfoPath-generated XML stylesheet (.xsl) files The xsl:apply-templates element and the values of match attributes of xsl:template elements that refer to the deleted data elements must be changed or removed. Removal of a root xsl:template element will require you to rebuild the view. In this case, it may be easier to remove the view and rebuild it in design mode.
- The form's script files Script may refer to data in XPath statements. Those XPath statements that correspond to the deleted elements in the data source must be removed.

Moving data elements in an existing data source
Difficulty Level of Change: Difficult
Effect of Change: All XML forms will become incompatible with the data source schema unless they are updated to reflect the new structure. Views may fail to render some content if template matches fail.
Moving data elements in the data source is the equivalent of deleting, then adding data elements. To implement the changes in your form, you must perform the operations listed in the Delete data elements from an existing data source and Add data elements to an existing data source sections.