Tuesday, July 10, 2007

InfoPath Processing Instructions - what are they good for ...

Did you ever wonder how InfoPath knows which template to use when you open an XML file in a form library?

Here's the answer:


If you download one of the filled-in InfoPath forms (these are just plain XML files) to your desktop and you open it with Notepad, you will notice that the file contains a number of specific statements at the beginning of your XML file. These statements, are called processing instructions, and will contain some lines with a similar syntax to the lines listed below:

<?mso-infoPathSolution solutionVersion="1.0.0.19" productVersion="12.0.0" PIVersion="1.0.0.0" href="http://moss/SiteDirectory/infopath/Expense%20Reports/Forms/template.xsn" name="urn:schemas-microsoft-com:office:infopath:Expense-Reports:-myXSD-2007-02-12T12-04-43" ?><?mso-application progid="InfoPath.Document" versionProgid="InfoPath.Document.2"?><?mso-infoPath-file-attachment-present?><my:myFields xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-02-12T12:04:43" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">


The processing instructions are used to tell the calling application how to handle the data contained within the XML file. These processing instructions can be placed anywhere in a XML file outside of other mark-up. The processing instructions contain a href and name attributes that reference the form template that is used to load and edit the XML file. These processing instructions also allow forms that are based on a specific form template to be updated after you change the associated form template.

This means that you can actually create InfoPath forms using the System.XML namespace and by adding processing instructions you can link these automatically generated XML files to specific InfoPath form templates.

 

References:

No comments: