How to add a custom intellisense and validation schema to Visual Web Developer 2005

Let's imagine that you want to add Internet Explorer 7 schema. Here what you need to do

1. Copy Program Files\VS8\Common7\Packages\Schemas\HTML\ie6_0.xsd to ie7_0.xsd.

2. Open ie7_0.xsd in VS XML editor: (File | Open | click small arrow on the Open button,

choose XML Editor) or any other text editor.

3. In the root xsd:schema element changeĀ namespace URI fromĀ IE6 to IE7, CSS schema to CSS 2.1 and change friendly name to Internet Explorer 7:

<xsd:schema version="1.0"
vs:cssschema="CSS 2.1"
vs:SuccinctFriendlyName="Internet Explorer 7">

You can leave reference to to DOM (vs:clientom attribute) unchanged as we are not changing anything in the DOM (which drive client script intellisense) at this time. If you are interested in how to change the DOM, have a look at my earlier blog posts: Part 1 and Part 2.

4. Save the file and exit Visual Studio.

5. Create a registry script to add your schema to the list of the HTML editor validation and intellisense schemas.

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\{1B437D20-F8FE-11D2-A6AE-00104BCC7269}\Schemas\Schema 21]
"Friendly Name"="Internet Explorer 7.0"

Note that here I hardcoded Schema 21 since I know that Whidbey comes with 20 schemas. You may want to check if that is true on your machine: some add-ins may install extra schemas. There should not be any gaps in numbering or your new schema won't be loaded.

7. Run the registry script (you will need admin rights), start VS, create a new HTML page and observer new schema appear in the target schema dropdown on the HTML editor toolbar.

You may ask what are those 20 schemas are for and why there are only 7 visible in the target browser dropdown. The reason is that some schemas only apply to certain file types. For example, there is a schema for Global.asax and since this and only this schema applies to this file type, the schema does not have a friendly name and does not appear in the target schema dropdown. In fact, when you open Global.asax, you'll see that target schema dropdown is disabled. The relationship between Global.asax and its schema are hardcoded. Some other schemas are 'companion' schemas. For instance, intellisense and validation on a typical Web Form file (aspx) uses target browser schema, server directives schema as well as schemas dynamically generated from server controls.

Note that in VS 2003 we were picking up all schemas in the schema folder as well as all schemas included in the project. For performance reasons we are no longer sniffing files on VS startup and are no longer monitoring file changes on disk. Therefore, all schemas must appear in the registry and when you are adding a a new schema or changing an existing one, you have restart the IDE.