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:
- The controls (control: A graphical user interface object, such as a text box, check box, scroll bar, or command button, that lets users control the program. You use controls to display data or choices, perform an action, or make the user interface easier to read.), labels, and instructional text that appear on the form.
- The way that controls behave when users interact with them. For example, you might make a particular section appear when the user selects a check box and disappear when the user clears the check box.
- Whether the form has additional views (view: A form-specific display setting that can be saved with a form template and applied to form data when the form is being filled out. Users can switch between views to choose the amount of data shown in the form.). For example, if you are designing a permit application form, you may have one view for the electrical contractor, another view for the receiving agent, and a third view for the investigator who approves or denies the application.
- How and where the data in a form is stored. For example, your form template might be designed to let users submit data to a database, either directly or through the use of a Web service. Or you might have users save their form to a shared folder.
- The fonts, colors, and other design elements that are used in the form.
- Whether users can customize the form. For example, you can let users add extra rows to a repeating table, repeating section, or optional section.
- Whether users are notified when they make mistakes in the form or forget to fill out a required field.
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.
Top of Page
What your users fill out: the form
An InfoPath form is an .xml file that contains XML (Extensible Markup Language (XML): Industry-standard language for describing, organizing, and exchanging data. In InfoPath, form templates are based on XML technologies, and form data is saved or submitted in XML format.) 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 (processing instructions: Information stored in the prologue of an XML document. This information is passed through the XML parser to any application that uses the XML document.), at the top of each form file. This code links the form file to its associated form template.
Top of Page
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 (XML Schema: A formal specification, written in XML, that defines the structure of an XML document, including element names and rich data types, which elements can appear in combination, and which attributes are available for each element.) files, an XSL Transformation (XSLT) (XSL Transformation (XSLT): A language that is used to transform XML documents into other types of documents, such as HTML or XML. It is designed for use as part of XSL.) 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 (form definition file: An XML file with an .xsf extension that contains information about all other files and components used within a form, including user interface customizations, XML Schemas, views, business logic, events, and deployment settings.), 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
- Create a new, blank form template.
- On the File menu, click Save As Source Files.
- 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.
- 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
|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 (group: An element in the data source that can contain fields and other groups. Controls that contain other controls, such as repeating tables and sections, are bound to groups.) and fields (field: An element or attribute in the data source that can contain data. If the field is an element, it can contain attribute fields. Fields store the data that is entered into controls.) in the Data Source task pane. Each data source (data source: The collection of fields and groups that define and store the data for an InfoPath form. Controls in the form are bound to the fields and groups in the 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
||.htm, .gif, .bmp, and others
||The files that are used to show custom task panes (custom task pane: An .html file whose content is displayed in a window next to a form. Custom task panes can provide form-specific commands and Help content.) or pictures within the form template.
||The files that contain scripts for implementing specific form behavior. These script files are either Microsoft JScript (JScript: An interpreted, object-based scripting language that borrows from C, C++, and Java. It is the Microsoft implementation of the ECMA 262 language specification.) or Microsoft Visual Basic Scripting Edition (VBScript) (Visual Basic Scripting Edition (VBScript): A subset of the Microsoft Visual Basic programming system. At least Microsoft Internet Explorer 3, along with the other Web browsers, can read VBScript programs that are embedded in HTML pages.) 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 (custom control: A form component, such as a template part or ActiveX control, that isn't included with InfoPath by default. Form designers can add or remove custom controls by using the Controls task pane.) 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:
- You want to reuse the form template's XML Schema (.xsd file) in another Microsoft Office program. For example, you can add the InfoPath .xsd file to the Schema Library in Microsoft Office Word 2007. You can then map elements from the InfoPath .xsd file to the content of a document.
- You want to create a toolbar in the form template that contains custom commands in addition to the built-in commands that come with InfoPath. To do this, you need to edit the form template's form definition (.xsf) file.
- You want to make formatting-related enhancements to your form template that aren't available in InfoPath, such as adding a background image (.gif file) to a button. To do this, you need to edit the form's XML Transformation (.xsl) file.
Top of Page