views:

1110

answers:

3

i've tried and tried and tried but i cannot manage to step into the XslCompiledTransform without having to load the stylesheet from disk (by passing a URI into the XslCompiledTransform.Load() method).

I am fully aware that you can only step into the XslCompiledTransform.Transform() method if you loaded the stylesheet from disk via URI (as mentioned) or by loading the stylesheet from an XmlReader that implements the IXmlLineInfo interface.

I have loaded the stylesheet as follows:

XslCompiledTransform xslt = new XslCompiledTransform(true);
//grab string from textbox
XmlReader reader = XmlReader.Create(new StringReader(XsltBox.Text));

// Compile the style sheet.
xslt.Load(reader);

This seems to be, from the various literature i have read, the way in which debugging can be enabled. However when i try to step into the XslCompiledTransform.Transform() method i get the message: "There is no source code available for the current location"

as mentioned i can step into the transformation if i do the following:

string stylesheet = @"C:\PathToMy\Stylesheet.xsl";

// Enable XSLT debugging.
XslCompiledTransform xslt = new XslCompiledTransform(true);
//compile stylesheet
xslt.Load(stylesheet);

the above method is not possible as i do not wish to be reading to and from disk constantly.

any ideas?

+1  A: 

Recently Microsoft released the symbols and source code for the .Net Framework to allow for debugging in such scenarios. It takes a few seconds to setup but once you've done it you should be able to step into the Load method regardless of how you built the XslCompiledTransform.

It's too detailed to go into an SO answer but here is an excellent blog post on the subject.

http://codebetter.com/blogs/james.kovacs/archive/2008/01/17/debugging-into-the-net-framework-source.aspx

JaredPar
+1  A: 

thanks you for that useful comment, i did not realise microsoft had done this, i'm sure this will prove very helpful in future.

however, i guess i didn't make myself entirely clear in my question. i was not looking into stepping into the load method, i wanted to step into the transform method so i could see what was happening with the xsl transformation. i emphasised the load method because the parameter you pass in dictates whether you are able to debug the transform method (you must pass in an XmlReader which implements the IXmlLineInfo interface to do so).

whilst i could step into the transform method using the technique you highlighted, i would merely be stepping through the code. though i could potentially work out what was hapening with the transformation through observing the code, the xsl debugger shows the stepping through of the actual stylesheet itself line by line (as opposed to the code which executes each line of the transformation)

+1  A: 

I have been having the same problem while trying to use XmlReader.Create(new StringReader(String)). It seems the debugger must be able to find a disk file for the debugging to work but this does not mean that StringReader or stream version of XMLReader.Create cannot be used. Try this version of Create: XMLReader.Create(new StringReader(String), New XmlReaderSettings(), baseURI)

In my case I am using a file resource to store my xslt string so there is a file I can point to. In fact you do not need to give an absolute path the debugger will know to search for source code in folders that are specified under Solution/Properties/Debugger Source code.

The documentation for XslCompiledTransform is misleading because it implies that all that is requires is an XMLReader supporting the IXmlLineInfo interface.