Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Optimization help

Status
Not open for further replies.

NBartomeli

Programmer
Jul 1, 2003
111
US
I have a XSLT stylesheet which was pretty fast untill I added more too it.

This is the code that slows down the stylesheet:
Code:
<!-- if there are totals for the level -->
<xsl:if test="/Report/Totals/@Level='ColumnLevel2'">
  <tr>
    <td class="xl26" align="left" width="200">Totals:</td>
    <!-- output each total -->
    <xsl:for-each select="/Report/Totals[@Level='ColumnLevel2']">
      <td class="xl25" align="right">
	<xsl:value-of select="format-number(@Value,&quot;#,###.00 ;-#,###.00&quot;)"/>
      </td>
    </xsl:for-each>
  </tr>
</xsl:if>

Here is a sample of the XML that code is for:
Code:
  <Totals Level="ColumnLevel2" ParentIndex="0" Value="1769901" />
  <Totals Level="ColumnLevel2" ParentIndex="0" Value="1398506" />
  <Totals Level="ColumnLevel2" ParentIndex="1" Value="1903972" />
  <Totals Level="ColumnLevel2" ParentIndex="1" Value="1753015" />
  <Totals Level="ColumnLevel2" ParentIndex="2" Value="1810228" />
  <Totals Level="ColumnLevel2" ParentIndex="2" Value="1583444" />
  <Totals Level="ColumnLevel2" ParentIndex="3" Value="2213212" />
  <Totals Level="ColumnLevel2" ParentIndex="3" Value="2653893" />
  <Totals Level="ColumnLevel2" ParentIndex="4" Value="2487725" />
  <Totals Level="ColumnLevel2" ParentIndex="4" Value="4901120" />
  <Totals Level="ColumnLevel2" ParentIndex="5" Value="2064621" />
  <Totals Level="ColumnLevel2" ParentIndex="5" Value="2266857" />
  <Totals Level="ColumnLevel2" ParentIndex="6" Value="2141267" />
  <Totals Level="ColumnLevel2" ParentIndex="6" Value="906375" />
  <Totals Level="ColumnLevel2" ParentIndex="7" Value="2078815" />
  <Totals Level="ColumnLevel2" ParentIndex="7" Value="761975" />
  <Totals Level="ColumnLevel2" ParentIndex="8" Value="2433448" />
  <Totals Level="ColumnLevel2" ParentIndex="8" Value="861284" />
  <Totals Level="ColumnLevel2" ParentIndex="9" Value="2115456" />
  <Totals Level="ColumnLevel2" ParentIndex="9" Value="693253" />
  <Totals Level="ColumnLevel2" ParentIndex="10" Value="1872822" />
  <Totals Level="ColumnLevel2" ParentIndex="10" Value="684939" />
  <Totals Level="ColumnLevel2" ParentIndex="11" Value="1810208" />
  <Totals Level="ColumnLevel2" ParentIndex="11" Value="620165" />
  <Totals Level="ColumnLevel2" ParentIndex="12" Value="1923188" />
  <Totals Level="ColumnLevel2" ParentIndex="12" Value="659823" />
  <Totals Level="ColumnLevel2" ParentIndex="13" Value="1980999" />
  <Totals Level="ColumnLevel2" ParentIndex="13" Value="737280" />
  <Totals Level="ColumnLevel2" ParentIndex="14" Value="2274542" />
  <Totals Level="ColumnLevel2" ParentIndex="14" Value="695680" />
  <Totals Level="ColumnLevel2" ParentIndex="15" Value="1755166" />
  <Totals Level="ColumnLevel2" ParentIndex="15" Value="680718" />
  <Totals Level="ColumnLevel2" ParentIndex="16" Value="1879054" />
  <Totals Level="ColumnLevel2" ParentIndex="16" Value="667651" />
  <Totals Level="ColumnLevel2" ParentIndex="17" Value="1998871" />
  <Totals Level="ColumnLevel2" ParentIndex="17" Value="601793" />
  <Totals Level="ColumnLevel2" ParentIndex="18" Value="1828341" />
  <Totals Level="ColumnLevel2" ParentIndex="18" Value="576840" />
  <Totals Level="ColumnLevel2" ParentIndex="19" Value="1838044" />

Any advice on how to speed things up would be great. I have 4 of these IF/Loop blocks in the stylesheet, so getting any speed increase would improve performance alot

I am relatively new to this whole thing, so bear with me

Thanks in advance

 
I suppose I should have posted the more complex example.

I have 2 IF/Loop blocks like above, and 2 which add another parameter, like this:

Code:
<xsl:variable name="index" select="@Index"/>
<xsl:if test="/Report/Totals/@Level='RowLevel2'">
  <td width="25"/>
  <xsl:for-each select="/Report/Totals[@Level='RowLevel2' and @ParentIndex=$index]">
    <td class="xl25" align="right">
      <xsl:value-of select='format-number(@Value,"#,###.00 ;-#,###.00")'/>
    </td>
  </xsl:for-each>
</xsl:if>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top