Cobertura 04

Cobertura XML code coverage report, as Cobertura’s DTD coverage-04.dtd defines it, translated to XML Schema.

Cobertura publishes no XML Schema, only DTDs; coverage-04.dtd is the latest. The translation keeps the DTD’s elements, attributes, their order and which are required, and allows no other attribute. Where the DTD’s CDATA holds a number, the attribute has a numeric type: a rate in range 0..1, a count, a complexity.

A report a tool writes may not follow the DTD - coverage.py adds the attribute missing-branches to a line -, so a report is read with the lenient Any-Cobertura.xsd, or with the strict schema of its dialect, e.g. CoveragePy-Cobertura.xsd.

A report Document.Write writes is valid according to it.

Download

Cobertura-04.xsd (5.3 kiB)

Validate a report

xmllint --schema Cobertura-04.xsd --noout coverage.xml

Source

  1<?xml version="1.0" encoding="UTF-8"?>
  2<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  3	<xs:annotation>
  4		<xs:documentation>
  5			Cobertura XML code coverage report: a translation of Cobertura's DTD 'coverage-04.dtd' to XML Schema.
  6
  7			Elements, attributes, their order and which are required follow the DTD; no other attribute is allowed. Where the
  8			DTD's CDATA holds a number, the attribute has a numeric type: a rate in range 0..1, a count, a complexity.
  9			Cobertura publishes no XML Schema, only DTDs; 'Any-Cobertura.xsd' reads the format leniently, as tools write it.
 10		</xs:documentation>
 11	</xs:annotation>
 12
 13	<xs:simpleType name="Rate">
 14		<xs:restriction base="xs:decimal">
 15			<xs:minInclusive value="0"/>
 16			<xs:maxInclusive value="1"/>
 17		</xs:restriction>
 18	</xs:simpleType>
 19
 20	<xs:simpleType name="ConditionCoverage">
 21		<xs:annotation>
 22			<xs:documentation>Percentage and count of taken branches, e.g. '50% (1/2)'.</xs:documentation>
 23		</xs:annotation>
 24		<xs:restriction base="xs:string">
 25			<xs:pattern value="\d+(\.\d+)?%( \(\d+/\d+\))?"/>
 26		</xs:restriction>
 27	</xs:simpleType>
 28
 29	<xs:element name="coverage">
 30		<xs:complexType>
 31			<xs:sequence>
 32				<xs:element name="sources" minOccurs="0">
 33					<xs:complexType>
 34						<xs:sequence>
 35							<xs:element name="source" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
 36						</xs:sequence>
 37					</xs:complexType>
 38				</xs:element>
 39				<xs:element name="packages">
 40					<xs:complexType>
 41						<xs:sequence>
 42							<xs:element ref="package" minOccurs="0" maxOccurs="unbounded"/>
 43						</xs:sequence>
 44					</xs:complexType>
 45				</xs:element>
 46			</xs:sequence>
 47			<xs:attribute name="line-rate"        type="Rate"                  use="required"/>
 48			<xs:attribute name="branch-rate"      type="Rate"                  use="required"/>
 49			<xs:attribute name="lines-covered"    type="xs:nonNegativeInteger" use="required"/>
 50			<xs:attribute name="lines-valid"      type="xs:nonNegativeInteger" use="required"/>
 51			<xs:attribute name="branches-covered" type="xs:nonNegativeInteger" use="required"/>
 52			<xs:attribute name="branches-valid"   type="xs:nonNegativeInteger" use="required"/>
 53			<xs:attribute name="complexity"       type="xs:decimal"            use="required"/>
 54			<xs:attribute name="version"          type="xs:string"             use="required"/>
 55			<xs:attribute name="timestamp"        type="xs:string"             use="required"/>
 56		</xs:complexType>
 57	</xs:element>
 58
 59	<xs:element name="package">
 60		<xs:complexType>
 61			<xs:sequence>
 62				<xs:element name="classes">
 63					<xs:complexType>
 64						<xs:sequence>
 65							<xs:element ref="class" minOccurs="0" maxOccurs="unbounded"/>
 66						</xs:sequence>
 67					</xs:complexType>
 68				</xs:element>
 69			</xs:sequence>
 70			<xs:attribute name="name"        type="xs:string"  use="required"/>
 71			<xs:attribute name="line-rate"   type="Rate"       use="required"/>
 72			<xs:attribute name="branch-rate" type="Rate"       use="required"/>
 73			<xs:attribute name="complexity"  type="xs:decimal" use="required"/>
 74		</xs:complexType>
 75	</xs:element>
 76
 77	<xs:element name="class">
 78		<xs:complexType>
 79			<xs:sequence>
 80				<xs:element name="methods">
 81					<xs:complexType>
 82						<xs:sequence>
 83							<xs:element ref="method" minOccurs="0" maxOccurs="unbounded"/>
 84						</xs:sequence>
 85					</xs:complexType>
 86				</xs:element>
 87				<xs:element ref="lines"/>
 88			</xs:sequence>
 89			<xs:attribute name="name"        type="xs:string"  use="required"/>
 90			<xs:attribute name="filename"    type="xs:string"  use="required"/>
 91			<xs:attribute name="line-rate"   type="Rate"       use="required"/>
 92			<xs:attribute name="branch-rate" type="Rate"       use="required"/>
 93			<xs:attribute name="complexity"  type="xs:decimal" use="required"/>
 94		</xs:complexType>
 95	</xs:element>
 96
 97	<xs:element name="method">
 98		<xs:complexType>
 99			<xs:sequence>
100				<xs:element ref="lines"/>
101			</xs:sequence>
102			<xs:attribute name="name"        type="xs:string" use="required"/>
103			<xs:attribute name="signature"   type="xs:string" use="required"/>
104			<xs:attribute name="line-rate"   type="Rate"      use="required"/>
105			<xs:attribute name="branch-rate" type="Rate"      use="required"/>
106		</xs:complexType>
107	</xs:element>
108
109	<xs:element name="lines">
110		<xs:complexType>
111			<xs:sequence>
112				<xs:element ref="line" minOccurs="0" maxOccurs="unbounded"/>
113			</xs:sequence>
114		</xs:complexType>
115	</xs:element>
116
117	<xs:element name="line">
118		<xs:complexType>
119			<xs:sequence>
120				<xs:element name="conditions" minOccurs="0" maxOccurs="unbounded">
121					<xs:complexType>
122						<xs:sequence>
123							<xs:element name="condition" minOccurs="0" maxOccurs="unbounded">
124								<xs:complexType>
125									<xs:attribute name="number"   type="xs:nonNegativeInteger" use="required"/>
126									<xs:attribute name="type"     type="xs:string"             use="required"/>
127									<xs:attribute name="coverage" type="xs:string"             use="required"/>
128								</xs:complexType>
129							</xs:element>
130						</xs:sequence>
131					</xs:complexType>
132				</xs:element>
133			</xs:sequence>
134			<xs:attribute name="number"             type="xs:positiveInteger"    use="required"/>
135			<xs:attribute name="hits"               type="xs:nonNegativeInteger" use="required"/>
136			<xs:attribute name="branch"             type="xs:boolean"            default="false"/>
137			<xs:attribute name="condition-coverage" type="ConditionCoverage"     default="100%"/>
138		</xs:complexType>
139	</xs:element>
140</xs:schema>