Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio "Start xslt debugging" option not visible

I am editing an xlst file and I cannot run it. How do I do that? Under "XML" I can only see "Create Schemas"(unclickable) and "Schemas". There should be an option to start xslt with or without debugging.

like image 207
Greyshack Avatar asked Mar 12 '16 19:03

Greyshack


2 Answers

It is plausible that you're running version of Visual Studio where XSLT debugging feature is not made available. See MSDN: Debugging XSLT :

"XSLT debugging is available in the Visual Studio Team System and the Professional Edition."

I'm currently using Visual Studio 2015 Community Edition in my personal laptop and it doesn't have XSLT debugging menu. At the same time, my work laptop has Visual Studio 2012 installed, Professional Edition if I remember correctly, and it indeed has the XSLT debugging menu available.

like image 79
har07 Avatar answered Sep 19 '22 19:09

har07


Like says in https://msdn.microsoft.com/fr-fr/library/ms255603.aspx, you must use the XslCompiledTransform class and enable debug mode in the constructor parameters.

Now when you will debug your application, VS will break on your breakpoints in your xlst file.

var xsl = new XslCompiledTransform(enableDebug :true);
xsl.Load("transform.xslt");

var reader = XmlReader.Create("file.xml");
XmlDocument doc = new XmlDocument();
doc.Load("file.xml");

var outputPath = Path.GetTempFileName();
using (var stream = File.OpenWrite(outputPath))
{
    xsl.Transform(reader, null, stream);
}
like image 21
Kalten Avatar answered Sep 16 '22 19:09

Kalten