SonarXml custom rule not working

I have created one templated rule for XML language to check if some tag values satisfy the naming convention and through code smell if it doesn’t satisfy. I followed: , to create the rule. But seems like this rule is not getting executed.

The newly created templated rule looks like:

Check if NJR project component name starts with get


filePattern The files to be validated using Ant-style matching patterns
expression The XPath query
Default Value //ELEMENT[./S_TAG/NAME/@tokenValue='types1:Name' and ./CONTENT[starts-with(@tokenValue, 'get')] ]
message The issue message
Default Value This xml doesn’t start with get

My XML structure:

<aetgt:getResponse xmlns:aetgt=""

xpath query that i am using:

//ELEMENT[./S_TAG/NAME/@tokenValue='types1:Name' and ./CONTENT[starts-with(@tokenValue, 'get')] ]

In sslr-xml-toolkit i am able to select the element in AST with the above query. But in sonarqube this plugin doesn’t seems to work.

The documentation page you mention doesn’t list an SSLR toolkit for XML.
It’s easier than that: you can use an ordinary XPath expression.
In your case, you should try something like:

//*[local-name()='Name'][starts-with(., 'get')]