And I want to write a rule that hits, if there is \"No\" in description.
\nI have the following rule in my ruleset
\n<rule name=\"GettingNo\" language=\"xml\" message=\"TEST\" class=\"net.sourceforge.pmd.lang.rule.xpath.XPathRule\">\n <properties>\n <property name=\"xpath\">\n\t <value><![CDATA[\n PermissionSet[contains(description, 'No')]\n ]]></value>\n </property>\n </properties>\n </rule>\nAccording to xpath-checker, my xpath is hitting for my example. However, if I execute my ruleset, I don't get a result (and no error).
\nWhat am I doing wrong? Any help is highly appreciated and would make my day ;)
","upvoteCount":1,"answerCount":4,"acceptedAnswer":{"@type":"Answer","text":"FYI: without DomXPathRule the XPath expression looks like this:
PermissionSet[description/text[contains(@Text, 'No')]]\n-
|
Hi, sorry, if i'm just stupid, but i'm working on a simple thing the whole day, but don't get it... Assume, I have the following XML file And I want to write a rule that hits, if there is "No" in description. I have the following rule in my ruleset According to xpath-checker, my xpath is hitting for my example. However, if I execute my ruleset, I don't get a result (and no error). What am I doing wrong? Any help is highly appreciated and would make my day ;) |
Beta Was this translation helpful? Give feedback.
-
|
Hello, the simple answer is you have to use the class |
Beta Was this translation helpful? Give feedback.
-
|
FYI: without |
Beta Was this translation helpful? Give feedback.
-
|
I thought about the DomXPathRule also, but it shows the same result. Maybe something is not compatible in the xpath as well here... 🧐. However, the version from @adangel is working, so I'm fine with that. I still don't understand, why the xpath needs to look this way and didn't work the way i did and checked with xpather.com - but maybe I will after writing the whole rule set... If you can tell me with ease, i also wouldn't complain 😃 Many thanks to such a fast community! |
Beta Was this translation helpful? Give feedback.
-
|
If you are a bloody starter with PMD (like me) - you get the hint to use the DomXPathRule when writing your first rule for XML-files (at least I did before doing too much with the "normal" xpath. However, as I said, as I never got any results back in my case, i turned my back to the Dom-version. So maybe just working with the Dom needs some more clarification and examples ;) |
Beta Was this translation helpful? Give feedback.
FYI: without
DomXPathRulethe XPath expression looks like this: