xsl-list
[Top] [All Lists]

RE: parameters in XSLT 2.0

2005-06-07 16:40:20
First, am I right that if I use an "as" attribute of element() or 
node() I am passing a reference to the original element or node, and 
thus that this is an efficient operation?

In the examples below you are passing a reference. If you used xsl:copy-of
rather that xsl:sequence you would be creating a copy. 

The effect of using "as" on performance may be positive or negative. It may
cause the system to do run-time checks that would otherwise not be
performed. On the other hand, it gives the system compile-time information
that may be useful to perform optimizations. I would use it as widely as
possible because it speeds the development cycle and catches bugs more
efficiently, and not worry too much about any effect on performance.


Related, am I correct that these below are equivalent from a 
processing 
standpoint?

<xsl:variable name="foo" select="bar" as="element()"/>

<xsl:variable name="foo" as="element()">
   <xsl:sequence select="bar"/>
</xsl:variable>

Yes.

Finally, in general, under what conditions should one use tunnel 
parameters?  I do a lot of parameter passing in my 
stylesheets, though 
the content of those parameters is typically fixed.


Use them if A calls E via B, C, and D, and you want to get information from
A to E without cluttering the code of templates B, C, and D. The most likely
use-case for this is if you are reusing existing templates B, C, and D and
want to reuse them unchanged.

Michael Kay
http://www.saxonica.com/




--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--