xsl-list
[Top] [All Lists]

Re: [xsl] Does <xsl:copy> use a lot of memory? Is there an alternative that is more efficient?

2012-09-03 03:32:08

On 02/09/2012 16:34, Dimitre Novatchev wrote:
In case the input document is parsed successfully, wouldn't the use of
<xsl:sequence> (instead of <xsl:copy-of>) result in using less memory?


In most circumstances both will do exactly the same thing:

- if you're writing to the serializer, both emit a stream of events representing a traversal of the selected nodes - if you're writing to the content of an element in a temporary tree, both cause a physical copy to be made

If you're returning the result of a function, xsl:sequence returns a reference to an existing node while xsl:copy-of (in Saxon) returns a "virtual copy" which shares memory with the original. Processing the virtual copy is more expensive because you have to prevent axis navigation straying outside the subtree of the node that was "copied", but this is a processing cost not a memory cost.

Michael Kay
Saxonica

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

<Prev in Thread] Current Thread [Next in Thread>