|
Description
In this article I will show you how to implement an XslTransform wrapper to trace and profile XSLT transformations at runtime in .NET applications. The source code and supporting files can be downloaded from www.syscon.com/xml/sourcec.cfm.
Tests executed and results obtained to verify the execution and performance of XSLT transformations during development and testing are often not fully representative of production use case scenarios encountered in a live environment. Troubleshooting XSLT transformations that performed well during the development and testing phases but later exhibit unexpected behavior in a production environment can be a daunting task.
Random exceptions, access violations, generation of unexpected/incorrect output, and inconsistent drops in query execution performance (prolonged high CPU usage or idle times) are examples of common problems that you can encounter when executing XSLT transformations in production environments. Such problems are most commonly caused by the design of the XSLT style sheet(s) used to execute the transformations. These problems can be difficult to reproduce and troubleshoot when the source XML data is generated dynamically and varies by user, e.g., dynamically generated queries to retrieve source XML data from a SQL Server hack end, or data retrieved dynamically from external Web services.
In such situations the availability of the following diagnostic data can help significantly reduce the time to identify the cause of the problem in an XSLT transformation and take the required corrective action:
1. The context source XML data
2. The XSLT style sheet used to execute the transformation
3. An XSLT transformation trace/profiler log to the point of failure, manual termination, or completion
The context source XML data can be difficult to obtain in dynamic environments without source code modifications. The availability of this item combined with the style sheet (which is usually easily attainable, as style sheets are commonly loaded from the disk) will provide users the data they will need in recreate the problem on a development/test server.
An XSLT transformation trace/profiler log will help execute a time- and resource-efficient post mortem analysis of the failed/problematic XSLT transformation to determine the progress to the point of failure/manual termination/completion, isolate the cause of an observed problematic behavior, and take the required corrective action.
These items should be obtainable without having to resort to executing time-consuming troubleshooting steps that require the use of advanced debugging tools and/or the implementation of source code modifications. Being able to obtain diagnostic data representative of a live use case in a timely manner will facilitate faster problem isolation and resolution.
In the .NET Framework, the XslTransform type in the System.Xml.Xsl namespace implements the API to execute XSLT transformations using the .NET XSLT processor. This article details an implementation architecture that can be used to implement a wrapper for this type to trace and profile XSLT transformations at runtime in .NET applications.
XSLT Tracing Goals
Design goals
1. The tracing functionality should be fully configurable without requiring source code modifications. This is mandatory if a feature like this is to be useful in production environments. Specifically, the following aspects should be configurable:
* Enable/disable tracing. By default XSLT Tracing should be disabled. The feature is meant to be enabled and used only in troubleshooting and/or profiling scenarios.
* Configure (enable/disable) XSLT elements/instructions to be traced, e.g., trace only xsl:template instructions.
* Enable/disable the persisting of source XML data used in XSLT transformations. This option, when enabled, will help obtain the source XML data transformed by problematic XSIT transformations in dynamic environments.
* Enable/disable the deletion of trace logs and source XML data persisted by successful XSLT transformations (to prevent logs related to... |

More articles from XML Journal
Remember ebXML? Doing business in real time.(Standards), February 01, 2004 Matters of syntax: ConciseXML builds upon the important qualities of X..., February 01, 2004 Web-services transactions: from Loosely Coupled--the Missing Pieces of..., February 01, 2004 FileAct for SWIFTNet: helping financial services gain savings from the..., February 01, 2004 Rendering a connected tree using XSLT: the ideas behind XSLT and XPath..., February 01, 2004
Looking for additional articles?
Click here
to search our database of over 3 million articles.
|