Full documentation for SonarQube has moved to a new location: http://docs.sonarqube.org/display/SONAR

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 37 Next »

Description / Features

This plugin enables analysis of XML files within Sonar.

Some common use cases are:

  • Validation of XHTML files by using the XHTML schemas as provided by the W3C (strict, transitional, and others). Quickly validate the markup of a set of XHTML files. 
  • Validation of XML files for conformance to the provided XML schema.
  • Validation of rules in XML files (ex: validate the Maven pom files for conformance to coding standards)

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 Web projects.

Advanced Properties

 

Property

Description

sonar.xml.includeFileFilter

Additional filter for the files to be scanned

Validating Files Against Specific Schema

Files can be validated against a specific schema thanks to the XML Schema Check.

Within the same project some files can be validated against schema 'S1', others against schema 'S2' and so on. So, this rule has to be copied and configured as many times as you have pairs of files/schema.

 

Property

Description

filePattern

Files to be validated against the schema set through the schemas parameter.

schemas

Namespace of schema to use for validation.

It can either be set to:

  • a built-in schema (ex: xhtml1-strict)
  • or a URL (ex: TODO)
  • 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.

Built-in schemas:

Namespace or Short name

Doctype

Description

http://www.w3.org/2001/xml.xsd

 

XML

http://www.w3.org/1999/xhtml

 

XHTML1.0 Strict

xhtml1-strict

-//W3C//DTD XHTML 1.0 Strict//EN

XHTML1.0 Strict

xhtml1-transitional

-//W3C//DTD XHTML 1.0 Transitional//EN

XHTML1.0Ttransitional

xhtml1-frameset

-//W3C//DTD XHTML 1.0 Frameset//EN

XHTML1.0 Frameset

 

-//W3C//DTD XHTML 1.1 Strict//EN

XHTML1.1

http://java.sun.com/jsf/core

 

JSF core

http://java.sun.com/jsf/html

 

JSF HTML Basic

http://java.sun.com/jsf/facelets

 

JSF Facelets

http://maven.apache.org/POM/4.0.0

 

Maven Project Model

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 Check allows to define custom checks 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.

Property

Description

filePattern

Files to be checked against the XPath expression set through the xpathQuery parameter.

xpathQuery The XPath query
messageThe violation message

Change Log

Loading

Release 1.0 (not yet released) (15 issues)

 

Loading

Release 0.2 (9 issues)

 

Loading

Release 0.1 (3 issues)

  • No labels