Altova Mailing List Archives

Re: [xsl] Optimizing XSLT iteration

From: Abel Braaksma <>
Date: 10/7/2007 11:13:00 PM
Hi Sujata,

See my comments below,

Sujata Gohad wrote:
In order to convert it to SVG format:

<?xml version=' 1.0' encoding='UTF-8'?>

<?xml-stylesheet href="hvm_to_svg.css" type="text/css"? >


Does this actually work? Are you calling an XSLT stylesheet as being 
type "text/css" and you call it ***.css? Your processor (which one are 
you using?) seems quite forgiving (or maybe I am missing something ;)

            <xsl:for-each select="component">
                <xsl:for-each select="trace">
                    <path >
                        <xsl:attribute name="class"> trace</xsl:attribute >
                        <xsl:attribute name="d">
                            <xsl:for-each select="locus[position()=1]">

This nested for-each is probably easier written and easier maintainable 
when you write it as apply-template/template matching pairs. This way 
you make use of the features of XSLT and let it choose the best 
execution path, instead of telling the processor what you think is best.

XSLT profiler shows that 80% of the time is spent in enumerating the
"locus" elements?

Is there a way to faster iteration of the "locus" elements?

That sounds about right. In the source snippet you showed, just about 
95% of all your lines are about "locus" elements, no? So, to be fair, 
the processing of those elements should take about 95%, if the ratio 
would apply. Perhaps your code is even quicker than the apply-template 
approach? But I wouldn't bet on it. But even if the code runs quicker, 
it would still be 80% or something that is spend on the locus elements.

-- Abel Braaksma


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 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.