Saxon.Api

Class DocumentBuilder

Class DomDestination

Class DynamicContext

Class DynamicError

Class EmptyEnumerator

Class ExtensionFunctionCall

Class ExtensionFunctionDefinition

Class NullDestination

Class ParameterDetails

Class Processor

Class QName

Class SchemaManager

Class SchemaValidator

Class Serializer

Class StandardLogger

Class StaticContext

Class StaticError

Class TextWriterDestination

Class TreeProtector

Class XPathCompiler

Class XPathExecutable

Class XPathSelector

Class XQueryCompiler

Class XQueryEvaluator

Class XQueryExecutable

Class XdmAnyFunctionType

Class XdmAnyItemType

Class XdmAnyNodeType

Class XdmAtomicType

Class XdmAtomicValue

Class XdmDestination

Class XdmEmptySequence

Class XdmFunctionItem

Class XdmItem

Class XdmItemType

Class XdmNode

Class XdmNodeKind

Class XdmSequenceType

Class XdmValue

Class XmlDestination

Class Xslt30Transformer

Class XsltCompiler

Class XsltExecutable

Class XsltPackage

Class XsltTransformer

Enum RecoveryPolicy

Enum SchemaValidationMode

Enum TreeModel

Enum WhitespacePolicy

Enum XdmAxis

Interface IMessageListener

Interface IQueryResolver

Interface IResultDocumentHandler

Interface IXdmEnumerator

Interface IXmlLocation

Interface SchemaResolver

 

Saxon.Api
Class ExtensionFunctionDefinition


public abstract class ExtensionFunctionDefinition
implements object

Abstract superclass for user-written extension functions. An extension function may be implemented as a subclass of this class, with appropriate implementations of the defined methods.

More precisely, a subclass of ExtensionFunctionDefinition identifies a family of extension functions with the same (namespace-qualified) name but potentially having different arity (number of arguments).

A user-defined extension function is typically implemented using a pair of classes: a class that extends ExtensionFunctionDefinition, whose purpose is to define the properties of the extension function (in particular, its signature -- the types of its arguments and result); and a class that extends ExtensionFunctionCall, whose purpose is to perform the actual evaluation.

The ExtensionFunctionDefinition is immutable and will normally have a singleton instance for each subclass; this singleton instance is registered with the Processor to associate the name of the extension function with its definition.

The ExtensionFunctionCall has one instance for each call on the extension function appearing in the source code of a stylesheet or query; this instance is created when Saxon calls the method MakeFunctionCall provided by the ExtensionFunctionDefinition object. The instance of ExtensionFunctionCall holds information about the static context of the function call, and its Call method is called (by Saxon) to evaluate the extension function at run-time.


Property Summary
 QName FunctionName

Read-only property returning the name of the extension function, as a QName.

 int MinimumNumberOfArguments

Read-only property giving the minimum number of arguments in a call to this extension function.

 int MaximumNumberOfArguments

Read-only property giving the maximum number of arguments in a call to this extension function.

 XdmSequenceType[] ArgumentTypes

Read-only property giving the required types of the arguments to this extension function. If the number of items in the array is less than the maximum number of arguments, then the last entry in the returned ArgumentTypes is assumed to apply to all the rest; if the returned array is empty, then all arguments are assumed to be of type item()*

 Boolean TrustResultType

This property may return true for a subclass if it guarantees that the returned result of the function will always be of the declared return type: setting this to true by-passes the run-time checking of the type of the value, together with code that would otherwise perform atomization, numeric type promotion, and similar conversions. If the value is set to true and the value is not of the correct type, the effect is unpredictable and probably disastrous.

 Boolean DependsOnFocus

This property must return true for a subclass if the evaluation of the function makes use of the context item, position, or size from the dynamic context. It should also return true (despite the property name) if the function makes use of parts of the static context that vary from one part of the query or stylesheet to another. Setting the property to true inhibits certain Saxon optimizations, such as extracting the call from a loop, or moving it into a global variable.

 Boolean HasSideEffects

