Subject: Re: [xsl] Slow XSLT From: Cleyton Jordan <cleytonjordan@xxxxxxxxxxx> Date: Mon, 3 Mar 2008 18:48:43 +0000 (GMT) |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Slow XSLT, Manfred Staudinger | Thread | Re: [xsl] Slow XSLT, Michael Ludwig |
Re: [xsl] Is it possible to nest te, David Carlisle | Date | [xsl] [Announce] XQuery Training Ev, Stylus Studio |
Month |