Re: [xsl] XSLT result tree fragment, with XSLT 3.0 and xsl:variable

Subject: Re: [xsl] XSLT result tree fragment, with XSLT 3.0 and xsl:variable
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Apr 2023 22:24:07 -0000
> The idea that you can't inspect the output also lets an implementation use a
different representation, perhaps a lighter-weight one, for result trees.

James Clark taught me that it's better to put the complexity into the
implementation rather than into the spec. So I somehow doubt that was his
thinking. It's perfectly easy to use different tree models internally in
different cases. (We also do that for maps, giving considerable savings for
some usage scenarios).

In a very early Saxon release I represented result-tree-fragments as a
seriallzed string of lexical XML which was reparsed if you needed to convert
it to a node-set. That implementation is perfectly viable today, it just
wouldn't work especially well the way most people use variables. But there are
other models worth exploring - for example the Saxon Java API now offers the
"sapling" tree model which is an immutable structure with no node identity or
parent pointers, so small modifications like adding an attribute do not
require copying the whole tree.

Michael Kay
Saxonica

Current Thread