<?xml version="1.0"?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
 
 <xs:element name="LLBLGenProjectGUIDefinition">
  <xs:complexType>
   <xs:sequence>
    <xs:element ref="EntityModel"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>

 <xs:element name="EntityModel">
  <xs:complexType>
   <xs:sequence>
    <xs:sequence minOccurs="0" maxOccurs="1">
	    <xs:element ref="SecurityFilters"/>
    </xs:sequence>
    <xs:sequence minOccurs="0" maxOccurs="1">
	    <xs:element ref="EntityDefinitions"/>
    </xs:sequence>
   </xs:sequence>
  </xs:complexType>
 </xs:element>

<!-- ******************************
	 BEGIN SecurityFilters Elements 
	 ****************************** -->

 <xs:element name="SecurityFilters">
  <xs:complexType>
    <xs:sequence minOccurs='0' maxOccurs="unbounded">
     <xs:element ref="EntityFilter"/>
    </xs:sequence>
  </xs:complexType>
 </xs:element>

 <xs:element name="EntityFilter">
  <xs:complexType>
   <xs:sequence minOccurs='0' maxOccurs="unbounded">
    <xs:element ref="Role"/>
   </xs:sequence>
   <xs:attribute name="Entity" type="xs:Name" use="required"/>
  </xs:complexType>
 </xs:element>

 <xs:element name='Role'>
  <xs:complexType>
   <xs:sequence>
    <xs:sequence minOccurs='0' maxOccurs='unbounded'>
     <xs:element ref='RoleFieldMap'/>
    </xs:sequence>
    <xs:sequence minOccurs='0' maxOccurs='1'>
     <xs:element ref='RoleHide'/>
    </xs:sequence>
   </xs:sequence>
   <xs:attribute name='Name' type='xs:Name' use='required'/>
  </xs:complexType>
 </xs:element>

 <xs:element name="RoleFieldMap">
  <xs:complexType>
   <xs:attribute name="EntityField" type="xs:Name" use="required"/>
   <xs:attribute name="ProfileField" type="xs:Name" use="required"/>
   <xs:attribute name="Relation" type="xs:string" />
   <xs:attribute name="CompareSet" type="xs:string" />
  </xs:complexType>
 </xs:element>

 <xs:element name='RoleHide'>
  <xs:complexType>
   <xs:sequence>
    <xs:sequence minOccurs='0' maxOccurs='unbounded'>
     <xs:element ref='HideField'/>
    </xs:sequence>
    <xs:sequence minOccurs='0' maxOccurs='unbounded'>
     <xs:element ref='HideAction'/>
    </xs:sequence>
    <xs:sequence minOccurs='0' maxOccurs='unbounded'>
     <xs:element ref='HideCustomAction'/>
    </xs:sequence>
   </xs:sequence>
  </xs:complexType>
 </xs:element>

 <xs:element name="HideField">
  <xs:complexType>
   <xs:attribute name="Name" type="xs:Name" use="required"/>
  </xs:complexType>
 </xs:element>
 
 <xs:element name="HideAction">
  <xs:complexType>
   <xs:attribute name="Name" type="HideActionType" use="required"/>
  </xs:complexType>
 </xs:element>

 <xs:simpleType name="HideActionType">
  <xs:restriction base="xs:Name">
    <xs:enumeration value="All"/>
    <xs:enumeration value="Add"/>
    <xs:enumeration value="List"/>
    <xs:enumeration value="Excel"/>
    <xs:enumeration value="Search"/>
    <xs:enumeration value="Report"/>
    <xs:enumeration value="View"/>
    <xs:enumeration value="Edit"/>
    <xs:enumeration value="Delete"/>
  </xs:restriction>
</xs:simpleType>

 <xs:element name="HideCustomAction">
  <xs:complexType>
   <xs:attribute name="Name" type="xs:Name" use="required"/>
  </xs:complexType>
 </xs:element>

