<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="test-data">
        <xs:complexType>
            <xs:annotation>
             <xs:documentation>You can mix these elements freely</xs:documentation>
            </xs:annotation>
            <xs:sequence minOccurs="0" maxOccurs="unbounded">
             <xs:choice>
                <xs:element ref="test-code"/>
                <xs:element name="code-fragment" type="code-fragmentType"/>
             </xs:choice>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    
    <xs:element name="test-code">
        <xs:complexType>
            <xs:sequence>
                <xs:element name="description" type="xs:string"/>
                <xs:element name="rule-property" type="rule-propertyType" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="expected-problems" type="xs:nonNegativeInteger"/>
                <xs:choice>
                    <xs:element name="code" type="xs:string"/>
                    <xs:element name="code-ref" type="code-refType"/>
                </xs:choice>
                <xs:element ref="source-type" minOccurs="0"/>
            </xs:sequence>
            <!-- Reinitialize the rule for this test. For rules with caching (ie. XPath 
            rules with properties), only works if the rule was created with findRule -->
            <xs:attribute name="reinitializeRule" type="xs:boolean" use="optional"/>
            <!-- is the test a regression test, i.e. was it working in previous releases.
            this defaults to true so that the attribute only needs to be set for failing tests -->
            <xs:attribute name="regressionTest" type="xs:boolean" use="optional"/>
        </xs:complexType>
    </xs:element>
    
    <xs:complexType name="rule-propertyType">
	   <xs:annotation>
        <xs:documentation>The property set on the rule before the test</xs:documentation>
       </xs:annotation>
	   <xs:simpleContent>
	       <xs:extension base="xs:string">
	           <xs:attribute name="name" type="xs:string" use="required"/>
	       </xs:extension>
	   </xs:simpleContent>
    </xs:complexType>
    
    <xs:complexType name="code-fragmentType">
       <xs:annotation>
        <xs:documentation>Code fragment to be used in multiple test-codes</xs:documentation>
       </xs:annotation>
       <xs:simpleContent>
           <xs:extension base="xs:string">
               <xs:attribute name="id" type="xs:string" use="required"/>
           </xs:extension>
       </xs:simpleContent>
    </xs:complexType>
    
    <xs:complexType name="code-refType">
        <xs:annotation>
         <xs:documentation>Reference to a code-fragment, ids should match</xs:documentation>
        </xs:annotation>
        <xs:attribute name="id" type="xs:string" use="required"/>
    </xs:complexType>
    
    <xs:element name="source-type">
      <xs:simpleType>
        <xs:annotation>
          <xs:documentation>Primary definition in LanguageVersion.java</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:string">
          <xs:enumeration value="java 1.3"/>
          <xs:enumeration value="java 1.4"/>
          <xs:enumeration value="java 1.5"/> <!-- default -->
          <xs:enumeration value="java 1.6"/>
          <xs:enumeration value="JSP"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:element>
</xs:schema>
