Patch #1411
closeduser-defined closure() function
0%
Description
SourceForge user: gschadow
Hi Michael,
this is the patch that implements user-defined closure()
functions. For clarity I have this decoupled from the
previous patch that contains the special-form / deferred
argument evaluation for extension functions. So, this
patch depends on the previous patch.
The attached ZIP file contains:
closure-only-for-saxon8.1.1.diff -- the patch
Functions.java -- a closure() extension function
demo/closure.xsl -- an example
demo/ClosureTestCounter.java -- a side-effect function
for the example
The demo is run simply on any input (e.g., on itself)
saxon8 closure.xsl closure.xsl
the point of the demo is to show how database inserts
and unique id generation would be deferred up until a
foreign key is required. In this example, a parent id is
only created if we actually insert a child that would refer
to the parent id. The output says what the id attributes
should be.
Implementing this required changes to ExpressionTool
eagerEvaluate and to Closure itself. Please look these
over, IMO they work fine. But this territory is a bit
obscure to me so I might be wrong. The problem with
your code seems to be that the closures are evaluated
when the argument is assigned to the variable or passed
as parameter, which is too early. It should be evaluated
only if the value is actually used. My patch seems to
accomplish this.
Please consider if you might adopt these few changes to
the core if at all possible. You don't need to actually
supply the closure() extension if you don't want to, but
the changes to ExpressionTool and Closure itself would
be highly appreciated.
Thanks,
-Gunther
Files
Please register to edit this issue