<!-- ********************************
	 BEGIN EntityDefinitions Elements 
	 ******************************** -->

 <xs:element name="EntityDefinitions">
  <xs:complexType>
   <xs:sequence maxOccurs="unbounded">
    <xs:element ref="EntityDefinition"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>

 <xs:element name="EntityDefinition">
  <xs:complexType>
   <xs:all>
     <xs:element minOccurs="0" ref="CustomActions" />
     <xs:element minOccurs="0" ref="Fields" />
     <xs:element minOccurs="0" ref="CalculatedFields" />
     <xs:element minOccurs="0" ref="SearchRelatedFields" />
     <xs:element minOccurs="0" ref="StateField" />
   </xs:all>
   <xs:attribute name="Name" type="xs:Name" use="required"/>
  </xs:complexType>
 </xs:element>

 <xs:element name="CustomActions">
  <xs:complexType>
   <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="CustomAction"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:element name="Fields">
  <xs:complexType>
   <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="Field"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:element name="CalculatedFields">
  <xs:complexType>
   <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="CalculatedField"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:element name="SearchRelatedFields">
  <xs:complexType>
   <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="SearchRelatedField"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>

 <xs:element name="CustomAction">
  <xs:complexType>
   <xs:attribute name="Name" type="xs:Name" use="required"/>
   <xs:attribute name="InlineIconFilePath" type="xs:string" default=""/>
  </xs:complexType>
 </xs:element>

 <xs:element name="Field">
  <xs:complexType>
   <xs:sequence minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="ValidationRule"/>
   </xs:sequence>
   <xs:attribute name="Name" type="xs:Name" use="required"/>
  </xs:complexType>
 </xs:element>

 <xs:element name="ValidationRule">
  <xs:complexType>
   <xs:attribute name="Type" type="xs:string" use="required"/>
   <xs:attribute name="MinValue" type="xs:string" default=""/>
   <xs:attribute name="MaxValue" type="xs:string" default=""/>
   <xs:attribute name="ErrorMessage" type="xs:string" use="required"/>
   <xs:attribute name="Operator" type="xs:string" default=""/>
   <xs:attribute name="FieldToCompare" type="xs:string" default=""/>
   <xs:attribute name="Expression" type="xs:string" default=""/>
  </xs:complexType>
 </xs:element>

 <xs:element name="SearchRelatedField">
  <xs:complexType>
   <xs:attribute name="Name" type="xs:Name" use="required"/>
   <xs:attribute name="Relation" type="xs:string" use="required"/>
  </xs:complexType>
 </xs:element>

<!-- Add a new calculated field. 
Example:
<CalculatedField Name="Total" Type="System.Decimal" 
	Value="OrderDetailFields.Quantity * OrderDetailFields.UnitPrice"
	Aggregate = "Sum" />
-->
<xs:element name="CalculatedField">
  <xs:complexType>
   <xs:attribute name="Name" type="xs:Name" use="required"/>
   <xs:attribute name="Type" type="xs:string" use="required"/>
   <xs:attribute name="Value" type="xs:string" use="required"/>
   <xs:attribute name="Aggregate" type="CalculatedFieldAggregateType" />
   <xs:attribute name="Label" type="xs:string" />
   <xs:attribute name="Format" type="xs:string" />
  </xs:complexType>
 </xs:element>

  <xs:simpleType name="CalculatedFieldAggregateType">
   <xs:restriction base="xs:Name">
     <xs:enumeration value="Count"/>
     <xs:enumeration value="CountDistinct"/>
     <xs:enumeration value="CountRow"/>
     <xs:enumeration value="Avg"/>
     <xs:enumeration value="AvgDistinct"/>
     <xs:enumeration value="Max"/>
     <xs:enumeration value="Min"/>
     <xs:enumeration value="Sum"/>
     <xs:enumeration value="SumDistinct"/>
     <xs:enumeration value="StDev"/>
     <xs:enumeration value="StDevDistinct"/>
     <xs:enumeration value="Variance"/>
     <xs:enumeration value="VarianceDistinct"/>
   </xs:restriction>
  </xs:simpleType>

  <xs:element name="StateField">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="State"/>
      </xs:sequence>
      <xs:attribute name="Name" use="required" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="State">
    <xs:complexType>
      <xs:sequence>
        <xs:element maxOccurs="unbounded" ref="AllowedTransitions"/>
      </xs:sequence>
      <xs:attribute name="Value" use="required" type="xs:NMTOKEN"/>
      <xs:attribute name="InitialForRoles" type="xs:string"/>
    </xs:complexType>
  </xs:element>
  <xs:element name="AllowedTransitions">
    <xs:complexType mixed="true">
      <xs:attribute name="RoleName" type="xs:NCName"/>
    </xs:complexType>
  </xs:element>

</xs:schema>
