This plugin enables analysis of XML files within SonarSonarQube.
Some common use cases are:
- Validation of XHTML files against schemas provided by the W3C (strict, transitional, and others)
- Validation of XML files against a provided XML schema
- Validation of rules in XML files (ex: validate the Maven pom files against coding standards)
- Install the XML plugin through the Update Center or download it into the SONAR_HOME/extensions/plugins directory
- Restart the Sonar server
Run a Sonar Analysis with the Sonar Runner (Recommended Way)
Run an Analysis with the SonarQube Runner (Recommended Method)
To run an analysis of your XML project, use the Sonar SonarQube Runner.
an Analysis with the other Analyzers
Files can be validated against specific schemas thanks to the XML Schema CheckValidation rule.
Within the same project some files can be validated against schema 'S1', others against schema 'S2', others against schemas 'S3' and 'S4', and so on. SoTherefore, this rule has to must be copied and configured as many times as you have pairs of files/schema.
Whitespace-separated list of schemas to use for validation.
It can either be set to:
- the namespace or short name of a built-in schema (ex: xhtml1-strict or http://www.w3.org/1999/xhtml)
- or the URL to a schema (ex: http://www.springframework.org/schema/beans/spring-beans-3.2.xsd)
- or a relative path to a schema on the filesystem (ex: schemas/xsd/mycustomschema.xsd)
Default value: autodetect. In this case, the parser will try to load the schema based on the doctype or the namespace declaration in the document.
Namespace or Short name
-//W3C//DTD XHTML 1.0 Strict//EN
-//W3C//DTD XHTML 1.0 Transitional//EN
-//W3C//DTD XHTML 1.0 Frameset//EN
-//W3C//DTD XHTML 1.1 Strict//EN
JSF HTML Basic
Maven Project Model
- Schema validation is performed by the Xerces parser using XML schemas (XSDs).
- For validation of XHTML files it is recommended to use autodetect, xhtml1-transitional or xhtml1-strict.
Custom Checks Using XPath Expressions
The XPath Check rule allows rule allows you to define custom rules on XML documents using XPath expressions.
Within the same project some files can be checked against XPath rules 'R1', 'R2', etc., others against rules 'R6', 'R7', etc. and so on. So Therefor, this rule has to be copied and configured as many times as you have pairs of files/rule.
This rule allows to define some homemade XML rules with help of an XPath expression.
Violations are created depending on the return value of the XPath expression. If the XPath expression returns:
Here is an example of an XPath expression to log a violation on each 'td' tag using the 'nowrap' deprecated attribute: //td[@nowrap]
Files to be checked against the XPath expression set through the expression parameter.
|expression||The XPath query.|
|message||The violation message.|