Class NodeSelector

    • Method Detail

      • of

        public static NodeSelector of​(java.util.function.Predicate<? super NodeInfo> predicate)
        Create a NodeTest based on a supplied predicate. The NodeTest selects a node if the predicate returns true.
        Parameters:
        predicate - the supplied predicate (a boolean function of a node)
        Returns:
        a NodeTest matching the selected nodes
      • test

        public boolean test​(NodeInfo node)
        Description copied from class: NodeTest
        Test whether this node test is satisfied by a given node. This alternative method is used in the case of nodes where calculating the fingerprint is expensive, for example DOM or JDOM nodes. The default implementation calls the method NodeTest.matches(int, NodeName, SchemaType)
        Specified by:
        test in interface NodePredicate
        Overrides:
        test in class NodeTest
        Parameters:
        node - the node to be matched
        Returns:
        true if the node test is satisfied by the supplied node, false otherwise
      • getDefaultPriority

        public double getDefaultPriority()
        Description copied from class: NodeTest
        Determine the default priority to use if this node-test appears as a match pattern for a template with no explicit priority attribute.
        Specified by:
        getDefaultPriority in interface ItemType
        Specified by:
        getDefaultPriority in class NodeTest
        Returns:
        the default priority for the pattern
      • matches

        public boolean matches​(int nodeKind,
                               NodeName name,
                               SchemaType annotation)
        Description copied from class: NodeTest
        Test whether this node test is satisfied by a given node. This method is only fully supported for a subset of NodeTests, because it doesn't provide all the information needed to evaluate all node tests. In particular (a) it can't be used to evaluate a node test of the form element(N,T) or schema-element(E) where it is necessary to know whether the node is nilled, and (b) it can't be used to evaluate a node test of the form document-node(element(X)). This in practice means that it is used (a) to evaluate the simple node tests found in the XPath 1.0 subset used in XML Schema, and (b) to evaluate node tests where the node kind is known to be an attribute.
        Specified by:
        matches in class NodeTest
        Parameters:
        nodeKind - The kind of node to be matched
        name - identifies the expanded name of the node to be matched. The value should be null for a node with no name.
        annotation - The actual content type of the node. Null means no constraint.
        Returns:
        true if the node matches this node test
      • getUType

        public UType getUType()
        Description copied from interface: ItemType
        Get the corresponding UType. A UType is a union of primitive item types.
        Returns:
        the smallest UType that subsumes this item type