How to define new Rat reports

All Rat reports are XSLT stylesheets that transform the XML output. The schema for the XML output can be found in the core resources rat-report.xsd file.

There are three internal reports in the same directory that can also be used as examples:

The Report XML

The apache-rat sub-module has an example of the Rat report XML file.

rat-report Element

The XML document starts with a rat-report element that has a timestamp attribute that contains the date and time the Rat report was created. The rat-report only contains resource elements.

resource Element

There is one resource element for every file that was processed. The resource may contain license and sample child elements. It has two attributes:

  • name: The name of the file.
  • type: The document type. This is one of the Document.Type enum values. The value is always in lower case. For a complete list see the Document.java file for a complete list of document types.

license Element

The license element is only found as a child of a resource element and may have a notes child element. The license element has four elements:

  • approval: Specifies whether the license is approved. Values are restricted to 'true' and 'false'.
  • family: The license family code. This is always 5 characters long and may have spaces at the end.
  • id: The license id. This is often the same as the license family code with trailing spaces removed, but may be other values. It is guaranteed to be unique within licenses.
  • name: The name of the license. This is the human-readable name that was provided when the license was defined.

sample Element

The sample element contains a CDATA block comprising the text that was processed when the resource was processed.

notes Element

The notes element contains a CDATA block comprising the text of any notes about the license that were provided when the license was defined.

How to use the report

Once an XSLT stylesheet has been developed it can be tested by running Rat and providing the full path to the XSLT stylesheet as the stylesheet argument for the client being used. See Running Rat from the Command line, Maven, or Ant for details.