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, chained conditions, and abbreviated syntax (`.` for self, `..` for parent within a path).

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

  • 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