Class CurrentGroupPattern

  • All Implemented Interfaces:
    ExportAgent, Locatable, IdentityComparable, Traceable

    public class CurrentGroupPattern
    extends AnchorPattern
    This is a special pattern that matches the "anchor node". It is used for the selectors that arise when evaluating XPath expressions in streaming mode; the anchor node is the context node for the streamed XPath evaluation. Given a streamed evaluation of an expression such as ./BOOKS/BOOK/PRICE, the way we evaluate this is to turn it into a pattern, which is then tested against all descendant nodes. Conceptually the pattern is $A/BOOKS/BOOK/PRICE, where $A is referred to as the anchor node. When we evaluate the pattern against (say) a PRICE element, the match will only succeed if the name of the element is "PRICE" and its ancestors are, in order, a BOOK element, a BOOKS element, and the anchor node $A.
    • Constructor Detail

      • CurrentGroupPattern

        protected CurrentGroupPattern()
    • Method Detail

      • matchesCurrentGroup

        public boolean matchesCurrentGroup()
        Ask whether the pattern is anchored on a call on current-group()
        Overrides:
        matchesCurrentGroup in class Pattern
        Returns:
        true if calls on matchesBeneathAnchor should test with all nodes in the current group as anchor nodes. If false, only the first node in a group is treated as the anchor node
      • matchesBeneathAnchor

        public boolean matchesBeneathAnchor​(NodeInfo node,
                                            NodeInfo anchor,
                                            XPathContext context)
                                     throws XPathException
        Description copied from class: AnchorPattern
        Determine whether this pattern matches a given Node within the subtree rooted at a given anchor node. This method is used when the pattern is used for streaming.
        Overrides:
        matchesBeneathAnchor in class AnchorPattern
        Parameters:
        node - The NodeInfo representing the Element or other node to be tested against the Pattern
        anchor - The anchor node, which must match any AnchorPattern subpattern
        context - The dynamic context. Only relevant if the pattern uses variables, or contains calls on functions such as document() or key().
        Returns:
        true if the node matches the Pattern, false otherwise
        Throws:
        XPathException - if an error occurs while matching the pattern (the caller will usually treat this the same as a false result)
      • export

        public void export​(ExpressionPresenter presenter)
                    throws XPathException
        Description copied from class: Expression
        Diagnostic print of expression structure. The abstract expression tree is written to the supplied output destination.
        Specified by:
        export in interface ExportAgent
        Overrides:
        export in class AnchorPattern
        Parameters:
        presenter - the expression presenter used to display the structure
        Throws:
        XPathException - if the export fails, for example if an expression is found that won't work in the target environment.