Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Slow XSLT

From: Cleyton Jordan <cleytonjordan@----------->
To:
Date: 3/3/2008 6:49:00 PM
Hi Manfread,

I truly appreciate your help. You are real star :)

I have just seen your post and before I try your
changes I would like to ask you what this line does
i.e. which template does it call?

<xsl:apply-templates select="$set"/>

Where is this template being called from?

<xsl:template match="Col">
  <td colspan="{$msrs}">
   <div><xsl:value-of select="@heading"/></div>
  </td>
</xsl:template>

Cheers

C


--- Manfred Staudinger <manfred.staudinger@xxxxxxxxx>
wrote:

> Hi,
> 
> No wonder you felt confused, I was wrong. Only after
> sitting down with
> the problem I realized that this needs a recursive
> call for a named
> template: it is used to produce one row  with
> apply-templates and then
> go down one level. If we are at the bottom, process
> the Measures and
> quit.
> You will have no difficulty to add the attributes I
> left out for
> readability. If you want to use $axisHeads = false()
> then the most
> natural way would be to begin processing one level
> below by setting
> 	<xsl:variable name="set"
> select="Reports/Report/Columns/ColGrp/*"/>
> Hope this helps,
> 
> Manfred
> 
> XSLT:
> <?xml version="1.0" encoding="UTF-8" ?>
> <xsl:stylesheet version="2.0"
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> <xsl:output indent="yes"/>
> <xsl:variable name="msrs"
> select="count(/Reports/Report/Measures/Measure)"/>
> 
> <xsl:template match="/">
> 	<html>
> 	<body>
> 		<table>
> 		<tbody>
> 			<xsl:variable name="set"
> select="Reports/Report/Columns/ColGrp"/>
> 			<xsl:call-template name="apply-set">
> 				<xsl:with-param name="set" select="$set"/>
> 			</xsl:call-template>
> 		</tbody>
> 		</table>
> 	</body>
> 	</html>
> </xsl:template>
> 
> <xsl:template name="apply-set">
> 	<xsl:param name="set"/>
> 	<tr>
> 		<xsl:apply-templates select="$set"/>
> 	</tr>
> 	<xsl:choose>
> 		<xsl:when test="$set/*">
> 			<xsl:call-template name="apply-set">
> 				<xsl:with-param name="set" select="$set/*"/>
> 			</xsl:call-template>
> 		</xsl:when>
> 		<xsl:otherwise>
> 			<tr valign="bottom">
> 				<xsl:for-each select="$set">
> 					<xsl:apply-templates
> select="/Reports/Report/Measures/*">
> 						<xsl:with-param name="pos"
> select="position()"/>
> 					</xsl:apply-templates>
> 				</xsl:for-each>
> 			</tr>
> 		</xsl:otherwise>
> 	</xsl:choose>
> </xsl:template>
> 
> <xsl:template match="ColGrp">
> 	<td colspan="{$msrs*count(.//Col)}">
> 		<div><xsl:value-of select="@heading"/></div>
> 	</td>
> </xsl:template>
> <xsl:template match="Col">
> 	<td colspan="{$msrs}">
> 		<div><xsl:value-of select="@heading"/></div>
> 	</td>
> </xsl:template>
> <xsl:template match="Measure">
> 	<xsl:param name="pos" />
> 	<td align="center">
> 		<div onclick="sortFullGrid({position()}, {$pos},
> '')">
> 			<xsl:value-of select="@heading"/>
> 		</div>
> 	</td>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> INPUT XML:
> <?xml version="1.0" encoding="UTF-8" ?>
> <Reports>
>  <Report>
>  <Measures>
>    <Measure idx="1" heading="Total Pages" />
>    <Measure idx="2" heading="Cost" />
>  </Measures>
>  <Columns>
>    <ColGrp heading="Quarter">
>      <ColGrp heading="2003">
>        <Col heading="Quarter 1" />
>        <Col heading="Quarter 2" />
>      </ColGrp>
>      <ColGrp heading="2004">
>        <Col heading="Quarter 1" />
>        <Col heading="Quarter 2" />
>      </ColGrp>
>    </ColGrp>
>    <ColGrp>
>      <ColGrp>
>        <Col heading="Total" />
>      </ColGrp>
>    </ColGrp>
>  </Columns>
>  </Report>
> </Reports>
> 
> OUTPUT HTML:
> <html>
>    <body>
>       <table>
>          <tbody>
>             <tr>
>                <td colspan="8">
>                   <div>Quarter</div>
>                </td>
>                <td colspan="2">
>                   <div></div>
>                </td>
>             </tr>
>             <tr>
>                <td colspan="4">
>                   <div>2003</div>
>                </td>
>                <td colspan="4">
>                   <div>2004</div>
>                </td>
>                <td colspan="2">
>                   <div></div>
>                </td>
>             </tr>
>             <tr>
>                <td colspan="2">
>                   <div>Quarter 1</div>
>                </td>
>                <td colspan="2">
>                   <div>Quarter 2</div>
>                </td>
>                <td colspan="2">
>                   <div>Quarter 1</div>
>                </td>
>                <td colspan="2">
>                   <div>Quarter 2</div>
>                </td>
>                <td colspan="2">
>                   <div>Total</div>
>                </td>
>             </tr>
>             <tr valign="bottom">
>                <td align="center">
>                   <div onclick="sortFullGrid(1, 1,
> '')">Total Pages</div>
>                </td>
>                <td align="center">
>                   <div onclick="sortFullGrid(2, 1,
> '')">Cost</div>
>                </td>
>                <td align="center">
>                   <div onclick="sortFullGrid(1, 2,
> '')">Total Pages</div>
>                </td>
>                <td align="center">
>                   <div onclick="sortFullGrid(2, 2,
> '')">Cost</div>
>                </td>
>                <td align="center">
>                   <div onclick="sortFullGrid(1, 3,
> '')">Total Pages</div>
>                </td>
>                <td align="center">
>                   <div onclick="sortFullGrid(2, 3,
> '')">Cost</div>
>                </td>
>                <td align="center">
>                   <div onclick="sortFullGrid(1, 4,
> '')">Total Pages</div>
>                </td>
>                <td align="center">
>                   <div onclick="sortFullGrid(2, 4,
> '')">Cost</div>
>                </td>
>                <td align="center">
>                   <div onclick="sortFullGrid(1, 5,
> '')">Total Pages</div>
>                </td>
>                <td align="center">
> 
=== message truncated ===



		
___________________________________________________________ 
NEW Yahoo! Cars - sell your car and browse thousands of new and used cars online! http://uk.cars.yahoo.com/


transparent
Print
Mail
Like It
Disclaimer
.

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 www.altova.com/list/index.html. 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.

.
.

transparent

transparent