Class XdmFunctionItem

  • All Implemented Interfaces:
    java.lang.Iterable<XdmItem>
    Direct Known Subclasses:
    XdmArray, XdmMap

    public class XdmFunctionItem
    extends XdmItem
    The class XdmFunctionItem represents a function item
    • Constructor Detail

      • XdmFunctionItem

        public XdmFunctionItem​(Function fi)
        Create an XdmFunctionItem that wraps a supplied Function. This method is primarily for internal use, though it is also available to applications that manipulate data using lower-level Saxon interfaces.
        Parameters:
        fi - the function value to be wrapped.
    • Method Detail

      • getName

        public QName getName()
        Get the name of the function
        Returns:
        the function name, as a QName, or null for an anonymous inline function item
      • getArity

        public int getArity()
        Get the arity of the function
        Returns:
        the arity of the function, that is, the number of arguments in the function's signature
      • isAtomicValue

        public boolean isAtomicValue()
        Determine whether the item is an atomic value
        Overrides:
        isAtomicValue in class XdmItem
        Returns:
        false, the item is not an atomic value, it is a function item
      • getSystemFunction

        public static XdmFunctionItem getSystemFunction​(Processor processor,
                                                        QName name,
                                                        int arity)
                                                 throws SaxonApiException
        Get a system function. This can be any function defined in XPath 3.1 functions and operators, including functions in the math, map, and array namespaces. It can also be a Saxon extension function, provided a licensed Processor is used.
        Parameters:
        processor - the processor
        name - the name of the requested function
        arity - the arity of the requested function
        Returns:
        the requested function, or null if there is no such function. Note that some functions (those with particular context dependencies) may be unsuitable for dynamic calling.
        Throws:
        SaxonApiException - No longer thrown, but remains in the method signature for backwards compatibility
      • asFunction

        public java.util.function.Function<? super XdmValue,​? extends XdmValue> asFunction​(Processor processor)
        Get an equivalent Java Function object representing this XdmFunction. This is possible only for arity-1 functions.
        Parameters:
        processor - the processor
        Returns:
        a Java Function. This takes an XdmValue as its argument, and returns the function result in the form of an XdmValue. The Function throws an unchecked exception if evaluation fails
        Throws:
        java.lang.IllegalStateException - if the arity of the function is not one (1).
      • asStep

        public Step<XdmItem> asStep​(Processor processor)
        Get an equivalent Step object representing this XdmFunction. This is possible only for arity-1 functions.
        Parameters:
        processor - the processor
        Returns:
        a Step. This takes an XdmItem as its argument, and returns the function result in the form of an XdmStream. The Function throws an unchecked exception if evaluation fails
        Throws:
        java.lang.IllegalStateException - if the arity of the function is not one (1).
      • call

        public XdmValue call​(Processor processor,
                             XdmValue... arguments)
                      throws SaxonApiException
        Call the function
        Parameters:
        arguments - the values to be supplied as arguments to the function. The "function conversion rules" will be applied to convert the arguments to the required type when necessary.
        processor - the s9api Processor
        Returns:
        the result of calling the function
        Throws:
        SaxonApiException - if an error is detected