Exploring the Contents of Form Template Files

The form template (originally XDocs solution) files you save with the .xsn extension are compressed archives, which Microsoft calls CAB (for cabinet) files. You can open .xsn files in WinZip 8.1 SR1+ or a similar compression utility and extract the files, but you can't add or replace archive files (see Figure 26.15).

Following are brief descriptions of files included in the example ChangeOrder.xsn archive:

  • manifest.xsf is an XML file that lists the other files required by the template and, if your form connects to an Access or SQL Server database, the OLE DB connection string for the database. Every .xsn file has one manifest.xsf file of the Microsoft InfoPath Form Definition File type. You can open a form from manifest.xsf, make design changes, and save the form as an .xsn file with its original file name.

    Figure 26.15. WinZip 8.1 SR1 shows the files in the .xsn archive, but the Add toolbar button and File menu choice are disabled.

    graphics/26fig15.gif

  • schema.xsd is the underlying XML schema for the form. All forms require schema.xsd; some forms have more than one schema. For example, forms bound to a database table require schema1.xsd and schema2.xsd to define the ADO Recordset for query and data display views.

  • template.xml is an XML document that serves as a template for forms you complete. All elements of template.xml are empty, which is another way of saying the elements contain no text. Every .xsn file has a template.xml file.

  • view_1.xsl is an XSL Transformations (XSLT) file that generates the Extensible HTML (XHTML) code to enable display of the form in a browser. Every .xsn file has at least one .xsl file but the file name(s) might differ. If the form has more than one view, there's an .xsl file for each view of the data.

  • sample.xml is a version of template.xml with shorthand notation for empty elements <co:singleName/> instead of <co:singleName></co:singleName>. Forms bound to an ADO Recordset have a sampledata.xml file with empty attribute values.

  • script.js is present only if your forms contain JScript event-handling code. All templates you save from InfoPath sample forms contain script.js. If you choose VBScript as the default scripting language, script.vbs replaces script.js.

  • currencies.xml and currencies.xsd are the XML document and schema, respectively, for the secondary data source that fills the Currencies list. The .xsn file must contain the .xml and .xsd files for each secondary data source of your form that relies on XML documents. You also can specify Access or SQL Server tables and queries as secondary data sources.

To extract all files from an .xsn archive, choose File, Extract Form Files, specify the folder that contains the .xsn archive in the Browse for Folder dialog, and click OK.

Creating an Abbreviated Currencies Data Source

You can author your own XML file to serve as the secondary data source for a drop-down list or connect to a lookup table or query. In this respect, InfoPath lists resemble Access combo boxes quite closely. You also can modify an existing XML file to better suit the purpose of the list.

The Currency list contains entries for most of if not all the world's currencies. Do the following to create a short list of the currencies that your organization is willing to use in transactions:

  1. Create a copy of currencies.xml as commoncurs.xml, and currencies.xsd as commoncurs.xsd. XML documents used as secondary data files require a corresponding .xsd file.

  2. Open commoncurs.xml in Notepad and delete the elements for currencies that you don't want to appear in the list. Figure 26.16 shows a file that includes 14 common North American, European, Scandinavian, and Asian currencies.

    Figure 26.16. This short version of the currencies.xml file has elements for 14 common currencies. The small rectangular symbols represent two byte currency symbols that don't display in NotePad.

    graphics/26fig16.jpg

  3. Press Ctrl+S to save the edited file and close Notepad.

Changing a Secondary Data Source

You can substitute a modified XML document for the original version, but removing the original XML file and substituting a new one is a more common practice. To change the secondary data source from currencies.xml to commoncurs.xml, do the following:

  1. Make a backup copy of ChangeOrder.xsn in case you encounter a problem.

  2. graphics/design_view.gif Open ChangeOrder.xsn in design mode, and choose Tools, Secondary Data Sources to open the dialog of the same name.

  3. With currencies selected, click the Remove button and confirm your choice.

  4. Click Add to open the Data Source Setup Wizard and accept the Default XML Data File option. Click Next.

  5. In the second Wizard dialog, click Browse, select the commoncurs.xml file, and click Next.

  6. In the third Wizard dialog, and change the name of the data source from commoncurs to currency, which is the name of the data source for the Currency list (see Figure 26.17). Verify that the Connect to This Secondary Data Source When the Form Is Opened check box is marked, and click Finish.

    Figure 26.17. By default, the Data Source Setup Wizard uses the source XML document's filename as the Data Source name. Changing the name to that of the original data source retains the list's binding.

    graphics/26fig17.gif

    Tip

    When changing a control's secondary data source, always use the original data source name to avoid unexpected results. You can avoid step 4 by clicking Modify in step 3 and selecting the new .xml file to replace the original.

    If you don't change the data source name to currency, you must right-click the Currency list, choose Drop-Down List Box Properties to open the properties dialog, and select commoncurs in the Data Source list.

  7. Click Yes to add the file to the form template file.

  8. Click OK to close the Secondary Data Source dialog.

  9. Click Preview Form and open the Currencies list to verify the change (see Figure 26.18).

    Figure 26.18. Opening the list in form preview mode confirms the secondary data source change.

    graphics/26fig18.gif

  10. Click Close Preview and press Ctrl+S to save your changes.

Unfortunately, changing the primary data source for a form isn't as simple as a secondary data source.

To learn how to alter the primary data source, see "Changing a Form's Primary Data Source," p. 1134.




Special Edition Using Microsoft Office Access 2003
Special Edition Using Microsoft Office Access 2003
ISBN: 0789729520
EAN: 2147483647
Year: 2005
Pages: 417

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