Greyshack
Greyshack

Reputation: 1971

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.

Upvotes: 12

Views: 11414

Answers (2)

har07
har07

Reputation: 89295

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.

Upvotes: 11

Kalten
Kalten

Reputation: 4302

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);
}

Upvotes: 8

Related Questions