Checkstyle provides a command-line option that displays the AST tree for a single file. I know this can be done through the Rule Designer. Is there a possibility that PMD will allow for the AST tree to be output via the CLI? Better still, output the AST as an xml doc?
I assume the Xpath works on elements specified in the grammar. It would be easier to work with an xml document that mimics the tree structure so that the Xpath can be tested independently and then integrated into rule changes, if needed. JavaParser allows for xml to be output for a Java source.
We could add an "export to XML" option in the designer. We could even let this XML document be dumpable from the designer CLI, without starting the GUI. But I don't think the value added to adding this to the PMD CLI would justify the added complexity.