<?xml version="1.0" encoding="UTF-8"?>
<!-- $Id$ -->

<xsd:schema
   xmlns:xsd="http://www.w3.org/2001/XMLSchema"
   xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
   xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
   jxb:extensionBindingPrefixes="xjc"
   jxb:version="1.0">

   <!-- copied from JAXB sample schema -->
   <xsd:annotation>
      <xsd:appinfo>

         <jxb:globalBindings
            fixedAttributeAsConstantProperty="true"
            collectionType="java.util.ArrayList"
            typesafeEnumBase="xsd:NCName"
            choiceContentProperty="true"
            typesafeEnumMemberName="generateError"
            enableFailFastCheck="false"
            generateIsSetMethod="true"
            underscoreBinding="asCharInWord">
            <xjc:serializable uid="106"/>
         </jxb:globalBindings>
         <jxb:schemaBindings>
            <jxb:package name="org.jcoderz.phoenix.findbugs.jaxb"/>
        <!--
            <jxb:nameXmlTransform>
               <jxb:elementName suffix="Element"/>
            </jxb:nameXmlTransform>
         -->
         </jxb:schemaBindings>
      </xsd:appinfo>
   </xsd:annotation>

  <xsd:simpleType name='Priority'>
      <xsd:annotation>
         <xsd:appinfo>
             <jxb:javaType
               name="org.jcoderz.phoenix.report.Severity"
               parseMethod="fromFindBugsPriority"
               printMethod="toFindBugsPriority"/>
          </xsd:appinfo>
      </xsd:annotation>
      <xsd:restriction base='xsd:int'>
         <xsd:enumeration value='1'/>
         <xsd:enumeration value='2'/>
         <xsd:enumeration value='3'/>
      </xsd:restriction>

   </xsd:simpleType>

 <xsd:element name='AuxClasspathEntry'>
  <xsd:complexType mixed='true'>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='BugCollection'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref='Project'/>
    <xsd:element ref='BugInstance' minOccurs='0' maxOccurs='unbounded'/>
    <xsd:element ref='BugCategory' minOccurs='0' maxOccurs='unbounded'/>
    <xsd:element ref='BugPattern' minOccurs='0' maxOccurs='unbounded'/>
    <xsd:element ref='BugCode' minOccurs='0' maxOccurs='unbounded'/>
    <xsd:element ref='Errors'/>
    <xsd:element ref='FindBugsSummary'/>
    <xsd:element ref='SummaryHTML' minOccurs='0'/>
    <xsd:element ref='ClassFeatures'/>
    <xsd:element ref='History'/>
   </xsd:sequence>
   <xsd:attribute name='version' use='optional' type='xsd:string'/>
   <xsd:attribute name='sequence' use='optional' type='xsd:long'/>
   <xsd:attribute name='timestamp' use='required' type='xsd:long'/>
   <xsd:attribute name='analysisTimestamp' use='required' type='xsd:long'/>
   <xsd:attribute name='release' use='optional' type='xsd:string'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='BugInstance'>
  <xsd:complexType>
   <xsd:sequence>
     <xsd:element ref='ShortMessage' minOccurs="0"/>
     <xsd:element ref='LongMessage' minOccurs="0"/>
      <xsd:choice maxOccurs="unbounded">
        <xsd:element ref='Class'/>
        <xsd:element ref='Field'/>
        <xsd:element ref='Method'/>
        <xsd:element ref='Property'/>
        <xsd:element ref='Type'/>
        <xsd:element ref='LocalVariable'/>
        <xsd:element ref='SourceLine'/>
        <xsd:element ref='Int'/>
        <xsd:element ref='String'/>
      </xsd:choice>
   </xsd:sequence>
   <xsd:attribute name='priority' use='required' type='Priority'/>
   <xsd:attribute name='type' type='xsd:string' use='required'/>
   <xsd:attribute name='abbrev' type='xsd:string' use='optional'/>
   <xsd:attribute name='category' type='xsd:string' use='optional'/>
   <xsd:attribute name='active' type='xsd:string' use='optional'/>
   <xsd:attribute name='uid' type='xsd:int'/>
   <xsd:attribute name='instanceHash' type='xsd:string'/>
   <xsd:attribute name='instanceOccurrenceNum' type='xsd:int'/>
   <xsd:attribute name='instanceOccurrenceMax' type='xsd:int'/>
   <xsd:attribute name="last" type="xsd:unsignedInt" use="optional" />
   <xsd:attribute name="removedByChange" type="xsd:boolean" use="optional" />
   <xsd:attribute name="first" type="xsd:unsignedInt" use="optional" />
   <xsd:attribute name="introducedByChange" type="xsd:boolean" use="optional" />
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='BugCategory'>
  <xsd:complexType>
   <xsd:sequence maxOccurs="unbounded">
      <xsd:choice>
        <xsd:element ref='Description'/>
      </xsd:choice>
   </xsd:sequence>
   <!-- TODO: category might be an enum type: CORRECTNESS, PERFORMANCE, I18N, MT_CORRECTNESS, MALICIOUS_CODE, STYLE -->
   <xsd:attribute name='category' use='required' type='xsd:string'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='BugPattern'>
  <xsd:complexType>
   <xsd:sequence maxOccurs="unbounded">
      <xsd:choice>
        <xsd:element ref='ShortDescription'/>
        <xsd:element ref='Details'/>
      </xsd:choice>
   </xsd:sequence>
   <xsd:attribute name='type' use='required' type='xsd:string'/>
   <!-- TODO: abbrev might be an enum type: FS, ... -->
   <xsd:attribute name='abbrev' use='required' type='xsd:string'/>
   <!-- TODO: category might be an enum type: CORRECTNESS, PERFORMANCE, I18N, MT_CORRECTNESS, MALICIOUS_CODE, STYLE -->
   <xsd:attribute name='category' use='required' type='xsd:string'/>
   <xsd:attribute name="cweid" type="xsd:positiveInteger" use="optional"/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='BugCode'>
  <xsd:complexType>
   <xsd:sequence maxOccurs="unbounded">
      <xsd:choice>
        <xsd:element ref='Description'/>
      </xsd:choice>
   </xsd:sequence>
   <!-- TODO: abbrev might be an enum type: FS, ... -->
   <xsd:attribute name='abbrev' use='required' type='xsd:string'/>
   <xsd:attribute name='cweid' use='optional' type='xsd:positiveInteger'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Class'>
  <xsd:complexType>
   <xsd:sequence>
        <xsd:element ref="SourceLine" />
        <xsd:element ref="Message" minOccurs="0" />
   </xsd:sequence>
   <xsd:attribute name='classname' type='xsd:string' use='required'/>
   <xsd:attribute name='primary' type='xsd:boolean' use='optional'/>
   <xsd:attribute name='role' use='optional' type="xsd:string"/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Property'>
  <xsd:complexType>
   <xsd:attribute name='name'  type='xsd:string' use='required'/>
   <xsd:attribute name='value' type="xsd:string" use='required'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='LocalVariable'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="Message" minOccurs="0" />
   </xsd:sequence>
   <xsd:attribute name='name'     type='xsd:string'   use='required'/>
   <xsd:attribute name='register' type="xsd:int"      use='optional'/>
   <xsd:attribute name='pc'       type="xsd:int"      use='optional'/>
   <xsd:attribute name='role'     type='xsd:string'   use='optional'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Int'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="Message" minOccurs="0" />
   </xsd:sequence>
   <xsd:attribute name='value' type='xsd:int' use='required'/>
   <xsd:attribute name='role' use='optional' type="xsd:string"/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Errors'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element name='Error' type="ErrorType"
                 minOccurs='0' maxOccurs='unbounded'/>
    <xsd:element name='AnalysisError' type="xsd:string"
                 minOccurs='0' maxOccurs='unbounded'/>
    <xsd:element name='MissingClass' type="xsd:string"
                 minOccurs='0' maxOccurs='unbounded'/>
   </xsd:sequence>
   <xsd:attribute name="errors" type="xsd:unsignedInt" use="optional"/>
   <xsd:attribute name="missingClasses" type="xsd:unsignedInt" use="optional"/>
  </xsd:complexType>
 </xsd:element>

 <xsd:complexType name="ErrorType">
   <xsd:sequence>
    <xsd:element name='ErrorMessage' type="xsd:string"/>
    <xsd:element name='Exception' type="xsd:string"/>
    <xsd:element name='StackTrace' type="xsd:string"
                 minOccurs='0' maxOccurs='unbounded'/>
   </xsd:sequence>
 </xsd:complexType>

 <xsd:element name='Field'>
  <xsd:complexType>
   <xsd:sequence>
        <xsd:element ref="SourceLine" />
        <xsd:element ref="Message" minOccurs="0" />
   </xsd:sequence>
   <xsd:attribute name='classname' type='xsd:string' use='required'/>
   <xsd:attribute name='isStatic' use='required'>
    <xsd:simpleType>
     <xsd:restriction base='xsd:string'>
      <xsd:enumeration value='false'/>
      <xsd:enumeration value='true'/>
     </xsd:restriction>
    </xsd:simpleType>
   </xsd:attribute>
   <xsd:attribute name='name' type='xsd:string' use='required'/>
   <xsd:attribute name='signature' type='xsd:string' use='required'/>
   <xsd:attribute name='role' use='optional' type="xsd:string"/>
   <xsd:attribute name='primary' type='xsd:boolean' use='optional'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Jar'>
  <xsd:complexType mixed='true'>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Method'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref='SourceLine' minOccurs="0"/>
    <xsd:element ref="Message" minOccurs="0" />
   </xsd:sequence>
   <xsd:attribute name='classname'  type='xsd:string' use='required'/>
   <xsd:attribute name='name'       type='xsd:string' use='required'/>
   <xsd:attribute name='signature'  type='xsd:string' use='required'/>
   <xsd:attribute name='role'       use='optional' type="xsd:string"/>
   <xsd:attribute name='isStatic'   use='optional' type="xsd:boolean"/>
   <xsd:attribute name='primary' type='xsd:boolean' use='optional'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Type'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref='SourceLine' minOccurs="0" />
    <xsd:element ref="Message" minOccurs="0" />
   </xsd:sequence>
   <xsd:attribute name='descriptor'  type='xsd:string' use='required'/>
   <xsd:attribute name='role' use='optional' type="xsd:string"/>
   <xsd:attribute name='typeParameters' use='optional' type='xsd:string'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Project'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref='Jar'/>
    <xsd:element ref='AuxClasspathEntry' maxOccurs='unbounded'/>
    <xsd:element name='SrcDir' type='xsd:string' maxOccurs='unbounded'/>
   </xsd:sequence>
   <xsd:attribute name='filename' type='xsd:string' use='optional'/>
   <xsd:attribute name="projectName" type="xsd:string" use="optional" />
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='SourceLine'>
  <xsd:complexType>
   <xsd:sequence>
     <xsd:element ref="Message" minOccurs="0" />
   </xsd:sequence>
   <xsd:attribute name='classname'     type='xsd:string' use='required'/>
   <xsd:attribute name='end'           type='xsd:int' use='optional'/>
   <xsd:attribute name='endBytecode'   type='xsd:int' use='optional'/>
   <xsd:attribute name='role'          type='xsd:string' use='optional'/>
   <xsd:attribute name='sourcefile'    type='xsd:string' use='optional'/>
   <xsd:attribute name="sourcepath"    type="xsd:string" use="optional" />
   <xsd:attribute name="relSourcepath"    type="xsd:string" use="optional" />
   <xsd:attribute name='start'         type='xsd:int' use='optional'/>
   <xsd:attribute name='startBytecode' type='xsd:int' use='optional'/>
   <xsd:attribute name="synthetic"     type="xsd:boolean" use="optional" />
   <xsd:attribute name='opcodes'       type='xsd:string' use='optional'/>
   <xsd:attribute name='primary'       type='xsd:boolean' use='optional'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='SummaryHTML'>
  <xsd:complexType mixed='true'>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='ClassFeatures'>
  <xsd:complexType mixed='true'>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='History'>
  <xsd:complexType mixed='true'>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='FindBugsSummary'>
  <xsd:complexType>
   <xsd:sequence>
     <xsd:element name="FileStats" maxOccurs="unbounded">
       <xsd:complexType>
         <xsd:attribute name="path" type="xsd:string" use="required" />
         <xsd:attribute name="bugCount" type="xsd:unsignedInt" use="required" />
         <xsd:attribute name="size" type="xsd:unsignedInt" use="optional" />
         <xsd:attribute name="bugHash" type="xsd:string" use="optional" />
       </xsd:complexType>
      </xsd:element>
      <xsd:element ref='PackageStats' maxOccurs='unbounded'/>
      <xsd:element ref="FindBugsProfile" minOccurs="0" maxOccurs="1"/>
   </xsd:sequence>
   <xsd:attribute name='timestamp' use='required' type='xsd:string'/>
   <xsd:attribute name='total_classes' use='required' type='xsd:int'/>
   <xsd:attribute name="referenced_classes" type="xsd:unsignedInt" use="optional"/>
   <xsd:attribute name='total_bugs' use='required' type='xsd:int'/>
   <xsd:attribute name='total_size' use='required' type='xsd:int'/>
   <xsd:attribute name='num_packages' use='required' type='xsd:int'/>
   <xsd:attribute name="vm_version" type="xsd:string" use="optional"/>
   <xsd:attribute name="cpu_seconds" type="xsd:float" use="optional" />
   <xsd:attribute name="clock_seconds" type="xsd:float" use="optional" />
   <xsd:attribute name="peak_mbytes" type="xsd:float" use="optional" />
   <xsd:attribute name="alloc_mbytes" type="xsd:float" use="optional" />
   <xsd:attribute name="gc_seconds" type="xsd:float" use="optional" />
   <xsd:attribute name='priority_1' use='optional' type='xsd:int'/>
   <xsd:attribute name='priority_2' use='optional' type='xsd:int'/>
   <xsd:attribute name='priority_3' use='optional' type='xsd:int'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='PackageStats'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref='ClassStats' maxOccurs='unbounded'/>
   </xsd:sequence>
   <xsd:attribute name='package' use='required' type='xsd:string'/>
   <xsd:attribute name='total_bugs' use='required' type='xsd:int'/>
   <xsd:attribute name='total_types' use='required' type='xsd:int'/>
   <xsd:attribute name='total_size' use='required' type='xsd:int'/>
   <xsd:attribute name='priority_1' use='optional' type='xsd:int'/>
   <xsd:attribute name='priority_2' use='optional' type='xsd:int'/>
   <xsd:attribute name='priority_3' use='optional' type='xsd:int'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='FindBugsProfile'>
  <xsd:complexType>
   <xsd:sequence>
    <xsd:element ref="ClassProfile" minOccurs="0" maxOccurs="unbounded"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='ClassProfile'>
  <xsd:complexType>
   <xsd:attribute name='name' use='required' type='xsd:string'/>
   <xsd:attribute name="totalMilliseconds" type="xsd:unsignedInt" use="required"/>
   <xsd:attribute name="invocations" type="xsd:unsignedInt" use="required"/>
   <xsd:attribute name="avgMicrosecondsPerInvocation" type="xsd:unsignedInt" use="required"/>
   <xsd:attribute name="maxMicrosecondsPerInvocation" type="xsd:unsignedInt" use="optional"/>
   <xsd:attribute name="standardDeviationMircosecondsPerInvocation" 
       type="xsd:unsignedInt" use="optional"/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='ClassStats'>
  <xsd:complexType>
   <xsd:attribute name='class' use='required' type='xsd:string'>
       <xsd:annotation>
            <xsd:appinfo>
               <jxb:property name="clazz"/>
            </xsd:appinfo>
         </xsd:annotation>
   </xsd:attribute>
   <xsd:attribute name='interface' use='required' type='xsd:string'/>
   <xsd:attribute name='sourceFile' use='optional' type='xsd:string'/>
   <xsd:attribute name='size' use='required' type='xsd:int'/>
   <xsd:attribute name='bugs' use='required' type='xsd:int'/>
   <xsd:attribute name='priority_1' use='optional' type='xsd:int'/>
   <xsd:attribute name='priority_2' use='optional' type='xsd:int'/>
   <xsd:attribute name='priority_3' use='optional' type='xsd:int'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='String'>
  <xsd:complexType>
   <xsd:sequence>
      <xsd:element name='Message' type='xsd:string' minOccurs="0"/>
   </xsd:sequence>
   <xsd:attribute name='value'     type='xsd:string' use='required'/>
   <xsd:attribute name='role'     type='xsd:string' use='optional'/>
  </xsd:complexType>
 </xsd:element>

 <xsd:element name='Details' type='xsd:string'/>
 <xsd:element name='ShortDescription' type='xsd:string'/>
 <xsd:element name='Description' type='xsd:string'/>
 <xsd:element name='Message' type='xsd:string'/>
 <xsd:element name='ShortMessage' type='xsd:string'/>
 <xsd:element name='LongMessage' type='xsd:string'/>
</xsd:schema>

