Hi Gordon,
Thanks for the patch.
It's probably best to not allow the configurability of this, and simply not log a violation if the document is invalid (too many small configuration options will complicate the usage).
Clearly, there must be another rule, which will log a single violation per invalid document.
This is already the case for other languages plugins such as Java, JavaScript, etc... where you can enable the "Parsing error" rule to track files which failed to parse.
The XML plugin has been migrated to GitHub, https://github.com/SonarCommunity/sonar-xml
It would be nice if you could fork it, and make a pull request there, to change this behaviour.
Also please do not integrate other changes in your patch, such as adding a requirement on Sonar 3.3 or Java 6.
Only keep the part that relates to this ticket.
Many thanks!
Eric will get back to you about the unit test not being run on the CI server.
I concur that I don't want to see XPATH rule violations appear due to the target XML being invalid. I'm attaching a patch file that makes this behavior configurable so that you by default get the original behavior or you can check a box when you create your XPATH rule to cause violations not to be generated in this situation and these cases will then only be logged during the analysis process.
If you want to simplify this solution by removing the configurability and just providing the new "no violations in this situation" behavior that'd be ok with me also.
I'll attach the patch file in a moment.