|
Subject: [xsl] Optimization using keys From: António Mota <amsmota@xxxxxxxxx> Date: Wed, 16 Feb 2005 12:21:58 +0000 |
My Menu project is allmost finished (couldn't do it without the list,
for sure) and i'm doing some optimization.
I had two xslts at the beggining on my app, one getting from a tree
only the nodes that match a app name, including all it's childrens
(only the top level menus have a app defined)
and the second replacing some nodes by another ones (of the same input
tree) including children.
Then i changed those two xslt to do the same things in only one xslt.
I've done this.
(identity template)
<xsl:template match="Menu">
<xsl:if test="Aplicacao=$app">
<xsl:copy>
<xsl:apply-templates select="*" mode="copia"/>
</xsl:copy>
</xsl:if>
</xsl:template>
<xsl:template match="*" mode="copia">
<xsl:copy>
<xsl:apply-templates mode="copia"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Menu[MenuTipo='REP']" mode="copia">
<xsl:apply-templates
select="document('TreeMenu.xml')//Menu[Menu_K=current()/MenuData]/Filhos/Menu"
mode="copia"/>
</xsl:template>
<xsl:template match="Orelha[MenuInfoTipo='Subst']" mode="copia">
<xsl:apply-templates
select="document('TreeMenu.xml')//Menu[Menu_K=current()/InfoData]/Orelhas/Orelha"
mode="copia"/>
</xsl:template>
It works ok but it is a little slow (curiosly is fast enough in IE but
slower in FF, and even more slower when running under IDE's). So i
have some questions:
1) Is this a case where i should/could use keys instead (i never used
keys before so it's a little puzzling to me)
<xsl:apply-templates
select="document('TreeMenu.xml')//Menu[Menu_K=current()/MenuData]/Filhos/Menu"
mode="copia"/>
2) Since the lookup document and the input tree are the same, why it
doesn't work when i changed that line to
<xsl:apply-templates
select="document('')//Menu[Menu_K=current()/MenuData]/Filhos/Menu"
mode="copia"/>
3) Is this a correct use of "modes"?
Thanks again to all.
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] RE: Display children of n, Andrew Welch | Thread | Re: [xsl] Optimization using keys, David Carlisle |
| RE: [xsl] RE: Display children of n, Andrew Welch | Date | [xsl] copying raw xml and changing , Graham Walsh |
| Month |