Debugging XSLT from a Content Query WebPart
Today I receive several questions about debugging CQWP XSLT. Although I love writing them in Notepad and doing the final transformation in IE ;), it would be great to use the features of Visual Studio 2005 (I will do other post for Visual Studio 2008) in order to debug our files in MOSS, without MOSS.
As you can read in the referenced links, there are, OOB, 3 XSL files for the CQWP in MOSS. So in order to start you should take a copy of those files, and take a sample xml for your query.
The sample query can be taken from the CQWP itself, configuring the query in a test page, and adding the following element in the first template of the ContentQueryMain (lines 2-4):
xsl:call-template name="OuterTemplate" />
That will allow you to copy&paste the sample xml for your query. You shoud add the correct encoding for your data. Mine is: <?xml version="1.0" encoding="iso-8859-1"?> as the first line in the sample xml.
Then you can just open Visual Studio (you will have intellisense for XSL schema, Validation, etc..), Open the XSL files, and in the Input property of the XSL file select the sample XML. Then in the XML Toolbar, you will need to click Debug XSLT (5th button), and you are on the right way!.
In order to debug the XSLT's we will use, we will need to include the import element on the top of the Main XSL file, linking the item XSLT (line 8):
exclude-result-prefixes="x xsl cmswrt cbq"
But I couldn't get rid of the custom functions in the namespace cmswrt, so you will need to change those (as cmswrt:EnsureIsAllowedProtocol); and you will get the result in the result window: