Visual Studio 2005 may not show attributes when debugging XSLT

Visual Studio 2005 contains powerful XSLT debugging capabilities.
 
In particular, you can set breakpoints, inspect variables, parameters and XPath values and step into every template and evalution rule.
 
However, if the XSLT stylesheet defines a default namespace, evaluating attributes in the Watch or Immediate windows fails (shows value as empty).
 
Example:
Although @name shows a value under self::node() in the Locals window, a the evaluation for for self::node()/@name in the Immediate window shows {Dimension:[0]}, i.e. an empty node-set.
 
This is due to the fact that the default namespace is not applied to non-prefixed attributes.
 
Although possibly by design, this behavior may be unexpected and may cause problems with conditional breakpoints.
 
My workaround is to use @*[name()=’x’] instead of @x.
 
The solution is probably to learn more about XML namespace defaulting before doing opportunistic XSLT programming.
Advertisements
This entry was posted in Software Development. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s