Class MatchXpathCheck

  • All Implemented Interfaces:
    Configurable, Contextualizable

    public class MatchXpathCheck
    extends AbstractCheck

    Evaluates Xpath query and report violation on all matching AST nodes. This check allows user to implement custom checks using Xpath. If Xpath query is not specified explicitly, then the check does nothing.

    It is recommended to define custom message for violation to explain what is not allowed and what to use instead, default message might be too abstract. To customize a message you need to add message element with matchxpath.match as key attribute and desired message as value attribute.

    Please read more about Xpath syntax at Xpath Syntax. Information regarding Xpath functions can be found at XSLT/XPath Reference. Note, that @text attribute can be used only with token types that are listed in XpathUtil.

    • Property query - Specify Xpath query. Type is java.lang.String. Default value is "".

    Parent is com.puppycrawl.tools.checkstyle.TreeWalker

    Violation Message Keys:

    • matchxpath.match
    Since:
    8.39