473,795 Members | 3,215 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Performance of Xsl Transformations

Folks, I'm running into some performance issues with my Xsl transformations .
I've done a ton of debugging and digging around, and have come to the
conclusion that the performance issues are NOT caused by slow stored
procedures, or bad XSL/Ts.

I came to this conclusion by doing a test transformation in client-side code
instead of server side aspx, as shown at the bottom of this post. The
transformations were super-fast. However, the client-side javascript isn't a
viable solution for my application.

I'm sure that different versions of the XMLDOM are being used when the code
is client-side as opposed to using System.Xml.Xsl.

Here's my C# code. What I'm trying to do is write out an HTML file of my
transformation.

// Create a FileStream to write with
System.IO.FileS tream fs = new System.IO.FileS tream(exportPat h,
System.IO.FileM ode.Create);
// Create an XmlTextWriter for the FileStream
System.Xml.XmlT extWriter oXmlTextWriter = new
System.Xml.XmlT extWriter(fs, System.Text.Enc oding.Unicode);

try
{
// Set up the XmlResolver
XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver( );
oXmlUrlResolver .Credentials = CredentialCache .DefaultCredent ials;

// Set up the XslTransform
System.Xml.Xsl. XslTransform oXslTransform = new
System.Xml.Xsl. XslTransform();
oXslTransform.L oad(MyXslPath, oXmlUrlResolver );

// Perform Transformation
XmlDataDocument oXmlDataDocumen t = new XmlDataDocument (MyDataSet);
oXslTransform.T ransform(oXmlDa taDocument, null, oXmlTextWriter,
oXmlUrlResolver );

// Clean up
oXmlTextWriter. Close();

return exportPath; // defined elsewhere
}
catch (Exception ex)
{
oXmlTextWriter. Close();
System.IO.File. Delete(exportPa th);
ExceptionManage r.Publish(ex);
throw(ex);
}
The code works, but it's slow. It was suggested that I use an XPathDocument
instead of an XmlDataDocument . How would I do that?
Any suggestions? Thank You

Client-Side Transformation
<%
var sXml = "MyXml.Xml"
var sXsl = "MyXsl.xsl"

var oXmlDoc = Server.CreateOb ject("MICROSOFT .XMLDOM");
var oXslDoc = Server.CreateOb ject("MICROSOFT .XMLDOM");
oXmlDoc.async = false;
oXslDoc.async = false;
oXmlDoc.load(Se rver.MapPath(sX ml));
oXslDoc.load(Se rver.MapPath(sX sl));
Response.Write( oXmlDoc.transfo rmNode(oXslDoc) );
%>
Nov 18 '05 #1
1 1930
Ok, I figured this out ... I would like to do some research to figure out
why this is faster (MUCH faster).

The slow way:

DataSet oDataSet = populate dataset with some report data
System.IO.FileS tream oFileStream = new System.IO.FileS tream(exportPat h,
System.IO.FileM ode.Create);
System.Xml.XmlT extWriter oXmlTextWriter = new
System.Xml.XmlT extWriter(oFile Stream, System.Text.Enc oding.Unicode);
try
{
XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver( );
oXmlUrlResolver .Credentials = CredentialCache .DefaultCredent ials;
System.Xml.Xsl. XslTransform oXslTransform = new
System.Xml.Xsl. XslTransform();
oXslTransform.L oad(_XslPath, oXmlUrlResolver );
XmlDataDocument oXmlDataDocumen t = new XmlDataDocument (oDataSet);
oXslTransform.T ransform(oXmlDa taDocument, null, oXmlTextWriter,
oXmlUrlResolver );
oXmlTextWriter. Close();

return exportPath; // path of exported file
}
catch (Exception ex)
{
oXmlTextWriter. Close();
System.IO.File. Delete(exportPa th);
throw(ex);
}

The fast way:

DataSet oDataSet = populate dataset with some report data
XmlTextReader oXmlTextReader = new XmlTextReader(o DataSet.GetXml( ),
XmlNodeType.Doc ument, null);
System.IO.FileS tream oFileStream = new System.IO.FileS tream(exportPat h,
System.IO.FileM ode.Create);
System.Xml.XmlT extWriter oXmlTextWriter = new
System.Xml.XmlT extWriter(oFile Stream, System.Text.Enc oding.Unicode);
try
{
XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver( );
oXmlUrlResolver .Credentials = CredentialCache .DefaultCredent ials;
System.Xml.Xsl. XslTransform oXslTransform = new
System.Xml.Xsl. XslTransform();
oXslTransform.L oad(_XslPath, oXmlUrlResolver );
XPathDocument oXPathDocument = new XPathDocument(o XmlReader);
oXslTransform.T ransform(oXPath Document, null, oXmlTextWriter,
oXmlUrlResolver );
oXmlTextWriter. Close();

return exportPath; // path of exported file
}
catch (Exception ex)
{
oXmlTextWriter. Close();
System.IO.File. Delete(exportPa th);
throw(ex);
}
"George Durzi" <gd****@hotmail .com> wrote in message
news:#e******** ******@TK2MSFTN GP12.phx.gbl...
Folks, I'm running into some performance issues with my Xsl transformations . I've done a ton of debugging and digging around, and have come to the
conclusion that the performance issues are NOT caused by slow stored
procedures, or bad XSL/Ts.

I came to this conclusion by doing a test transformation in client-side code instead of server side aspx, as shown at the bottom of this post. The
transformations were super-fast. However, the client-side javascript isn't a viable solution for my application.

I'm sure that different versions of the XMLDOM are being used when the code is client-side as opposed to using System.Xml.Xsl.

Here's my C# code. What I'm trying to do is write out an HTML file of my
transformation.

// Create a FileStream to write with
System.IO.FileS tream fs = new System.IO.FileS tream(exportPat h,
System.IO.FileM ode.Create);
// Create an XmlTextWriter for the FileStream
System.Xml.XmlT extWriter oXmlTextWriter = new
System.Xml.XmlT extWriter(fs, System.Text.Enc oding.Unicode);

try
{
// Set up the XmlResolver
XmlUrlResolver oXmlUrlResolver = new XmlUrlResolver( );
oXmlUrlResolver .Credentials = CredentialCache .DefaultCredent ials;

// Set up the XslTransform
System.Xml.Xsl. XslTransform oXslTransform = new
System.Xml.Xsl. XslTransform();
oXslTransform.L oad(MyXslPath, oXmlUrlResolver );

// Perform Transformation
XmlDataDocument oXmlDataDocumen t = new XmlDataDocument (MyDataSet);
oXslTransform.T ransform(oXmlDa taDocument, null, oXmlTextWriter,
oXmlUrlResolver );

// Clean up
oXmlTextWriter. Close();

return exportPath; // defined elsewhere
}
catch (Exception ex)
{
oXmlTextWriter. Close();
System.IO.File. Delete(exportPa th);
ExceptionManage r.Publish(ex);
throw(ex);
}
The code works, but it's slow. It was suggested that I use an XPathDocument instead of an XmlDataDocument . How would I do that?
Any suggestions? Thank You

Client-Side Transformation
<%
var sXml = "MyXml.Xml"
var sXsl = "MyXsl.xsl"

var oXmlDoc = Server.CreateOb ject("MICROSOFT .XMLDOM");
var oXslDoc = Server.CreateOb ject("MICROSOFT .XMLDOM");
oXmlDoc.async = false;
oXslDoc.async = false;
oXmlDoc.load(Se rver.MapPath(sX ml));
oXslDoc.load(Se rver.MapPath(sX sl));
Response.Write( oXmlDoc.transfo rmNode(oXslDoc) );
%>

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
3425
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical application in Python without using prebuilt numerical libraries and data objects such as dictionaries and lists. I have been experimenting with numerical algorithms in Python with a heavy use of the Numeric module. My experience is that Python...
0
1528
by: Mike | last post by:
I am trying to code vb.net to perform XML transformations by applying a style sheet to a XML doc. All of my XML and XSLT documents will be in either XML DOM Objects or string variables. I am not reading anything from Disk. Prior to .NET, I would this with the following code: ------ ******************* -------- 'Load Source cXML into DOM object Set objSource = server.CreateObject("microsoft.xmldom") objSource.loadXML(SourceXML)
6
2312
by: Duane Morin | last post by:
I've inherited an XSL transform that I need to squeeze every last millisecond out of (since it's running several hundred thousand times). I've noticed that there are 26 match clauses in the file. They are 13 pairs that each check the same condition, like this: <xsl:template match="A/foo"> .... <xsl:template match="B/foo"> .... <xsl:template match="A/bar">
3
1591
by: Daedelus | last post by:
hi, What is the performance hit of c# over visual c++. Would it be possible to write photoshop in c# for example with no noticable speed loss? thanks.
1
5333
by: James dean | last post by:
Could someone explain how this works. I think the graphics card is used to do blitting and drawing shapes like rectangles. How does it draw using the Graphics card on the PC and why is this feature left out of GDI+?. *** Sent via Developersdex http://www.developersdex.com ***
3
1665
by: Glenn | last post by:
I have a performance issue that needs resolving, and am not sure which options we have come up with are the best. Let me explain. Our site has a report designer that allows users to create dynamic report content. The output for these reports is HTML, but they can be exported to a number of formats for download (ie Excel). The contents of the exported report must be identical to the original report, thus cannot read from the DB as...
19
3155
by: Tom Jastrzebski | last post by:
Hello, I was just testing VB.Net on Framework.Net 2.0 performance when I run into the this problem. This trivial code attached below executed hundreds, if not thousand times faster in VB 6.0 than in .Net environment, under VS 2005 Beta 2. Does anyone have any idea whether this will be addressed in the final release? Thanks, Tomasz
36
2505
by: mrby | last post by:
Hi, Does anyone know of any link which describes the (relative) performance of all kinds of C operations? e.g: how fast is "add" comparing with "multiplication" on a typical machine. Thanks! -- B. Y.
0
1900
by: jimmy Zhang | last post by:
Hi, We are developers of VTD-XML (http//vtd-xml.sf.net) and we are interested in your opportunities...are you still having those positions open? Jimmy Zhang <gaetan@hains.orgwrote in message news:1193332732.035899.297980@d55g2000hsg.googlegroups.com... Doctoral project and scholarship at the University of Paris-12 ALGORITHMS FOR XML: LARGE DATA SETS, EXTERNAL MEMORY AND SCALABLE PERFORMANCE
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10439
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10165
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7541
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6783
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3727
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.