xsl-list
[Top] [All Lists]

Re: [xsl] Slow XSLT

2008-03-02 14:46:13
Hi Manfred,

Thank you for your help. I trully appreciate it.

I am trying to code the xslt stylesheet using  your
suggestion (using templates to take care of the
hierarchy) but I have to confess that I am a bit lost.


I was wondering if you could have a look at the
stylesheet below and make the necessary changes.

Also, I have not tried your simpler approach yet
because I am trying to understand this one first.

As for the Javascript, I will create a test harness to
test all the stylesheets and let you know the one with
the best performance.

Cheers


<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
xmlns:fo="http://www.w3.org/1999/XSL/Format";>
        <xsl:param name="axisHeads" select="'false'" />
        <xsl:output indent="yes"/>

        <xsl:variable name="msrs">
                <xsl:choose>
                         <xsl:when test="/Reports/Report/Measures/Measure">
                                   <xsl:value-of
select="count(/Reports/Report/Measures/Measure)"/>
                         </xsl:when>
                         <xsl:otherwise>
                                   <xsl:value-of select="1"/>
                         </xsl:otherwise>
           </xsl:choose>
 </xsl:variable>

 <xsl:template match="Reports">
         <html>
                 <body>
                         <xsl:apply-templates/>
                 </body>
         </html>
 </xsl:template>

 <xsl:template match="Report" >
     <!-- Top -->
     <div id="g1" style="position: absolute; top: 0px;
left: 0px; width: 400px; height: 12px">
       <table class="grdTop" border="0"
cellspacing="1"  cellpadding="0">
         <tbody>
           <xsl:apply-templates select="Columns" />
         </tbody>
       </table>
     </div>
  </xsl:template>
  
  <xsl:template match="Columns">
        <xsl:apply-templates mode="ColGrp"/>
 </xsl:template>

<!--processing for the innermost ColGrp here-->
<xsl:template match="ColGrp[Col]" mode="ColGrp">
        
 </xsl:template>

<xsl:template match="ColGrp" mode="ColGrp">
        <!--processing here (you can always test the
depth with count(ancestor::ColGrp))-->
        
 </xsl:template>

<!--plus one for Col:-->
<xsl:template match="Col" mode="ColGrp">

 </xsl:template>
 
 <xsl:template match="Measures">
   <xsl:param name="pos" />
   <xsl:for-each select="Measure">
     <xsl:variable name="mPos">
       <xsl:value-of select="position()" />
     </xsl:variable>
     <td align="center">
       <nobr>
         <div class="action" style="width:90px;
overflow:none" onclick="sortFullGrid({$mPos}, {$pos},
'{(_at_)class}')">
           <xsl:value-of select="@heading"/>
         </div>
       </nobr>
     </td>
   </xsl:for-each>
 </xsl:template>
 

</xsl:stylesheet>


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

--- Manfred Staudinger <manfred(_dot_)staudinger(_at_)gmail(_dot_)com>
wrote:

On 02/03/2008, Manfred Staudinger
<manfred(_dot_)staudinger(_at_)gmail(_dot_)com> wrote:
I would propose a slightly different approach:

<xsl:for-each
select="/Reports/Report/Columns/ColGrp">
   <xsl:apply templates mode="ColGrp"/>
should read
   <xsl:apply-templates mode="ColGrp"/>
 </xsl:for-each>
 passing the parameters needed for your processing
and using only two
 templates for ColGrp: one for the innermost
ColGrp, and one for the
 others
 <xsl:templates match="ColGrp[Col]" mode="ColGrp">
 processing for the innermost ColGrp here
add the apply-templates here:
   <xsl:apply-templates mode="ColGrp"/>
 </xsl:for-each>

Manfred


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





      ___________________________________________________________ 
Rise to the challenge for Sport Relief with Yahoo! For Good  

http://uk.promotions.yahoo.com/forgood/

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

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