Package net.sf.saxon.s9api
Interface ExtensionFunction
-
public interface ExtensionFunction
This is an interface for simple external/extension functions. Users can implement this interface and register the implementation with theProcessor
; the function will then be available for calling from all queries, stylesheets, and XPath expressions compiled under this Processor. Extension functions implemented using this interface are expected to be free of side-effects, and to have no dependencies on the static or dynamic context. A richer interface for extension functions is provided via theExtensionFunctionDefinition
class.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description XdmValue
call(XdmValue[] arguments)
Call the function.SequenceType[]
getArgumentTypes()
Declare the types of the argumentsQName
getName()
Return the name of the external functionSequenceType
getResultType()
Declare the result type of the external function
-
-
-
Method Detail
-
getName
QName getName()
Return the name of the external function- Returns:
- the name of the function, as a QName.
-
getResultType
SequenceType getResultType()
Declare the result type of the external function- Returns:
- the result type of the external function
-
getArgumentTypes
SequenceType[] getArgumentTypes()
Declare the types of the arguments- Returns:
- a sequence of SequenceType objects, one for each argument to the function, representing the expected types of the arguments
-
call
XdmValue call(XdmValue[] arguments) throws SaxonApiException
Call the function. The implementation of this method represents the body of the external function.- Parameters:
arguments
- the arguments, as supplied in the XPath function call. These will always be of the declared types. Arguments are converted to the required types according to the standard XPath function conversion rules - for example, if the expected type is atomic and a node is supplied in the call, the node will be atomized- Returns:
- the result of the function. This must be an instance of the declared return type; if it is not, a dynamic error will be reported
- Throws:
SaxonApiException
- can be thrown if the implementation of the function detects a dynamic error
-
-