Class IdFunction

  • All Implemented Interfaces:
    Function

    public class IdFunction
    extends java.lang.Object
    implements Function

    4.1 node-set id(object)

    The id function returns a List of all the elements in the context document that have an ID matching one of a specified list of IDs. How an attribute is determined to be of type ID depends on the navigator, but it normally requires that the attribute be declared to have type ID in the DTD.

    There should be no more than one element in any document with a certain ID. However, if there are multiple such elements--i.e. if there are duplicate IDs--then this function selects only the first element in document order with the specified ID.

    See Also:
    Section 4.1 of the XPath Specification
    • Constructor Summary

      Constructors 
      Constructor Description
      IdFunction()
      Create a new IdFunction object.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Object call​(Context context, java.util.List args)
      Returns a list of the nodes with the specified IDs.
      static java.util.List evaluate​(java.util.List contextNodes, java.lang.Object arg, Navigator nav)
      Returns a list of the nodes with the specified IDs.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • IdFunction

        public IdFunction()
        Create a new IdFunction object.
    • Method Detail

      • call

        public java.lang.Object call​(Context context,
                                     java.util.List args)
                              throws FunctionCallException
        Returns a list of the nodes with the specified IDs.
        Specified by:
        call in interface Function
        Parameters:
        context - the context at the point in the expression when the function is called
        args - a list with exactly one item which is either a string a node-set
        Returns:
        a List containing the first node in document with each of the specified IDs; or an empty list if there are no such nodes
        Throws:
        FunctionCallException - if args has more or less than one item
      • evaluate

        public static java.util.List evaluate​(java.util.List contextNodes,
                                              java.lang.Object arg,
                                              Navigator nav)
        Returns a list of the nodes with the specified IDs.
        Parameters:
        contextNodes - the context node-set. The first item in this list determines the document in which the search is performed.
        arg - the ID or IDs to search for
        nav - the navigator used to calculate string-values and search by ID
        Returns:
        a List containing the first node in document with each of the specified IDs; or an empty list if there are no such nodes