PL/SQL custom rule : sslr generated xml malformed

Sonarqube Version : Developer EditionVersion 8.2 (build 32929)
PL/SQL : 3.4.1 (build 2576)

  • what are you trying to achieve
    Write custom rule for .xdm extension file for PL/SQL language using xpath query.

  • what have you tried so far to achieve this

Using the SSLR toolkit the code has been parsed and using xpath query we can point to node in AST(abstract syntax tree) . But when we use the generated xml to validate the xpath query in any online xpath tester we are getting the following error.

Unable to perform XPath operation. The value of attribute “tokenValue” associated with an element type “COMPILATION_UNIT” must not contain the ‘<’ character. (766 Bytes)

The ask here is to check in the sample .xdm file attached, the value of property name “generate_output_format” is “CSV” or not.

As your .xdm files use an XML syntax, you should set up an XPath rule for XML, not for PL/SQL.

Hi @pynicolas
Thanks for the quick response. Yeah we did try xpath rule created for xdm file in sonarqube somehow it is able to scan and report any code smells on .xdm files, But when we tried same in SSLR toolkit

SLR toolkit generated 2 things, AST and XML. We could point a node in AST but if we try to use the generated XML to validate the xpath query we’re getting an error saying its a malformed xml.

So I am little curious on how does that worked on Sonarqube and What we doing different in SSLR toolkit.

Sorry, I don’t understand what you’re trying to do.
I have the feeling that you’re confused by the fact that you have XML files which are related to Oracle but are not PL/SQL.

When we used xdm file SSLR toolkit it generate AST of that file and we are able navigate to node inside that AST, But it also generate an XML file based on this .xdm file when we try to run our xpath query on that file it fails and throws an error saying that its an invalid xml file.

  • Same xpath query we uploaded on sonarqube applied this on project(repo) where it has .xdm file it scans that file and our xpath query gets applied and it returns the expected results.

Sorry, I still don’t get it.
Which xdm file? Can you show the content?
Which SSLR toolkit? What’s the file name of the SSLR toolkit?
Which XPath query?
Can you share a screenshot of the error you got?