xsl-list
[Top] [All Lists]

RE: [xsl] Re: Benefits of xsl.sequence

2008-09-30 04:58:48
Could the use of xsl:sequence be considered mostly an 
uptimization issue? A lot of the functionality of 
xsl:sequence is covered by xsl:copy-of, and we can make 
sequences in e.g. variables directly like xsl:variable 
name=x" select="(2, 5, 8)"/>?

If you're using atomic values, then xsl:copy-of and xsl:sequence produce the
same run-time effect. However, if the system doesn't know statically that
the input will be atomic values rather than nodes, then more code might be
generated for the xsl:copy-of case, because it is a more complex
instruction. (xsl:sequence is essentially a no-op - it's just a syntax
wrapper that presents an XPath expression as an XSLT instruction.) Also,
because xsl:copy-of has the potential to create new nodes, it can't be
optimized away quite as easily as xsl:sequence; for example a call to a
function that calls xsl:copy-of can't safely be moved out of a loop.


Is there anything in XSLT 2.0 we can only do using xsl:sequence?


Yes: this is the only way that you can write a function (or indeed a
template) that returns references to existing nodes, as distinct from newly
constructed nodes. That's very important if you're doing graph-manipulation
operations like checking your data for cycles.

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>
--~--