XPATH custom rules

I’m trying to create an XPATH rule for xml files but when I run sonar-scanner it does not seem that the custom rule is evaluated.
I’ve created a simple XML fle and a simple XPATH and a quality gate and activated that custom rule with the quality gate.
The XPATH expression is the sample given:

And the XML file is containing that.

I’ve installed sonarqube 7.9.1 on postgreSQL and using sonar-scanner-

Is there a tutorial step by step which can help me?

What’s the content of the XML file?
What’s the name of the XML file?
Did you set the following parameters on the XPath rule you created?

  • filePattern
  • message

Do you see something special in the logs of the analysis?

Hi Pierre,

I am also facing same kind of issue, I am trying to validate if a file name weblogic.xml, If the file doesn’t have declared the attribute names as page-check-seconds then report violation.

filePattern: weblogic.xml
The XPath query = not(//jsp-descriptor/jsp-param/param-name[text()=‘page-check-seconds’])
Message : Page check seconds are not mentioned

File content:

<?xml version="1.0" encoding="UTF-8"?> keepgenerated true page-check-sec true

But I am not able to see any sonar violation , I an scanning file using sonar-scanner. I am using soanrqube 7.2.

PS: I am novice to SonarQube.

@aloksrivastava269 see the answer on the thread which you created: