Menu

Tool executing ("grabbing"/returning/displaying values from) instead of evaluating PMD Xpath expressions?

Help
2014-09-03
2014-09-08
  • Christian Balzer

    Hi all!

    We are struggling a bit with PMD and its PMD Rule Designer. It seems to only evaluate XPath statements and work with boolean values.

    Sometimes, it would really help to be able to see what (a part of) our XPath grabbed as a String. For example, the other day, we were struggling, because we were trying to compare the first character of the argument passed into an annotation to a set of characters. After hours of trial and error, we realized that we had grabbed the opening quotation mark instead of the first letter. Being able to see what we actually grab would have saved us hours of trial and error...

    So, is there a GUI/tool that lets us run XPath on Java code and returns what we selected, instead of just evaluating an expression for true or false? Or can the PMD Rule Designer be made to do that somehow?

    Kind regards,

    Christian

    P.S.: I'm cross-posting this from StackExchange, in the hopes it gets more attention here (and because I initially didn't know about this board).

     
  • Brian R

    Brian R - 2014-09-03

    If you use PMD in Eclipse, there is a relatively new XPath Designer view in it that allows you to enter XPath expressions and view the results.

    Select the test class in the Package Explorer, chose to work on either the class or selected method in the designer, then enter your xpath expression in the top right text box. Click the Go buttonand any results should appear in the table below it.

     
  • Brian R

    Brian R - 2014-09-03

    Just played with it, there are some UI bugs in that view but the searches should still function properly. Its been awhile since I put it together.

     
  • Andreas Dangel

    Andreas Dangel - 2014-09-08

    I know, it's not so easy. In the lower left panel, you see all the attributes (including values), that are available for the selected node in the AST (upper left).

    You can enter the XPath expression and run it. The nodes, that match the complete expression, are shown in the lower right panel. Click on one node result, to see the corresponding selection in the source code.

    However, you can't see any intermediate results of the xpath. I usually split the xpath manually, to see such intermediate results.

    If you have ideas on how to improve this designer (which is very, very helpful in developing XPath based rules), feel free to create feature-requests.

     

Log in to post a comment.

MongoDB Logo MongoDB