[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Slow XSLT

Subject: Re: Slow XSLT
From: Cleyton Jordan <cleytonjordan@xxxxxxxxxxx>
Date: Mon, 3 Mar 2008 18:48:43 +0000 (GMT)
Re:  Slow XSLT
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/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.