Intellisense in XSLT

If you are using Visual Studio 2008 for XSLT development you will no doubt be familiar with the intellisense/autocomplete option for XSLT schema elements. For instance, when you type say <xsl: you will notice the intellisense dropdown that displays as shown in figure A. However, the limitation here is that when you get to actually using templates, attributes or params, defined in the xslt, intellisense does not kick in (see figure B)

Figure A: Intellisense for XSLT schema element

Figure B: Intellisense does not appear for template name

image image

Expanded Intellisense

Here is an undocumented feature of Visual Studio 2008 that now allows you to use intellisense for XSLT defined templates, attributes and params.

Intellisense for template names

image

Intellisense for param names

image

Intellisense for well-known attribute valuesimage

 

Applying the Registry Hack to enable expanded Intellisense

Here is how you can enable this feature. Now, since the below procedure involves modifying the registry, the standard cautionary note of backing up registry, and potential negative impact direct registry editing can have on your PC applies. Refer the article How to back up and restore the registry in Windows.

Now that you know what you are doing, do this -

  1. Start regedit
  2. Navigate to HKEY_CURRENT_USER\Software\Microsoft\Visual Studio\9.0\XmlEditor
  3. Create a new String Value.
  4. Set the key name as “XsltIntellisense” (without the quotes)
  5. Set the value as “True” (without quotes).

Close are relaunch Visual Studio 2008 to swing the new and expanded intellisense into action.

Caution: Bugs

There is a good reason this feature is undocumented – it has bugs.

I have noticed quite a few occasions where the intellisense suggestions do not reflect the latest changes. The only way to fix this appear to be closing the document and opening it again. This can be pretty annoying when you are creating an xslt from scratch.

Give it a spin.

If you don't like it, or if its too buggy for you then you can toggle the value of the registry key to False, or delete it to get back to the original RTM intellisense behavior.

 

- Chandra