Tuesday 28 June 2005 — This is more than 19 years old. Be careful.
I was looking at a file with an extension of .xml in the Windows explorer today. It had an unfamiliar icon associated with it. I tried dragging it onto Internet Explorer to see the XML, and was asked if I wanted to open it. I answered yes, and Office Infopath opened! “Since when does Infopath own .xml files?” I wondered. I’d never used Infopath before, and hadn’t recently installed it or anything.
Looking in the XML file, I saw this processing instruction:
<?mso-application progid="InfoPath.Document"?>
Hmmm, this seems to be an application linkage for the file! Sure enough, if I edited the progid to make it bogus, the icon in the explorer changed to a generic XML file icon, and I could now drop the file on IE and have it show me the XML.
I’d never heard of this before, but seems useful, and necessary. If XML is going to be a universal data solvent, then we’ll need some way other than file extensions to determine how to launch applications from documents. I just had no idea the shell was willing to parse XML to find the application.
Of course, the progid can be any progid, for example, here’s an example of using XSLT to create Word documents that uses this processing instruction to get the data hooked up with the application.
Comments
Why would every program that uses an XML based format use a .xml extension? Why not use a different extension?
(Though this PI is useful anyway.)
As for the file name extensions business, see here for a much better way to assign data types to files. But being able to tell a file's type is a separate issue to deciding what software should open/edit/print/etc it.
(since when is adding a PI "extending xml", btw?)
Oh, and anything Andrew says has to be taken with (at least) a grain of salted humor...
And there was much rejoicing!
(yay)
In fact it would be nice if the W3C made a recommendation in the vein of http://www.w3.org/TR/xml-stylesheet/, but for media types:
something like this:
<?xml-type application/ms-infopath.xml?>
(This seems to be the correct media type for InfoPath)
It would be more standardized, and would also make it easier to serve xml files with the right type.
I'm sure that Windows is looking up the "progid" string someplace in the registry and then from that determining what executable to launch, but I can't piece together how it works to enable me to leverage it myself. Any hints?
There are of course lots of problems with this way of doing it, but damn, it sure would seem wasteful to have the os checking against the .xml extension all the time.
Add a comment: