XML/XSLT Transformations

C

Christopher

I am currently in the process of evaluating the performance hits of moving
to the .NET platform for our application. I created a sample project that
loads the transforms the same XML and XSLT in COM, COM using interop and in
C# and then transforms it to HTML. I also tried concatenating the XML and
XSL as a string and then loading it to the DOM once as opposed to loading
the DOM with the appendChild() method. I see that the C# version is
magnitudes slower in both cases and this scares me. We are headed to .NET so
I have to find out if anyone has figured out how to speed up the
transformation or the DOM load using C#. ANY help would be greatly
appreciated.



Thanks in advance,

Chris
 
G

Guest

Hi Christopher,

Thank you for posting in the community!

Based on my understanding, your team will head to use .Net, so you want to
do some performance comparison between the MSXML and .Net XML class library.

=================================================
Actually, your test is the performance comparison between MSXML and .Net
XML, not the performance of C# code. In your test, the C# is just a test
language for .Net XML class library, it does not affect the performance.

For the comparison, there are some good articles talks about it, please
refer to the 2 articles below for useful information:
"XSLT Performance in .NET"
http://www.ondotnet.com/pub/a/dotnet/2003/07/14/xsltperf.html

"A Practical Comparison of XSLT and ASP.NET"
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnexxml/htm
l/xml02192001.asp

=================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice weekend!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
C

Chris

Hey Jeff,

Thanks for the response. I wanted to be clear that I was using the
..NET XML with C#, sorry for the confusion. Is there any large known
bottlenecks with using the .NET XML? Things to stay away from? In my
tests, I have a fairly large XML document with extremely simple XSL
and it doesn't even begin to compare to the performance of the VB or
Interop. I figured there might be some people that would know how to
speed it up. I found that loading the XmlDocument is not the problem,
the .Transform is. Any experience in speeding this up? I would gladly
post code samples if you need them. Thanks again.

Chris
 
G

Guest

Hi Chris,

Thanks for your feedback.

I will spend some time on this issue, I will reply to you ASAP.

Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Hi Chris,

Sorry for letting you wait for so long time.

After consulting and researching, I will provide some information for you:

For some known issue about XSL Transformation, please refer to:
"PRB: XSL Transformations May Perform Slower with System.Xml Than MSXML"

SYMPTOMS
========
XSL Transformations (XSLT) may perform slower with System.Xml classes in
comparison with transformations that are performed with Microsoft XML
(MSXML) 4.0.

CAUSE
=====
The System.Xml.Xslt namespace in the Microsoft .NET Framework Class
Libraries provides a set of classes for XSL Transformations for XML data in
..NET-based applications, whereas MSXML is a COM-based technology that
provides full XML services to COM-based applications.

The latest release of MSXML (Microsoft XML Core Services 4.0) compiles and
executes XSLT faster and provides one of the fastest XSLT engines that is
currently available.

RESOLUTION
==========
If XSLT is only a small part of your application, performance loss (when
you compare it to MSXML 4.0) may be negligible. Applications that you
develop solely with System.Xml have numerous benefits that System.Xml and
the .NET Framework provide, such as interoperability with Microsoft ADO.NET
components, scalability, and other enhancements.

If you develop the application solely for XSLT, and if performance is a
concern, you can use an MSXML 4.0 parser for XSLT operations with your
..NET-based application by using the COM Interop technology. For more
information about how to use MSXML 4.0 with the Interop technology, see the
"References" section of this article.

STATUS
======
This behavior is by design. Microsoft is currently developing the next
major version release of Microsoft Visual Studio .NET with an improved and
faster XSLT parser and engine.

Also, I want to inform you that: Use of MSXML is Not Supported in .NET
Applications, so you are not recommanded to interop with MSXML in .Net, for
more information, please refer to:
http://support.microsoft.com/default.aspx?scid=kb;en-us;815112

For suggestion about how to improve performance of XSLT Transformations in
the .NET Framework, please refer to:
http://support.microsoft.com/default.aspx?scid=kb;en-us;325689

Hope all these information can help you!

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
C

Chris

Jeff,

