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

Re: Optimization using keys

Subject: Re: Optimization using keys
From: António Mota <amsmota@xxxxxxxxx>
Date: Wed, 16 Feb 2005 19:39:39 +0000
xsl optimization
I'm also trying to optimize this template

(indentity template)

       <xsl:template match="Menu">
                <xsl:choose>
                        <xsl:when
test="count(./ancestor-or-self::Menu)+count(./preceding::Menu)=number($pos)">
                                <xsl:variable name="pai" select="Menu_K"/>
                                <xsl:copy>
                                        <xsl:apply-templates
select="@*|node()[not(name()='MenuTipo' or name()='Filhos' )]"
mode="menu"/>
                                        <MenuTipo>EXP</MenuTipo>
                                        <Filhos>
                                                <xsl:for-each
select="Filhos/Menu">
                                                        <xsl:variable
name="xmldoc" select="document(concat($xmluri,'?Menu_K=',Menu_K,'&amp;Pai_K=',$pai))"/>
                                                        <xsl:variable
name="filhos" select="Filhos"/>
                                                        <xsl:variable
name="orelhas" select="Orelhas"/>
                                                       
<xsl:apply-templates select="$xmldoc/Menus/Menu" mode="menu">
                                                               
<xsl:with-param name="filhos" select="$filhos"/>
                                                               
<xsl:with-param name="orelhas" select="$orelhas"/>
                                                        </xsl:apply-templates>
                                                </xsl:for-each>
                                        </Filhos>
                                </xsl:copy>
                        </xsl:when>
                        <xsl:otherwise>
                                <xsl:copy>
                                        <xsl:apply-templates select="*"/>
                                </xsl:copy>
                        </xsl:otherwise>
                </xsl:choose>
        </xsl:template>

      <xsl:template match="Menu" mode="menu">
                <xsl:param name="filhos"/>
                <xsl:param name="orelhas"/>
                <xsl:copy>
                        <xsl:apply-templates mode="menu"/>
                        <xsl:if test="$filhos">
                                <xsl:copy-of select="$filhos"/>
                        </xsl:if>
                        <xsl:if test="$orelhas">
                                <xsl:copy-of select="$orelhas"/>
                        </xsl:if>
                </xsl:copy>
        </xsl:template>

but it is too slow and i don't know why. I thought it was the document
($xmluri is pointing to a ASP that returns a chunk of XML), but i've
tested with a small xml input tree and it's fast enough, so it seems
the problem is with the XML size. However i don't want to do much
things with it.

I'll fraze it (poor) english. Given a XML with nested Menu structures,
i want to copy all the nodes to the output tree *except* the one that
corresponds to the $pos position, wich i want to replace with the
result from document.

For each of the resulting document() nodes i want to append the
original <Filhos> and <Orelhas>.

So is there a optimized way to do this? Including the "simple copy" of
the nodes?


Thanks again.

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.