Skip to end of metadata
Go to start of metadata

Description / Features

This plugin enables analysis of XML files within Sonar.

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)
It is compatible with the Issues Report plugin to run pre-commit local analysis.

Installation

  1. Install the XML plugin through the Update Center or download it into the SONAR_HOME/extensions/plugins directory
  2. Restart the Sonar server

Usage

Run a Sonar Analysis with the Sonar Runner (Recommended Way)

To launch a Sonar analysis of your XML project, use the Sonar Runner.

A sample project is available on github that can be browsed or downloaded: /projects/languages/xml/xml-sonar-runner.

Run a Sonar Analysis with the other Analyzers

Maven and Ant can also be used to launch analysis on XML projects.

Validating Files Against Specific Schemas

Files can be validated against specific schemas thanks to the XML Schema Validation 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. So, this rule has to be copied and configured as many times as you have pairs of files/schemas.

Notes:

  • 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 rule allows 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, this rule has to be copied and configured as many times as you have pairs of files/rule.

Metrics

See Metrics documentation page.

Change Log

Release 1.0 (not yet released) (15 issues)
Type Key Summary Priority
Improvement SONARPLUGINS-1764 XML: Rename default profile to "Sonar way" Major
Improvement SONARPLUGINS-1765 XML: If the XPath rule fails to analyse the document, it should *not* generate a violation Major
Improvement SONARPLUGINS-1763 Document the XPath Rule Major
Bug SONARPLUGINS-1760 Malformed input may cause infinite loop Major
Bug SONARPLUGINS-2559 Cannot load extra schemas Major
Improvement SONARPLUGINS-2595 XML comments are not syntax highlighted Major
Improvement SONARPLUGINS-2597 The type of the XPath rule 'expression' attribute should be TEXT Major
Bug SONARPLUGINS-2593 When a node name contains the '-' character only the first part of the node name is colorized Major
Improvement SONARPLUGINS-2596 Merge all Xerces rules into one rule Major
Improvement SONARPLUGINS-2594 Colorize the attribute keys and values with dedicated styles Major
Bug SONARPLUGINS-2624 Don't count blank lines as ncloc Major
Task SONARPLUGINS-2650 The deprecated properties 'sonar.xml.sourceDirectory' and 'sonar.xml.includeFileFilter' must be removed from the Settings>XML page Major
Improvement SONARPLUGINS-2646 Rename 'Xml' language to 'XML' Major
Improvement SONARPLUGINS-2641 Document the XML Schema Validation Major
Improvement SONARPLUGINS-2375 Upgrade to Sonar 3.0 API Minor

 

Release 0.2 (9 issues)
Type Key Summary Priority
Bug SONARPLUGINS-1723 Sources are no more imported by the XML Plugin since Sonar 2.9+ Major
Bug SONARPLUGINS-1742 Plugin not compatible with Java 5 Major
Bug SONARPLUGINS-1196 Code colorizing in sonar source view does not work Major
Improvement SONARPLUGINS-1186 XPath check should have configurable message Major
New Feature SONARPLUGINS-1152 Validate Indenting in XML documents Major
New Feature SONARPLUGINS-1153 Validate newlines in XML Documents Major
Bug SONARPLUGINS-1150 Escape messages when loading MessagesRepository Major
Improvement SONARPLUGINS-1146 Create friendly names for error messages Major
New Feature SONARPLUGINS-1145 Check for Illegal Tabs in XML documents Major

 

Release 0.1 (3 issues)
Type Key Summary Priority
New Feature SONARPLUGINS-852 XML Schema check for XML documents Major
New Feature SONARPLUGINS-851 XPath Check for XML documents Major
New Feature SONARPLUGINS-611 Add a check for Maven POM code convention Minor

Labels