Class XPathMatcher

java.lang.Object
org.openrewrite.xml.XPathMatcher

public class XPathMatcher extends Object
Supports a limited set of XPath expressions, specifically those documented on this page. Additionally, supports `local-name()` and `namespace-uri()` conditions, `and`/`or` operators, and chained conditions.

Used for checking whether a visitor's cursor meets a certain XPath expression.

The "current node" for XPath evaluation is always the root node of the document. As a result, '.' and '..' are not recognized.

  • Constructor Details

    • XPathMatcher

      public XPathMatcher(String expression)
  • Method Details

    • matches

      public boolean matches(org.openrewrite.Cursor cursor)
      Checks if the given XPath expression matches the provided cursor.
      Parameters:
      cursor - the cursor representing the XML document
      Returns:
      true if the expression matches the cursor, false otherwise