Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xml-dev] XSLT Element Performence

From: "Thomas B. Passin" <tpassin@-------.--->
To: xml-dev@-----.---.---
Date: 7/7/2004 2:14:00 AM
Robert Hansson wrote:

> I have been taking over a project with thousands of lines of XSLT code that
> I need to change because of performance and readability problems. About the
> performance issues I 
> 
> need someone to tell me which of the following two examples is the best one
> for performance, what's the differences and what to think about.

> Example 1:
> 
> <xsl:element name="div"><xsl:attribute name="id"><xsl:value-of
> select="@id"/></xsl:attribute></xsl:element>
> 
> Example 2:

> <div id="{@id}"></div>

The only reason to use xsl:element and xsl:attribute is if you need to 
create element and attribute names dynamically.  Otherwise, literal 
result syntax is much more readable, and hence maintainable.  For its 
performance, you always have to test with your sources and processors, 
but in this case there would probably be no noticable difference.

Typical performance problems come from multiple evaluations of the same 
quantity (often inadvertant), poorly designed recursive templates, not 
using keys, using "//", evaluating a whole branch when you need only 
evaluate one node, selecting nodes in the predicate of a template match 
attribute rather than in an apply-templates select attribute, and so on.

For maintenance, use lots of variables for clarity.

Xslt questions are best asked on the Mulberry xslt list.

Cheers,

Tom P

-- 
Thomas B. Passin
Explorer's Guide to the Semantic Web (Manning Books)
http://www.manning.com/catalog/view.php?book=passin


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent