Re: [xsl] Slow XSLT

Subject: Re: [xsl] Slow XSLT
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 13 Mar 2008 00:51:58 GMT
your sample input wasn't well formed but judging by the required result
I think you intended the file below, the xsl produces the requested
result without any use of variables or position().


<Report xmlns="">
  <Measures>
    <Measure idx="1" heading="Total Pages" />
    <Measure idx="2" heading="Cost" />
  </Measures>
  <Rows>
   <RowGrp>
    <Row heading="Name 1">
      <Cell>
        <Msr idx="1" val="10" />
        <Msr idx="2" val="15" />
      </Cell>
      <Cell/>
    </Row>
    <Row heading="Name 2">
      <Cell />
      <Cell>
        <Msr idx="1" val="45" />
        <Msr idx="2" val="34" />
	</Cell>
      <Cell>
        <Msr idx="1" val="123" />
        <Msr idx="2" val="19" />
	</Cell>
    </Row>
   </RowGrp>
  </Rows>
</Report>



<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  
<xsl:strip-space elements="*"/>

<xsl:template match="Report">
  <html>
    <head><title>report</title></head>
    <body>
      <table>
	<xsl:apply-templates/>
      </table>
    </body>
  </html>
</xsl:template>

<xsl:template match="Measures">
  <tr>
    <xsl:apply-templates/>
    <xsl:apply-templates/>
  </tr>
</xsl:template>

<xsl:template match="Row">
  <tr>
    <xsl:apply-templates/>
  </tr>
</xsl:template>

<xsl:template match="Measure">
  <th><xsl:value-of select="@heading"/></th>
</xsl:template>

<xsl:template match="Msr">
  <td><xsl:value-of select="@val"/></td>
</xsl:template>
<xsl:template match="Cell[not(*)]">
  <td>&#160;</td>
  <td>&#160;</td>
</xsl:template>




</xsl:stylesheet>



$ saxon rept.xml rept.xsl
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   
      <title>report</title>
   </head>
   <body>
      <table>
         <tr>
            <th>Total Pages</th>
            <th>Cost</th>
            <th>Total Pages</th>
            <th>Cost</th>
         </tr>
         <tr>
            <td>10</td>
            <td>15</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
         </tr>
         <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>45</td>
            <td>34</td>
            <td>123</td>
            <td>19</td>
         </tr>
      </table>
   </body>
</html>

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread