Intellisense in onet.xml

Intellisense in onet.xml

This post is the first of several in which I will address issues that are asked during projects on which I work. Of course, to protect confidential information, any names or business related information are changed.
I am a big fan of knowing the nitti gritty details of how a system works. This enables me to piece together an efficient and effective solution that does not contain functionality I or the customer do not need or want.
In SharePoint development, this means wirting, or at least knowing how to write, a site defintion, and the first step is to work with onet.xml. I do prefer to write my own onet.xml since it gives me greater control, however this can be a tedious task unless you have good tools.
To ease the creation of onet.xml in Visual Studio you should use intellisense. By default, Visual Studio does not intellisense onet.xml, but you can make it do so either on a file-by-file basis or for every file, onet.xml or otherwise, that uses a given namespace.
To get intellisense for a single file, open the file i Visual Studio and go to the properties tab, often located on the bottom right:

In the Schema-field, clikc the three dots to browse for a schema file. Find the wss.xsd-file, usually located in ‘C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\XML’ and click add. That’s it, Visual Studio should now give you intellisense. Test this by placing the cursor at the very beginning of the file and press CTRL+Space. You should see a drop-down such as this:

Now, to tell Visual Studio to use the correct xsd-file (wss.xsd) every time you create an onet.xml-file you need to link an xml-namespace to the wss.xsd file. To do this you need to create one more xml file and also remember to use the correct namespace for your onet.xml files.

First, create a new XML-file in C:\Program Files\Microsoft Visual Studio 8\Xml\Schemas. Call it whatever you like, for instance SharePointCatalog.xml. Open the file and paste in the following:

href="C:/Program Files/Common Files/Microsoft Shared/web server extensions/12/TEMPLATE/XML/wss.xsd"
targetNamespace="" />

What this actually does is link the ‘targetNamespace‘ with the schema located in ‘href‘. You can use the same technique to link your own schema to any namespace if you use those.

Now, to get Visula Studio to use the intellisense with the schema, add the namespace attribute to the root elemet of your XML file, for instance:


If you now hit CTRL+Space you should get intellisense.

Found this article valuable? Want to show your appreciation? Here are some options:

a) Click on the banners anywhere on the site to visit my blog's sponsors. They are all hand-picked and are selected based on providing great products and services to the SharePoint community.

b) Donate Bitcoins! I love Bitcoins, and you can donate if you'd like by clicking the button below.

c) Spread the word! Below, you should find links to sharing this article on your favorite social media sites. I'm an attention junkie, so sharing is caring in my book!

Pin It

New SharePoint demonstrations in Norwegian

NittiTre, my employer of sorts, are currently making available a series of SharePoint screencast videos. So far, all videos have been made by yours truly. The videoes show off different aspects of SharePoint, from basic functionality to more advanced topics such as customization, sequential and statemachine workflows and other stuff.

Now, I am given quite a lot of liberty in deciding what these videos should cover so if you have tips or suggestions, please let me know.

The most recent video shows document generation from SharePoint data and also includes code from the book Pro SharePoint Solution Development by author Ed Hild. Ed has been very generous in letting us use his code and I would like to thank him again for being a great sport about this.

You should check out his book at APress and his blog at MSDN if you are interested in working with Office documents and SharePoint. The book is highly recommended.

The screencasts are available both online and for download at, however, they are only available with Norwegian narration.

Pin It