<?xml version="1.0" encoding="UTF-8"?>
<xs:schema targetNamespace="urn:defra.gov.uk:ESP:SeedCerts" xmlns:gt="http://www.govtalk.gov.uk/Schemas/govtalk/core" xmlns:SeedCerts="urn:defra.gov.uk:ESP:SeedCerts" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified" version="7.2" id="DEFRA_SeedCert_Cert2">
	<xs:annotation>
		<xs:documentation>This schema is used for submitting Seed Cert forms through the Gateway to Defra and NIAB</xs:documentation>
		<xs:appinfo>Defra, Seed Certification, Cert2, NIAB</xs:appinfo>
	</xs:annotation>
	<xs:include schemaLocation="SC_Common.xsd"/>
	<xs:element name="Cert2" type="SeedCerts:Cert2Type">
		<xs:annotation>
			<xs:documentation>Root node for Seed Certs cert2</xs:documentation>
		</xs:annotation>
	</xs:element>
	<xs:complexType name="Cert2Type">
		<xs:sequence>
			<xs:element name="MessageCreationTimestamp" type="xs:dateTime" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="Cert2Details" type="SeedCerts:Cert2Structure" maxOccurs="unbounded">
				<xs:annotation>
					<xs:documentation>Structure containing details for Cert2 applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="PaymentDetails" type="SeedCerts:PaymentDetailsStructure" minOccurs="0">
				<xs:annotation>
					<xs:documentation>Structure containing details of payments made for forms submissions, includes Defra and Gateway generated IDs, but no credit card details</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<!-- Start of Cert2Structure type definition -->
	<xs:complexType name="Cert2Structure">
		<xs:sequence>
			<xs:element name="Action" type="SeedCerts:ActionType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="ApplicationID" type="SeedCerts:ProgramIDType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="ApplicantOfficialNumber" type="SeedCerts:OfficialNumberType">
				<xs:annotation>
					<xs:documentation>Unique number assigned to applicant by Defra</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="AFPNumber" type="SeedCerts:AFPNumberType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="CategoryLevel" type="SeedCerts:CategoryType">
				<xs:annotation>
					<xs:documentation>Category for species and variety combination</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="HarvestYear" type="SeedCerts:YearType">
				<xs:annotation>
					<xs:documentation>Crop year</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="InitialFeeAmount" type="SeedCerts:FeeAmountType">
				<xs:annotation>
					<xs:documentation>External applications should enter 0.00 as this will be calculated by system</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="CropInspectionPayment" type="SeedCerts:FeeAmountType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="SeedLot" type="SeedCerts:FreeFormSeedLotStructure" maxOccurs="unbounded">
				<xs:annotation>
					<xs:documentation>Structure containing seed lot details</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="VarietyDetails" type="SeedCerts:VarietyStructure">
				<xs:annotation>
					<xs:documentation>Structure containing variety details</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="Cert2Line" type="SeedCerts:Cert2LineStructure" maxOccurs="9">
				<xs:annotation>
					<xs:documentation>Structure containing crop line details</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<!-- End of Cert2Structuretype definition -->
	<!-- ==================== -->
	<!-- Common Complex Types -->
	<!-- ==================== -->
	<xs:complexType name="Cert2LineStructure">
		<xs:sequence>
			<xs:element name="ApplicationID" type="SeedCerts:ProgramIDType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="ApplicationLineID" type="SeedCerts:ProgramIDType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="CropIdentityNo" type="SeedCerts:CropIdentityNoType">
				<xs:annotation>
					<xs:documentation>Crop identity number</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="FarmHoldingNo" type="SeedCerts:CPHnumType">
				<xs:annotation>
					<xs:documentation>Farm holding number</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="IACSFieldNo" type="SeedCerts:IACSFieldNoType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>IACS field number</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="OSGridRefNo" type="SeedCerts:GridRefStructure" minOccurs="0">
				<xs:annotation>
					<xs:documentation>No longer used</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="FieldName" type="SeedCerts:LongStringType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>Field name</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="CropAreaSown" type="SeedCerts:AreaType">
				<xs:annotation>
					<xs:documentation>Area sown in hectares</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="CropSownDate" type="SeedCerts:CropSownDateStructure" minOccurs="0">
				<xs:annotation>
					<xs:documentation>Structure containing sown details for crop</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="Grower" type="SeedCerts:GrowerStructure">
				<xs:annotation>
					<xs:documentation>Structure containing grower details</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="CropAddress" type="SeedCerts:AddressStructure">
				<xs:annotation>
					<xs:documentation>Structure containing crop address details</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="PreviousUsage" type="SeedCerts:PreviousUsageStructure" minOccurs="1" maxOccurs="10">
				<xs:annotation>
					<xs:documentation>Structure containing previous usage details</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
		<xs:attribute name="RowNo" type="xs:positiveInteger" use="optional">
			<xs:annotation>
				<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
			</xs:annotation>
		</xs:attribute>
	</xs:complexType>
	<!-- End of Cert2LineStructure -->
	<!-- Start of CropSownDateStructure -->
	<xs:complexType name="CropSownDateStructure">
		<xs:annotation>
			<xs:documentation>Structure containing sown details for crop</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="ApplicationLineID" type="SeedCerts:ProgramIDType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="Year" type="SeedCerts:YearType">
				<xs:annotation>
					<xs:documentation>Year crop sown</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="SeasonCode" minOccurs="0">
				<xs:annotation>
					<xs:documentation>Season crop sown (Autumn/Spring)</xs:documentation>
				</xs:annotation>
				<xs:simpleType>
					<xs:restriction base="xs:string">
						<xs:enumeration value=""/>
						<xs:enumeration value="A"/>
						<xs:enumeration value="S"/>
					</xs:restriction>
				</xs:simpleType>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<!-- End of CropSownDateStructure -->
	<!-- start of SeedLotStructure type definition -->
	<xs:complexType name="FreeFormSeedLotStructure">
		<xs:annotation>
			<xs:documentation>Structure containing seed lot details</xs:documentation>
		</xs:annotation>
		<xs:sequence>
			<xs:element name="ApplicationID" type="SeedCerts:ProgramIDType" minOccurs="0">
				<xs:annotation>
					<xs:documentation>For internal use only - should not be populated by external applications</xs:documentation>
				</xs:annotation>
			</xs:element>
			<xs:element name="SLRN" type="SeedCerts:SLRNFreeFormatType">
			<!-- This should contain a pattern for a correct Reference Number -->
				<xs:annotation>
					<xs:documentation>Seed lot reference number</xs:documentation>
					<xs:documentation>For England &amp; Wales format - seed lot year (4 digits must be entered)/category (2 characters)/applicant number (up to 5 digits)/seed lot number (up to 4 digits)</xs:documentation>
				</xs:annotation>
			</xs:element>
		</xs:sequence>
	</xs:complexType>
	<!-- end of SeedLotStructure type definition -->
	<xs:simpleType name="IACSFieldNoType">
		<xs:annotation>
			<xs:documentation>Pattern defines an IACS field number</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="[A-Z]{2}[0-9]{8}"/>
		</xs:restriction>
	</xs:simpleType>
</xs:schema>
