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

Antwort: RE: bad programming for speedup?

Subject: Antwort: RE: bad programming for speedup?
From: christoph.naber@xxxxxxxxxxxxxxxxxxx
Date: Tue, 24 Jul 2007 14:20:28 +0200
 Antwort: RE:  bad programming for speedup?
mike@xxxxxxxxxxxx schrieb am 24.07.2007 12:29:21:

> In trying to reverse-engineer your code, it looks to me as if you are
doing
> a classic "group-adjacent" problem, where a group of adjacent row
elements
> are wrapped in a table element.

thats it!

> The key point I think is that it's usually not necessary. In the vast
> majority of cases there is a way of solving the performance problems
that
> doesn't require you to write bad code.

I think I found one way with your help/hint of recursive templates.

The code:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>

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

        <xsl:template match="*">
                <xsl:copy>
                        <xsl:copy-of select="@*" />
                        <xsl:apply-templates select="*" />
                </xsl:copy>
        </xsl:template>

        <xsl:template match="row[position() = 1 or
preceding-sibling::*[name() != 'row' and position() = 1]]" >
                <table>
                        <xsl:apply-templates select="." mode="more2come"/>
                </table>
        </xsl:template>

        <xsl:template match="row" mode="more2come">
                <xsl:copy>
                        <xsl:copy-of select="@*" />
                        <xsl:apply-templates select="*" />
                </xsl:copy>
                <xsl:if test="following-sibling::*[name() = 'row' and
position() = 1]">
                        <xsl:apply-templates
select="following-sibling::row[position() = 1]" mode="more2come" />
                </xsl:if>
        </xsl:template>

        <xsl:template match="row" >
        </xsl:template>

</xsl:stylesheet>

It was much easier than the solution with <xsl:key>. But I learned much
about XPath.

Thank you for helping me to find a way..

Christoph Naber


If you are not the intended addressee, please inform us immediately that you
have received this e-mail by mistake and delete it. We thank you for your
support.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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-2013 All Rights Reserved.