Mohammed Atef’s Technical blog

Debug XSL

All of us use XSL and XML,but do you know how to debug XSL files via .net(2.0 or above)?

Really it’s very simple but I think it’s very useful also.using the following few lines of code you can debug XSL.

 XmlTextReader xmlSource = new XmlTextReader(“XMLFile1.xml”);
XPathDocument xpathDoc = new XPathDocument(xmlSource);
XmlTextReader xslSource = new XmlTextReader(“XSLTFile1.xsl”);
//note if this parameter eqaul false you can’t debug
XslCompiledTransform
xsltDoc = new XslCompiledTransform(true);
xsltDoc.Load(xslSource);
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
xsltDoc.Transform(xpathDoc, null, sw);

As you see it’s very simple just use XslCompiledTransform instead of  XslTransform

Note you can also debug XSL via
XMLSPY tool

Advertisements

February 11, 2009 - Posted by | Developement | , , , ,

No comments yet.

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

%d bloggers like this: