xsl-list
[Top] [All Lists]

Re: [xsl] XSLT 4: map serialization

2020-11-25 09:03:53

As for this particular example, I suspect that building an XML document 
incrementally from a sequence of single elements will have performance 
implications -- similar to concatenating to a string many times. 


It's true that bottom-up construction of a tree can be very expensive because 
of the need for copy operations. However, the copying can be avoided with 
careful optimization. For example with inline construction like

element('A', (element('B', ()), element('C', ()))

you can avoid copying B and C when attaching them to A either by recognising 
this pattern statically, or by some kind of run-time laziness.

On the Java side I've produced an API called the "sapling" model where the 
functions such as element() here don't construct a full XPath-navigable tree, 
but just a skeletal tree, whose construction is completed lazily the first time 
it is used for XPath navigation; this avoids the repeated copying of 
intermediate subtrees during construction. (I believe Javascript processor use 
a similar approach to avoid string copying for repetitive string concatenation).

Michael Kay
Saxonica 
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>