[xsl] Performance

Subject: [xsl] Performance
From: Richard Mitchell <Richard.Mitchell@xxxxxxxxxxxxx>
Date: Thu, 13 Sep 2001 10:40:59 +0100
OK it seems that performance is now becoming an important
issue for people. I myself would like to improve the
performance of our stylesheets for our sites as even with
only the first viewer generating the page it can still take
6 seconds to generate a page.

What is the best way to improve performance?

We are using inheriting style sheets so there are a lot
of calls to names templates that are overridden in sub stylesheets
that xsl:import the parent sheet.

Here are a few code snippets that might or might not be bad
programming style but they're here for examples to open
a discussion on tricks and performance...

Making an indent or just creating an empty table element:
<xsl:param name="mainindenthtml">
  <img src="/wdp/images/spc.gif" height="1">
    <xsl:attribute name="width"><xsl:value-of

        <xsl:when test="number($bfora:mainindent)">
          <TD width="{$bfora:mainindent}"><xsl:copy-of
          <TD />

Calling sub templates to do things:
<xsl:param name="tdgap"><td width="5"><img src="/wdp/images/spc.gif"
	<xsl:if test="number($itemshowkey1) or
			<xsl:attribute name="NOWRAP">1</xsl:attribute>
			<xsl:if test="number($itemshownetworkicon1)">
				<xsl:call-template name="shownetworkicon"/>
			<xsl:if test="number($itemshowkey1)">
				<xsl:call-template name="showkey"/>
		<xsl:copy-of select="$tdgap"/>

Trying hard to keep my tables matching:
	<TD width="100%"
ber($itemshowdate1) or
number($itemshownetworkicon1))*2+not(number($itemshownetworkicon3) or
number($itemshowweblink) or number($itemshowkey3))*2}">
		<xsl:if test="number($itemshowtitle)">
				<xsl:call-template name="showtitle"/>

Loading up the keys:

      <xsl:call-template name="bfora:subtext"/>
      <xsl:variable name="keys" select="document($keyfile)"/>
      <xsl:variable name="current" select="."/>
          select="keyitem[word=$current/publickeyword or
                          word=$current/adminkeyword or
                          word=$current/group or
      <xsl:call-template name="bfora:subtext-end"/>

My text templates:
  <xsl:template name="bfora:subtext">
     <xsl:text disable-output-escaping="yes">
      &lt;font face="verdana, arial" size="1" color="#000000"&gt;

  <xsl:template name="bfora:subtext-end">
    <xsl:text disable-output-escaping="yes">
Richard Mitchell
Software Developer

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

Current Thread