Thanks so much. I extremely appreciate your time and efforts. This was
a great answer. One last question: When is MS planning on addressing
some of these performance issues? I assume that a lot of people
porting to .NET and using the XML libraries are also affected by the
poor transformation speeds. Any help would be appreciated.

Chris
 
G

Guest

Hi Chris,

Thanks very much for your feedback.

I am very glad my reply makes sense to you.

For your furture xml performance planning, I can not give you a determine
answer. I think you may regard the msdn.microsoft.com for the more recently
planning and changes for .Net.

Also, I think you may provide your suggestion to
http://register.microsoft.com/mswish/suggestion.asp
or email to: (e-mail address removed)

Hope this help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
C

Chris

Thanks so much Jeff,

On a side note, do you have any information about C# developers using
different engines (ultimately Xalan) for transformations? I have been
searching around but can't find much. I would like to avoid using the
Interop with MSXML because it's not technically supported. Any ideas?

Thanks,
Chris
 
G

Guest

Hi Chris,

I do not know much of Xalan engine. After some search, I found it is a xml
transformation engine for C#.
And I did not find the tool or articles to use it in .Net. :-(

Why do not you use .Net System.Xml with XSLT to do transformation? I think
you concern may be the performance.
Actually, in original post, I have introduced you an article which shows
you the general performance bottleneck in .Net XSLT Transformations
http://support.microsoft.com/default.aspx?scid=kb;en-us;325689

You may use .Net XSLT Transformations, then avoid the usage of these
already known issue to get a better performance.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
C

Chris

Hey,

Yes, you are correct Jeff. The issue here is NOT the .NET XML
libraries (which are pretty efficient and easy to use) rather the XSLT
libraries, namely the transformation that is the problem. Given the
article you posted, even making those small changes in our style
sheets would not save much time. The code just does not perform well,
plain and simple. I created a simple XML document with 5,000 lines and
a very simple XSLT document to transform it into HTML. Here is an
example output of my tests:

Total time: 1162.53183016277 ms.
XML Load: 57.7347120932968 ms.
XSL Load: 2.21145424907356 ms.
Transform: 1010.64017912891 ms.

As you can see the transform is ridiculously slow. Therefore I am
looking for other ways of accomplishing this task. Using the Xalan
XSLT engine within C# might be one of the ways. I'm looking for any
information on how to implement that or something to that effect in my
project.

Thanks for all your time,
Chris
 
G

Guest

Hi Chris,

Thanks for your feedback.

Ok, I see your concern is the performance of Xml transformation.

To use other xml engine in .Net, the common way is through COM interop.

Also, I have done some research on System.Xml transformation performance. I
found one articles said that:
"I attended one of the System.Xml talks given by Fadi Fakhouri (WebData XML
Team Project Manager at Microsoft) at this year's TechEd conference. He
made a note of the fact that System.Xml is currently slower than MSXML4
(for XSL transformations only) because they didn't have time to do the
optimizations prior to the .NET ship. If performance is an issue, you will
need to use XPathDocument or MSXML4"

So I think you may use XPathDocument to see if it improves your
performance.

This article below do the performance Comparison of XslTransform. Its
conclusion also suggest you use XPathDocument. Because, "XPathDocument
provides the fastest option for transforming XML via XSLT because is
optimized for XPath queries due to the internal storage."
http://www.vbdotnetheaven.com/Code/Jun2003/2047.asp

Also, the article below may gives you a good view of performance in
..Net(Including transformation):
http://blogs.msdn.com/mfussell/archive/2004/02/23/78929.aspx

At last, these 2 KB below may give more tips on how to improve the XSL
Transformation performance:
"INFO: Techniques to Improve Performance of XSL Transformations"
http://support.microsoft.com/default.aspx?scid=kb;en-us;815124

"Show Me How: Performance Tune an Xslt Style Sheet in Visual Studio .NET
Using System.Xml"
http://support.microsoft.com/default.aspx?scid=kb;en-us;331026

Hope all these help you.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
G

Guest

Hi Chris,

Does my reply make sense to you? Does it help you?

If you still have any concern, please feel free to feedback, I will
continue to help you. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top