RE: Re: Benefits of xsl.sequence
> 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/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format