Modifying the Data Source

 <  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 :

  • Changing naming in the data source

  • Adding to a data source

  • Deleting from a data source

  • Restructuring a data source

In the following sections, we will look at each of these types of modification in turn .

Changing Naming in the Data Source

One 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.

CHANGING NAMESPACES

XML processors that are namespace-aware use the namespace URI and the local part to identify elements and attributes, not the literal name constituted by the namespace prefix and local part. So, an element xmml:book in a document containing the namespace declaration xmlns:xmml="http://somedomain.com/" is not the same as an xmml:book element in a document containing the namespace declaration xmlns:xmml="http://someOtherDomain.com/" .


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.xml

If 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.

XML IS CASE SENSITIVE

When editing file template files, it is important to remember that element type names and attribute names are case sensitive. It is helpful to use an XML-aware text editor to catch any well-formedness errors that might arise as a result of using case incorrectly in edited names.


Changes in XSLT Stylesheets

In 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 Documents

The 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 File

If 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.

ALWAYS OPEN AND SAVE THE MANIFEST FILE

One requirement that seems strange at first is the need to open and save the manifest file after you have made the necessary changes to other files, even if there are no changes necessary in the manifest file itself.

The need to open and save the manifest file arises because InfoPath uses a cached version of the form template, unless the manifest file has been changed. In other words, if you don't open and save the manifest file, InfoPath won't make use of any changes you have made in the other files! That can be very frustrating if you don't realize what is happening.


Changes in Script Files

If 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 Source

In 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 File

Any 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 Stylesheets

You 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 Documents

You will need to edit the W3C XML Schema document(s) relevant to the added component of the data source.

Changes in the Manifest File

If 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 Files

If 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 Source

In 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 File

Elements and attributes in the template.xml file that correspond to the deleted data source components must be deleted.

Changes in XSLT Stylesheets

You 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 Documents

Element 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 File

If 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 Files

If 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 Source

If 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 File

The structure of the template.xml file needs to be changed to correspond to the restructured data source.

Changes in XSLT Stylesheets

You 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 Documents

Each 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 File

You 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 Files

Edits will be required if altered components of the data source are referenced in script code.

 <  Day Day Up  >  


Microsoft Office InfoPath 2003 Kick Start
Microsoft Office InfoPath 2003 Kick Start
ISBN: 067232623X
EAN: 2147483647
Year: 2004
Pages: 206

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net