xsl-list
[Top] [All Lists]

RE: Which is more efficient?

2003-03-11 04:08:25
Which of these is the most efficient way of rendering html?  

Answers to such questions are always dependent on the XSLT processor you
are using, and the simple answer is to measure it: in this case I
suspect that you will find that the difference in execution time is
insignificant, though the shorter stylesheet will probably be faster to
compile.

To look at it another way: do you have a performance problem? If you do,
this change isn't going to solve it. If you don't, why are you worrying
about it?

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com 




It's obvious which one is easier to code, but which one would 
actually parse more quickly?  In the abbreviated examples 
below, the difference, of course would be negligible...but 
consider a page of a few thousand lines of rendered HTML.

SCENARIO #1:
----------------------
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = 
"http://www.w3.org/1999/XSL/Transform";>
<xmlRoot>
<table 
border="1" cellspacing="1">
<tr>
<td>abc</td>
</tr>
</table>
</xmlRoot>
</xsl:stylesheet>


SCENARIO #2:
----------------------
<?xml version = "1.0" encoding = "UTF-8"?>
<xsl:stylesheet version = "1.0" xmlns:xsl = 
"http://www.w3.org/1999/XSL/Transform";>
<xmlRoot>

<xsl:element name="table">
<xsl:attribute name="border">
<xsl:text>1</xsl:text>
</xsl:attribute>
<xsl:attribute name="cellspacing">
<xsl:text>1</xsl:text>
</xsl:attribute>
<xsl:element name="tr">
<xsl:element name="td">
<xsl:text>abc</xsl:text>
</xsl:element>
</xsl:element>
</xsl:element>
</xmlRoot>
</xsl:stylesheet>

--------------------------------------------------------------
----------------
This e-mail transmission may contain information that is 
proprietary, privileged and/or confidential and is intended 
exclusively for the person(s) to whom it is addressed. Any 
use, copying, retention or disclosure by any person other 
than the intended recipient or the intended recipient's 
designees is strictly prohibited. If you are not the intended 
recipient or their designee, please notify the sender 
immediately by return e-mail and delete all copies. 


==============================================================
================


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>