This property should return true for a subclass if the evaluation of the function has side-effects. Saxon never guarantees the result of calling functions with side-effects, but if this property is set, then certain aggressive optimizations will be avoided, making it more likely that the function behaves as expected.

 
Method Summary
 XdmSequenceType ResultType(Saxon.Api.XdmSequenceType[] ArgumentTypes)

Method returning the declared type of the return value from the function. The type of the return value may be known more precisely if the types of the arguments are known (for example, some functions return a value that is the same type as the first argument. The method is therefore called supplying the static types of the actual arguments present in the call.

 ExtensionFunctionCall MakeFunctionCall()

Factory method to create an ExtensionFunctionCall object, representing a specific function call in the XSLT or XQuery source code. Saxon will call this method once it has identified that a specific call relates to this extension function.

 
Property Detail

FunctionName

public abstract QName FunctionName {}

Read-only property returning the name of the extension function, as a QName.

A getter for this property must be implemented in every subclass.


MinimumNumberOfArguments

public abstract int MinimumNumberOfArguments {}

Read-only property giving the minimum number of arguments in a call to this extension function.

A getter for this property must be implemented in every subclass.


MaximumNumberOfArguments

public abstract int MaximumNumberOfArguments {}

Read-only property giving the maximum number of arguments in a call to this extension function.

A getter for this property must be implemented in every subclass.


ArgumentTypes

public abstract XdmSequenceType[] ArgumentTypes {}

Read-only property giving the required types of the arguments to this extension function. If the number of items in the array is less than the maximum number of arguments, then the last entry in the returned ArgumentTypes is assumed to apply to all the rest; if the returned array is empty, then all arguments are assumed to be of type item()*

A getter for this property must be implemented in every subclass.


TrustResultType

public virtual Boolean TrustResultType {}

This property may return true for a subclass if it guarantees that the returned result of the function will always be of the declared return type: setting this to true by-passes the run-time checking of the type of the value, together with code that would otherwise perform atomization, numeric type promotion, and similar conversions. If the value is set to true and the value is not of the correct type, the effect is unpredictable and probably disastrous.

The default value of this property is false. A getter for this property may be implemented in a subclass to return a different value.


DependsOnFocus

public virtual Boolean DependsOnFocus {}

This property must return true for a subclass if the evaluation of the function makes use of the context item, position, or size from the dynamic context. It should also return true (despite the property name) if the function makes use of parts of the static context that vary from one part of the query or stylesheet to another. Setting the property to true inhibits certain Saxon optimizations, such as extracting the call from a loop, or moving it into a global variable.

The default value of this property is false. A getter for this property may be implemented in a subclass to return a different value.


HasSideEffects

public virtual Boolean HasSideEffects {}

This property should return true for a subclass if the evaluation of the function has side-effects. Saxon never guarantees the result of calling functions with side-effects, but if this property is set, then certain aggressive optimizations will be avoided, making it more likely that the function behaves as expected.

The default value of this property is false. A getter for this property may be implemented in a subclass to return a different value.


Method Detail

ResultType

public abstract XdmSequenceType ResultType(Saxon.Api.XdmSequenceType[] ArgumentTypes)

Method returning the declared type of the return value from the function. The type of the return value may be known more precisely if the types of the arguments are known (for example, some functions return a value that is the same type as the first argument. The method is therefore called supplying the static types of the actual arguments present in the call.

This method must be implemented in every subclass.

Parameters:
ArgumentTypes -
The static types of the arguments present in the function call
returns
An XdmSequenceType representing the declared return type of the extension function

MakeFunctionCall

public abstract ExtensionFunctionCall MakeFunctionCall()

Factory method to create an ExtensionFunctionCall object, representing a specific function call in the XSLT or XQuery source code. Saxon will call this method once it has identified that a specific call relates to this extension function.

This method must be implemented in every subclass. The implementation should normally instantiate the relevant subclass of ExtensionFunctionCall, and return the new instance.

returns
An instance of the appropriate implementation of ExtensionFunctionCall