<?xml version="1.0"?>

<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>

 <xs:element name='MESHLAB_FILTER_INTERFACE'>
  <xs:complexType>
   <xs:sequence>
    <xs:element ref='PLUGIN'/>
   </xs:sequence>
   <xs:attribute name='mfiVersion' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>

 <xs:element name='PLUGIN'>
  <xs:complexType>
   <xs:sequence>
    <xs:element ref='FILTER' maxOccurs='unbounded'/>
   </xs:sequence>
   <xs:attribute name='pluginName' type='xs:string' use='required'/>
   <xs:attribute name='pluginAuthor' type='xs:string' use='required'/>
   <xs:attribute name='pluginEmail' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>

 <xs:element name='FILTER' type='filterType'>
	<xs:unique name="paramNameKey">
      <xs:selector xpath="*/PARAM"/>
      <xs:field xpath="parName"/>
    </xs:unique>
  </xs:element>
  
  <xs:complexType name='filterType'>
   <xs:sequence>
    <xs:element ref='FILTER_HELP'/>
	<xs:element ref='FILTER_JSCODE' minOccurs='0' maxOccurs='1'/>
    <xs:element ref='PARAM' minOccurs='0' maxOccurs='unbounded'/>
   </xs:sequence>
   <xs:attribute name='filterName' type='xs:string' use='required'/>
   <xs:attribute name='filterFunction' type='xs:string' use='required'/>
   <xs:attribute name='filterClass' type='xs:string' use='required'/>
   <xs:attribute name='filterPre' type='xs:string' use='required'/>
   <xs:attribute name='filterPost' type='xs:string' use='required'/>
   <xs:attribute name='filterArity' type='ArityType' use='required'/>
   <xs:attribute name='filterRasterArity' type='ArityRasterType' use='required'/>
   <xs:attribute name='filterIsInterruptible' type='xs:string' use='required'/>
  </xs:complexType>

 <xs:element name='FILTER_HELP'>
  <xs:complexType mixed='true'>
  </xs:complexType>
 </xs:element>
 
  <xs:element name='FILTER_JSCODE'>
  <xs:complexType mixed='true'>
  </xs:complexType>
 </xs:element>
 
 <xs:element name='PARAM'>
  <xs:complexType>
   <xs:sequence>
    <xs:element ref='PARAM_HELP'/>
    <xs:choice>
     <xs:element ref='CHECKBOX_GUI'/>
     <xs:element ref='ABSPERC_GUI'/>
	 <xs:element ref='EDIT_GUI'/>
	 <xs:element ref='VEC3_GUI'/>
	 <xs:element ref='COLOR_GUI'/>
	 <xs:element ref='SLIDER_GUI'/>
	 <xs:element ref='ENUM_GUI'/>
	 <xs:element ref='MESH_GUI'/>
	 <xs:element ref='SHOT_GUI'/>
    </xs:choice>
   </xs:sequence>
   <xs:attribute name='parType' use='required'>
    <xs:simpleType>
     <xs:restriction base='xs:string'>
      <xs:pattern value='Boolean'/>
	  <xs:pattern value='Int'/>
      <xs:pattern value='Real'/>
	  <xs:pattern value='Vec3'/>
	  <xs:pattern value='Color'/>
	  <xs:pattern value='Mesh'/>
	  <xs:pattern value='CameraShot'/>
	  <xs:pattern value='Enum \{(\s*\S+(\s*\S*)*\s*\:\s*\d+\s*(\|)?)+\}'/>
     </xs:restriction>
    </xs:simpleType>
   </xs:attribute>
   <xs:attribute name='parName' type='xs:string' use='required'/>
   <xs:attribute name='parDefault' type='xs:string' use='required'/>
   <xs:attribute name='parIsImportant' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>

 <xs:element name='PARAM_HELP'>
  <xs:complexType mixed='true'>
  </xs:complexType>
 </xs:element>
 
 <xs:element name='CHECKBOX_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
 <xs:element name='EDIT_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
  <xs:element name='VEC3_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
 <xs:element name='ABSPERC_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
   <xs:attribute name='guiMin' type='xs:string' use='required'/>
   <xs:attribute name='guiMax' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
 <xs:element name='COLOR_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
  <xs:element name='SLIDER_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
   <xs:attribute name='guiMin' type='xs:string' use='required'/>
   <xs:attribute name='guiMax' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
 <xs:element name='ENUM_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
  <xs:element name='MESH_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
 <xs:element name='SHOT_GUI'>
  <xs:complexType>
   <xs:attribute name='guiLabel' type='xs:string' use='required'/>
  </xs:complexType>
 </xs:element>
 
 <xs:simpleType name="ArityType">
  <xs:restriction base="xs:string">
    <xs:enumeration value="SingleMesh"/>
    <xs:enumeration value="Fixed"/>
    <xs:enumeration value="Variable"/>
	<xs:enumeration value="FunctionDefined"/>
  </xs:restriction>
 </xs:simpleType>

 <xs:simpleType name="ArityRasterType">
  <xs:restriction base="xs:string">
	<xs:enumeration value="NoRaster"/>
    <xs:enumeration value="SingleRaster"/>
    <xs:enumeration value="Fixed"/>
    <xs:enumeration value="Variable"/>
	<xs:enumeration value="FunctionDefined"/>
  </xs:restriction>
 </xs:simpleType>
</xs:schema>

