Introduction to form templates and forms

When you design a form template (.xsn) file, you are creating a single file that contains multiple supporting files. Conversely, when your users fill out a form, they are actually filling out a form (.xml) file, which is based on a form template.

In this article

What you design: the form template

You create form templates in design mode, which is the InfoPath design environment. A form template is a file with an .xsn file name extension. The .xsn file defines the data structure, appearance, and behavior of finished forms (.xml files).

A form template defines a lot of things, including:

After you finalize the design of a form template, you make it available to your users by publishing it as an .xsn file.

Tip: In addition to designing form templates, you can also design template parts, which are custom controls that you can use in other form templates or Microsoft Office documents. For example, you might create a template part that includes fields for collecting contact information. You could then use that template part in several different form templates. Find links to more information about template parts in the See Also section.

What your users fill out: the form

An InfoPath form is an .xml file that contains XML data. All InfoPath forms are based on form templates.

To illustrate the relationship between a form template and a form, imagine that you designed a permit application form template for electrical contractors to use. Each permit application that an electrical contractor fills out is a form. That form is just an .xml file that contains the data (and only the data) that was entered into the form. All of the other things that make up the form are provided by the form template. This means that whenever your users open a form, that form must locate and use its associated form template in order to function properly. Otherwise, when your users opened a form, they would see only XML markup tags and data.

To link a form template and the forms that are based on it, InfoPath includes several lines of code, called processing instructions, at the top of each form file. This code links the form file to its associated form template.

Components of a form template

A form template is a single file that contains multiple supporting files, such as files that define how controls on the form template should appear, files for graphics that appear on the form template, and programming files that enable custom behaviors in the form template. These supporting files are collectively known as form files. When you design a form template, you can view and work with the form files that make up the form template by extracting and saving those form files to a folder.

The supporting files that make up a form template can include one or more XML Schema files, an XSL Transformation (XSLT) file for each view in the form template, an XML file for the data that appears by default when users first open a form that is based on that form template, script files or managed code assemblies, and a form definition file, called Manifest.xsf.

To familiarize yourself with the files that make up a form template, you can use the following procedure to view the source files for a form template.

View the form files for a form template

  1. Create a new, blank form template.
  2. On the File menu, click Save As Source Files.
  3. In the Browse For Folder dialog box, select an existing folder in which to save the form files, or create a new folder, and then click OK. InfoPath saves a copy of the form template as a set of files inside the folder.
  4. In Windows Explorer, browse to the folder that contains the files.

The following table describes the supporting files of a form template. These files are always included in a form template.

File name extension

Description

Form definition file

The file that contains information about how the form template is put together, including the XML Schemas that it uses and the resource files that it contains. InfoPath automatically generates this file when you design a new form template. As you design and modify the form template, the file is automatically updated to reflect your changes.

The file or files that constrain and validate the data in a form template. The contents of XML Schema files — the elements, attributes, and so forth — are represented by groups and fields in the Data Source task pane. Each data source that is associated with a form template, including the main data source, has a corresponding .xsd file.

The XSL Transformation (XSLT) files that are used to present, view, and transform into HTML the displayed data that is contained in the form that your users fill out. When you work with the different views of a form template, you are actually looking at different HTML representations (or transformations) of the data that is displayed in the form.

The file that contains the data that you want to appear by default in specific controls. Users see this data when they first open a form and until they select different values in the controls.

In addition to the files in the previous table, a form template can include any of the files in the following table, depending on the form template's design.

File name extension

Description

.htm, .gif, .bmp, and others

The files that are used to show custom task panes or pictures within the form template.

The files that contain scripts for implementing specific form behavior. These script files are either Microsoft JScript or Microsoft Visual Basic Scripting Edition (VBScript) files.

.dll, .exe, .cab, and others

The external files that provide programming code and additional business logic. For example, if you create a custom control for your form template, you might need an installation program in order to automatically install and register that control on your users' computers. Binary files are not created in InfoPath, but in programs such as Microsoft Visual Studio .NET.

InfoPath automatically updates the form files when you make changes to your form template. However, if you are experienced with XML, or if you are an advanced form designer, you can extract the individual form files and customize them by hand. For example, you might want to manually modify a set of form files in the following types of situations: