< Day Day Up > |
In this section, we will look at several possible changes to a data source, and also at approaches to modifying the files that make up the form template. The possible types of change to the data source are as follows :
In the following sections, we will look at each of these types of modification in turn . Changing Naming in the Data SourceOne type of modification that can be made to a form template is to change the names of some or all of the elements and attributes specified by the W3C XML Schema document that forms part of the form template. Naming changes can involve some or all of the elements and attributes in the XML instance document, and can involve a change of XML namespace without changing the literal name of the elements. If the names of data source components are changed, typically the forms that contain data corresponding to the former naming scheme won't work with the new version of the form template.
An InfoPath form template cannot be submitted unless the data provided by the user is validated against the W3C XML Schema document, which is part of the form template. If one or more names don't match, validation fails. The changes you might have to make are described in the following sections. Not all changes need to be made for every form template; some are necessary only in particular circumstances. Changes in template.xmlIf the name in the data source corresponding to any element or attribute in template.xml is changed, the name of the relevant element(s) and attribute(s) must be changed to match. If you are not familiar with XML, it is easy to make editing changes that result in a file that isn't well- formed XML. To help avoid that kind of problem, I suggest you use an XML-aware editor such as XMLwriter (http://www.xmlwriter.com) or XMLSpy (http://www.xmlspy.com). Among other helpful aids, XML editors typically have a command to allow you to check well- formedness and will flag the error's apparent location. It is possible to edit XML and other InfoPath files using Notepad, but there is no support to help you edit XML correctly.
Changes in XSLT StylesheetsIn XSLT stylesheets, you might need to change the value of the match attribute of xsl:template elements to ensure that there are no unexpected blanks in the corresponding InfoPath view. In addition, look out for xd:binding attributes in the stylesheet that contain XPath expressions. You will need to edit the XPath expression at any point that corresponds to changes made in the data source. Changes in W3C XML Schema DocumentsThe names of elements and attributes declared in the form template's schema documents need to be changed to correspond to name changes in the data source. Changes in the Manifest FileIf you have created any custom interfaces, you will need to change the corresponding xsf:xmlToEdit elements. If the form template uses ActiveX Data Objects (ADO) or connects to an XML Web service, you will likely need to make changes in the data string corresponding to the changes made in the data source.
Changes in Script FilesIf you use scripting code to manipulate the XML DOM (Document Object Model), you have probably used XPath expressions somewhere in your scripting code. If the XPath expressions refer to elements or attributes whose names have been changed, the corresponding changes need to be made in the relevant parts of the XPath expressions. Adding to a Data SourceIn this section, we will look at the issues that apply when you add new structural components to a data source. Depending on what you add to the data source, the following files might need to be edited. Changes in the template.xml FileAny components added to the data source must be reflected by adding element(s) or attribute(s) to the relevant part of the template.xml file. Changes in XSLT StylesheetsYou probably won't have to edit the XSLT stylesheet(s) of the form template, because InfoPath will normally automatically add the relevant xd:binding attributes to the stylesheet when you add form controls to a view that bind to the newly added data source components. Changes in W3C XML Schema DocumentsYou will need to edit the W3C XML Schema document(s) relevant to the added component of the data source. Changes in the Manifest FileIf the form template uses ActiveX Data Objects (ADO) or connects to an XML Web service, you will need to edit the data string to correspond to the changes made in the data source. Remember that you need to open and save the manifest file after all other changes have been made to avoid InfoPath using a cached version of the form template that has not been updated. Changes in Script FilesIf you want to associate script code with the newly added component of the data source, it can be added in the normal way. Deleting from a Data SourceIn this section, we will look at the issues that apply when you choose to delete one or more structural components from an existing data source. Typically, you can expect that all forms containing the former data structure won't work with the new version of the form template. The deleted data source components will cause validation error(s). Changes in the template.xml FileElements and attributes in the template.xml file that correspond to the deleted data source components must be deleted. Changes in XSLT StylesheetsYou might need to edit the match attribute of an xsl:template element and/or the select attribute of an xsl:apply-templates element. Additionally, if the deleted data source component has a form control in the corresponding view, the relevant part of the stylesheet must be deleted. That deletion must include any xd:binding attributes that specify binding to the deleted component of the data source. In some situations, you might find it easier to delete a view and create a new one using InfoPath's graphical user interface. Changes in W3C XML Schema DocumentsElement and attribute declarations in W3C XML Schema documents that correspond to the deleted component(s) of the data source must themselves be deleted. Changes in the Manifest FileIf the form template uses ActiveX Data Objects (ADO) or an XML Web service, the part of the data string corresponding to the deleted component of the data source must be deleted. Remember that you need to open and save the manifest file after all other changes have been made to avoid InfoPath using a cached version of the form template that has not been updated. Changes in Script FilesIf existing script code references the deleted component of the data source, the relevant part(s) of the scripting code must be edited or deleted. Restructuring a Data SourceIf you move components around in the data source, you can expect that the old forms won't work with the revised form template. If you also add or delete data source components, you might also need to make the changes described in the preceding sections. Changes in the template.xml FileThe structure of the template.xml file needs to be changed to correspond to the restructured data source. Changes in XSLT StylesheetsYou might need to edit the match attribute of an xsl:template element and/or the select attribute of an xsl:apply-templates element. Edits to add or delete xd:binding attributes and the corresponding HTML code will likely also be required. Changes in W3C XML Schema DocumentsEach W3C XML Schema document will need to be edited to reflect the restructuring of the data source. If you are not familiar with W3C XML Schema, particularly for complex classes of XML instance documents, this can be a difficult task. Changes in the Manifest FileYou will need to change the data string where the form template uses ADO or connects to an XML Web service. Remember that you need to open and save the manifest file after all other changes have been made to avoid InfoPath using a cached version of the form template that has not been updated. Changes in Script FilesEdits will be required if altered components of the data source are referenced in script code. |
< Day Day Up > |