Click here to Skip to main content
Click here to Skip to main content

XML Namespace Shell Extension

, 23 Aug 2004
Rate this:
Please Sign up or sign in to vote.
A shell extension to associate applications with particular XML namespaces.

Sample Image - XmlNamespaceShell.png

Introduction

This utility allows you to associate a different editor with an XML namespace, while keeping your existing file associations intact.

Background

If you have ever used the Microsoft Office 2003 Save as XML feature in Word or Excel, you will have seen that although the file has a .xml file extension, it still opens with the appropriate Office application. Digging a little deeper, you will see that there is a processing instruction <?mso-application progid="Word.Document"?> in the XML file that the Office shell extension reads, to determine which application to open.

Although this is a cool feature, it is a bit limited because:

  1. It is not extensible.
  2. If it was extensible, you would need to modify your existing XML documents to include a processing instruction.

With these problems in mind, I started looking for some code to:

  1. Intercept the shell invoke on XML documents.
  2. Read the root element of the XML to determine the namespace.
  3. Determine which application to open.
  4. If the namespace has no application associated, default to the original file extension handler.

I found the Creating a shell extension with C# article by Richard Birkby which is almost a perfect fit for the shell extension I needed. I have also used the isolated storage class from Persisting Application data using HashTable and IsolatedStorage by T Manjaly for storing the associations per user.

Using the code

The bulk of the code is best explained by the two excellent articles referenced above.

The application consists of an exe and a DLL. The exe is used to install and uninstall the shell extension (the DLL), and to add and remove namespaces. Once the extension is installed, you can use the menu to add and remove namespaces on the fly without needing to uninstall.

Using the example in the screenshot above, any XML documents that have http://www.w3.org/1999/XSL/Format as the namespace on their root element, will open with Notepad.exe.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Colin Savage
Web Developer
United States United States
No Biography provided

Comments and Discussions

 
GeneralWhat's wrong of PinsussAnonymous24-Aug-04 9:03 
GeneralRe: What's wrong of PinmemberColin Savage24-Aug-04 9:55 
With hundreds of files with .xml file extension, but with xml content in different xml namespaces, some content is more suitable to a particular editor or viewer.
 
Perhaps this link will help to understand xml namespaces? http://www.w3.org/TR/1999/REC-xml-names-19990114/

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141220.1 | Last Updated 24 Aug 2004
Article Copyright 2004 by Colin Savage
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid