<?xml version="1.0"?>
<xs:schema
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
  targetNamespace="http://pmd.sourceforge.net/ruleset/2.0.0"
  elementFormDefault="qualified">

  <xs:element name="ruleset">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="description" type="xs:string" minOccurs="1" maxOccurs="1" />
        <xs:element name="exclude-pattern" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="include-pattern" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
        <xs:element name="rule" type="rule" minOccurs="1" maxOccurs="unbounded" />
      </xs:sequence>
      <xs:attribute name="name" type="xs:string" use="required" />
    </xs:complexType>
  </xs:element>

  <xs:complexType name="rule">
    <xs:sequence>
      <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1" />
      <xs:element name="priority" type="xs:int" default="5" minOccurs="0" maxOccurs="1"/>
      <xs:element name="properties" type="properties" minOccurs="0" maxOccurs="1" />
      <xs:element name="exclude" type="exclude" minOccurs="0" maxOccurs="unbounded" />
      <xs:element name="example" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
    </xs:sequence>
    <xs:attribute name="language" type="xs:string" use="optional" />
    <xs:attribute name="minimumLanguageVersion" type="xs:string" use="optional" />
    <xs:attribute name="maximumLanguageVersion" type="xs:string" use="optional" />
    <xs:attribute name="name" type="xs:ID" use="optional" />
    <xs:attribute name="since" type="xs:string" use="optional" />
    <xs:attribute name="ref" type="xs:string" use="optional" />
    <xs:attribute name="message" type="xs:string" use="optional" />
    <xs:attribute name="externalInfoUrl" type="xs:string" use="optional" />
    <xs:attribute name="class" type="xs:NMTOKEN" use="optional" />
    <xs:attribute name="dfa" type="xs:boolean" use="optional" />  <!-- rule uses dataflow analysis -->
    <xs:attribute name="typeResolution" type="xs:boolean" default="false" use="optional" />
    <xs:attribute name="deprecated" type="xs:boolean" default="false" use="optional" />
  </xs:complexType>

  <xs:complexType name="properties">
    <xs:sequence>
      <xs:element name="property" type="property" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="property">
    <xs:sequence>
      <xs:element name="value" type="xs:string" minOccurs="0" maxOccurs="1" />
    </xs:sequence>
    <xs:attribute name="name" type="xs:NMTOKEN" use="required" />
    <xs:attribute name="value" type="xs:string" use="optional" />
    <xs:attribute name="description" type="xs:string" use="optional" />
    <xs:attribute name="type" type="xs:string" use="optional" />
    <xs:attribute name="delimiter" type="xs:string" use="optional" />
    <xs:attribute name="min" type="xs:string" use="optional" />
    <xs:attribute name="max" type="xs:string" use="optional" />
  </xs:complexType>

  <xs:complexType name="exclude">
    <xs:attribute name="name" type="xs:NMTOKEN" use="required" />
  </xs:complexType>

</xs:schema>
