Saxon.Api

 

 

Saxon.Api

Class ExtensionFunctionCall


public abstract class ExtensionFunctionCall

An instance of this class will be created by the compiler for each function call to this extension function that is found in the source code. The class is always instantiated by calling the method MakeFunctionCall() of the corresponding ExtensionFunctionDefinition. The implementation may therefore retain information about the static context of the call. Once compiled, however, the instance object must be immutable.

Method Summary

 XdmValue Call (XdmValue[] arguments, DynamicContext context)

Method called at run time to evaluate the function.

 void CopyLocalData (ExtensionFunctionCall destination)

A subclass must implement this method if it retains any local data at the instance level. On some occasions (for example, when XSLT or XQuery code is inlined), Saxon will make a copy of an ExtensionFunction object. It will then call this method on the old object, supplying the new object as the value of the argument, and the method must copy all local data items from the old object to the new.

 void SupplyStaticContext (StaticContext context)

Method called by the compiler (at compile time) to provide information about the static context of the function call. The implementation may retain this information for use at run-time, if the result of the function depends on information in the static context.

 

Method Detail

Call

public abstract XdmValue Call(XdmValue[] arguments,
DynamicContext context)

Method called at run time to evaluate the function.

Parameters:

arguments - The values of the arguments to the function, supplied as iterators over XPath sequence values.
context - The dynamic context for evaluation of the function. This provides access to the context item, position, and size, and if required to internal data maintained by the Saxon engine.

Returns:

An iterator over a sequence, representing the result of the extension function. Note that Saxon does not guarantee to read this sequence to completion, so calls on the iterator must have no side-effects. In rare circumstances (for example, when last() is used) Saxon may clone the returned iterator by calling its GetAnother() method, allowing the function results to be read more than once.

CopyLocalData

public virtual void CopyLocalData(ExtensionFunctionCall destination)

A subclass must implement this method if it retains any local data at the instance level. On some occasions (for example, when XSLT or XQuery code is inlined), Saxon will make a copy of an ExtensionFunction object. It will then call this method on the old object, supplying the new object as the value of the argument, and the method must copy all local data items from the old object to the new.

Parameters:

destination - The new extension function object. This will always be an instance of the same class as the existing object.

SupplyStaticContext

public virtual void SupplyStaticContext(StaticContext context)

Method called by the compiler (at compile time) to provide information about the static context of the function call. The implementation may retain this information for use at run-time, if the result of the function depends on information in the static context.

For efficiency, the implementation should only retain copies of the information that it actually needs. It is not a good idea to hold a reference to the static context itself, since that can result in a great deal of compile-time information being locked into memory during run-time execution.

Parameters:

context - Information about the static context in which the function is called