.NET Framework Class Library
XslCompiledTransform Constructor (Boolean)

Initializes a new instance of the XslCompiledTransform class with the specified debug setting.

Namespace:  System.Xml.Xsl
Assembly:  System.Xml (in System.Xml.dll)
Syntax

Visual Basic (Declaration)
Public Sub New ( _
    enableDebug As Boolean _
)
Visual Basic (Usage)
Dim enableDebug As Boolean

Dim instance As New XslCompiledTransform(enableDebug)
C#
public XslCompiledTransform(
    bool enableDebug
)
Visual C++
public:
XslCompiledTransform(
    bool enableDebug
)
JScript
public function XslCompiledTransform(
    enableDebug : boolean
)

Parameters

enableDebug
Type: System..::.Boolean
true to generate debug information; otherwise false. Setting this to true enables you to debug the style sheet with the Microsoft Visual Studio Debugger.
Remarks

The following conditions must be met in order to step into the code and debug the style sheet:

Examples

The following example shows how to enable XSLT debugging.

Visual Basic
' Enable XSLT debugging.
Dim xslt As New XslCompiledTransform(true)

' Load the style sheet.
xslt.Load("output.xsl")

' Create the writer.
Dim settings As New XmlWriterSettings()
settings.Indent=true
Dim writer As XmlWriter = XmlWriter.Create("output.xml", settings)

' Execute the transformation.
xslt.Transform("books.xml", writer)
writer.Close()
C#
// Enable XSLT debugging.
XslCompiledTransform xslt = new XslCompiledTransform(true);

// Load the style sheet.
xslt.Load("output.xsl");

// Create the writer.
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent=true;
XmlWriter writer = XmlWriter.Create("output.xml", settings);

// Execute the transformation.
xslt.Transform("books.xml", writer);
writer.Close();
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0, 2.0
See Also

Reference

Other Resources

Tags :


Community Content

Dan Lash
Memory leak possibility

When setting the constructor argument to true, you might very well encounter a memory usage that is quite simply staggering.

If your application seems to be leaking memory at a rapid pace when running, and you use XslCompiledTransform, try calling the constructor with false as an explicit parameter. This will reduce the memory overhead.

The XslTransform and XslCompiledTransform classes also may leak memory if your XSLT contains a script reference. See this KB Article: http://support.microsoft.com/default.aspx/kb/316775


Amit Patankar
Re: Memory leak possibility

The memory leak is a pain, especially if you have scripts inside your xsl's in which case there is IL created on every transform and the handles and memory are not released until the appdomain is released.

I am facing this issue today in one of my applications running as a windows service. The suggestion to use a static / singleton xsl transformation object / class is not an option in my situation.

If you do have a choice designing an application which has to use the XslCompiledTransform class, please look at http://support.microsoft.com/default.aspx/kb/316775/EN-US/.

This issue is still present in the current version (3.5) of .Net framework.


Page view tracker