SIGN UP MEMBER LOGIN:    
ARTICLE

Performance Comparison of XslTransform Inputs

Posted by Daniel Stefanescu Articles | XML in C# May 02, 2002
To transform XML into HTML for use on a Web site or to transform it into a document that contains only the fields required you could use the XSLTransform class (found in the System.Xml.Xsl namespace).
Reader Level:
 

Description

To transform XML into HTML for use on a Web site or to transform it into a document that contains only the fields required you could use the XSLTransform class (found in the System.Xml.Xsl namespace). The XSL transformation uses as input document an XML document through three classes which implements XPathNavigator and IXPathNavigable interface: XmlDocument, XmlDataDocument and XPathDocument. 

XmlDocument class (found in the System.Xml namespace):

This class can be used in cases where a DOM structure must be edited first before XSL transformation. The class extends the XMLNode class. 

XMLDataDocument class (found in the System.Xml namespace):

This class extends the XMLDocument class and can be used when working with Datasets. Provides access either to relational data (through the overloaded method Load) or to XML data (LoadXML method) 

XPathDocument class (found in the System.Xml.XPath namespace):

This class does not extend the XMLNode class (as XMLDocument) but provides a read-only representation of a DOM structure and it is highly optimized for XSLT processing and the XPath data model using the XPath optimization functions on the XPathNavigator

So, I used the following scenario to test if the XPathDocument is the fastest way to input an XML document to the XSL transformation.

I applied the XSL transformation to the each class loaded with the same XML file and outputted the result to the web in an .aspx page.

oTrs.Load(Server.MapPath("portfolio3.xsl"))
oTrs.Transform(oDoc, Nothing, sw)
TextBox1.Text = sw.ToString()
 

Each .aspx page was stressed with against Application Center Test in three different cases (1, 3 and 10 concurrent browser connections). The stress test was performed on 2 different machines and the test duration was 5 minutes.

// XMLDocument Test
Test.SendRequest(http://XMLDocument.aspx)
// XMLDataDocument Test
Test.SendRequest(http://XMLDataDocument.aspx)
// XPathDocument Test
Test.SendRequest(http://XPathDocument.aspx)


The results (request vs. time) were identical in all cases.

XslTPe1.jpg

Where:

(1)   XPathDocument
(2)   XMLDataDocument
(3)   XMLDocument 

Conclusion:

XPathDocument provides the fastest option for transforming XML via XSLT because is optimized for XPath queries due to the internal storage.

Login to add your contents and source code to this article
share this article :
post comment
 
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor