Launch Files with Extensions Other Than .XML in InfoPath - Greg Collins
in

InfoPath Dev

This Blog

Syndication

Greg Collins

Launch Files with Extensions Other Than .XML in InfoPath

If you or your company has been using XML files for a while you may have a large collection of them with file extensions other than .xml. Let's assume that these files have the extension .xdf (XML Data File). InfoPath will allow you to use these .xdf files as main or secondary data sources without renaming their extension. By typing the full path and filename, including the .xdf extension, InfoPath will use your file provided it contains valid XML.

In this task we will show how to have these .xdf files launch in InfoPath when you double-click them. This can be accomplished with relatively few changes as described below.

PREPARE YOUR .XDF FILES TO OPEN LAUNCH IN INFOPATH

There are a few lines of XML code known as processing-instructions (PIs) that must exist at the top of your .xdf files. These PIs can be found at the top of any existing InfoPath .xml file. You must make sure that you get them from an .xml file created using the form template you expect the .xdf file to open with. You will also need to declare the InfoPath form namespaces on the root element of your .xdf file. Let's take a look at these changes:

The XML declaration processing-instruction:

<?xml version="1.0" encoding="UTF-8"?>

The first line of your .xdf file is the XML declaration PI. You should be able to copy this as is, unless you are using an encoding other than UTF-8. If so, make the adjustment.

The InfoPath processing-instructions:

<?mso-infoPathSolution name="..." solutionVersion="1.0.0.1" productVersion="11.0.6357" PIVersion="1.0.0.0" href="..." ?>

The second line of your .xdf file is the InfoPath mso-infoPathSolution PI. This is used by InfoPath for a variety of purposes. We won't go into each of the attributes here, but they should match with a form produced by the latest version of your form template.

<?mso-application progid="InfoPath.Document"?>

The third line of your .xdf file is the InfoPath mso-application PI. This tells the file system that this file belongs to InfoPath.

The InfoPath namespaces:

<RootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:my="..." xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xml:lang="en-us">

There can be any number of namespaces declared. You must verify that all namespaces declared in your sample .xml file, produced by your form template, is present on the root element of your .xdf file.

CREATE AN OPEN ACTION FOR THE .XDF FILE TYPE

Now that your .xsd files have the PIs and namespaces added, you need to tell the operating system what to do when you double-click an .xdf file.

Identify the action required to open in InfoPath:

  1. In Windows Explorer, choose Folder Options from the Tools menu.
  2. On the File Types tab of the Folder Options dialog box, type the letters INFOPA to quickly navigate to the INFOPATHXML file type.
  3. Click Advanced.
  4. Select the Open action, and then click Edit.
  5. Copy the information used to open this file type (you'll use it for your .xdf files)
  6. Click Cancel twice to return to the Folder Options dialog box.

Set the open action for .xdf files:

  1. Click in the list of file types to set the focus.
  2. Type the letters XDF to quickly navigate to your XDF file type.
  3. Click Advanced.
  4. If an Open action exists, click Edit. Otherwise click New to create one.
  5. Enter the information you copied previously.
  6. Click OK three times to save your settings.

Try it:

That's it! Now double-click one of your updated .xdf files to launch it in InfoPath.

©2004 Greg Collins. All rights reserved. Licensed to Autonomy Systems, LLC for display on InfoPathDev.com.

Comments

No Comments
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.