This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: keys fast for lookups? attribute-value template in xsl:call-template?
- To: "'xsl-list at lists dot mulberrytech dot com'" <xsl-list at lists dot mulberrytech dot com>
- Subject: RE: [xsl] keys fast for lookups? attribute-value template in xsl:call-template?
- From: Mark Feblowitz <mfeblowitz at frictionless dot com>
- Date: Mon, 6 Aug 2001 10:03:11 -0400
- Reply-To: xsl-list at lists dot mulberrytech dot com
If you're using Saxon, there's a way to allow the use of a variable in a
template name:
saxon:allow-avt This attribute may be set on the xsl:call-template element.
If set to the value "yes", it causes the name attribute of xsl:call-template
to be interpreted as an attribute value template. This allows the selection
of the called template to be decided at run-time. Typical usage
is:[NL]<xsl:call-template name="{$tname}" saxon:allow-avt="yes">
Don't forget to define the saxon namespace.
----------------------------------------------------------------------------
----
Mark Feblowitz [t] 617.715.7231
Frictionless Commerce Incorporated [f] 617.495.0188
XML Architect [e]
mfeblowitz@frictionless.com
400 Technology Square, 9th Floor
Cambridge, MA 02139
www.frictionless.com
-----Original Message-----
From: David_Marston@lotus.com [mailto:David_Marston@lotus.com]
Sent: Friday, August 03, 2001 10:13 PM
To: xsl-list@lists.mulberrytech.com
Subject: Re: [xsl] keys fast for lookups? attribute-value template in
xsl:call-template?
Mike Lamb writes:
>I had thought of using a key over this document to perform the lookup.
>My xsl is:
> <xsl:key name="ziptodealer" match="ZIP" use="@zip"/>
>...
>This works fine, but as performance is really important here I would
>like some feedback about whether this is absolutely the fastest way to
>get this done.
General Principle: keys were designed so as to allow developers the
maximum potential for optimization. If anything can be tweaked for good
performance, keys should be it.
Lesser Principle: since "lazy evaluation" is an optimization tactic,
assume that you don't get a payoff until you look up a given value
more than once. If each zip is looked up once, you may not benefit.
Real-world answer: measure performance in your environment unless you
have clear-cut knowledge of how the Lesser Principle applies to you.
>Looks like the name attribute of xsl:call-template does not expect an
>attribute-value template.
That's correct.
>Any thoughts on how I might get this done? I am trying to avoid writing
>the huge switch statement over dealercode.
Look in the FAQ for some tricks. Also, look for commonalities among
dealers (to share templates) or ways to throw more parameters at the
template. Use more keys on dealercode to set parameter values.
.................David Marston
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list