<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
	<xs:include schemaLocation="ErrorsInfoTypes.xsd" />
	<!--	
******************************************************************************
FEEDBACKFILEINFO

Root element of the schema. It's composed by two elements:

	OriginalFileName: Name of the file without the timestamp from the hub.
	
And one of the two following elements per file:

	NoErrors: OK if there are no errors or,

	ErrorsInfo: the complex structure of this element has been described 
		further down.

Plus five attributes:

	Version: version number of the xml schema.

	AuthorityKey: ISO 3166 country code alpha-2. Length: 2 characters.

	CreationDate: Mandatory date in ISO 8601 extended format  
		(YYYY-MM-DD). 

	CreationTime: Mandatory time in extended ISO 8601 HH:MM:SS 
		format.

	CreationTimeOffset: Mandatory ISO 8601 Time Zone Offset. 
		Format: SHH max 12 h, where S is the sign (+ or -) and 
		HH the number of hours.

******************************************************************************
-->
	<xs:element name="FeedBackFileInfo">
		<xs:annotation>
			<xs:documentation />
		</xs:annotation>
		<xs:complexType>
			<xs:sequence>
				<xs:element name="OriginalFileName" type="FileNameType" />
				<xs:choice>
					<xs:element name="NoErrors" type="NoErrorsType" />
					<xs:element name="ErrorsInfo" type="ErrorsInfoCompleteDescriptionType" />
				</xs:choice>
			</xs:sequence>
			<xs:attribute name="Version" type="xs:string" use="required" fixed="1.0" />
			<xs:attribute name="AuthorityKey" type="AuthorityKeyType" use="required" />
			<xs:attribute name="CreationDate" type="xs:date" use="required" />
			<xs:attribute name="CreationTime" type="xs:time" use="required" />
			<xs:attribute name="CreationTimeOffset" type="TimeOffsetType" use="required" />
		</xs:complexType>
	</xs:element>
	<!--	
************************************************************************
COMPLEX TYPES 

ErrorsInfoCompleteDescriptionType: errors will be managed 
	using two types of error records: file and transaction.

	See ErrorsInfoTypes.xsd for more details.

************************************************************************
-->
	<xs:complexType name="ErrorsInfoCompleteDescriptionType">
		<xs:choice>
			<xs:element name="FileErrorRecords" type="FileErrorsCompleteDescriptionType" />
			<xs:element name="TransactionErrorRecords" type="TransactionErrorsCompleteDescriptionType" />
		</xs:choice>
	</xs:complexType>
	<!--	
************************************************************************
SIMPLE TYPES 

TimeOffsetType: ISO 8601 Time Zone Offset. Format: SHH max 
	12 h, where S is the sign (+ or -) and HH the number of hours.

NoErrorsType: tag OK  if there are no errors.

FileNameType:Name of the file, without the timestamp from 
	the hub.

AuthorityKeyType: country code of the authority which sends
	the file.

************************************************************************
-->
	<xs:simpleType name="TimeOffsetType">
		<xs:annotation>
			<xs:documentation>ISO 8601 Time Zone Offset Format:SHH max 12 h</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="collapse" />
			<xs:pattern value="[-|+](0[0-9]|1[0-2])" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="NoErrorsType">
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="collapse" />
			<xs:pattern value="OK" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="FileNameType">
		<xs:annotation>
			<xs:documentation> Format: 2(a)_6(a)_2(a)_6(n) _2(n)</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="collapse" />
			<xs:pattern value="[A-Z]{2}_[A-Z]{6}_[A-Z]{2}_[0-9]{6}_[0-9]{2}" />
		</xs:restriction>
	</xs:simpleType>
	<xs:simpleType name="AuthorityKeyType">
		<xs:annotation>
			<xs:documentation> ISO 31666 Country Code alpha-2 </xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:whiteSpace value="collapse" />
			<xs:pattern value="[A-Z]{2}" />
		</xs:restriction>
	</xs:simpleType>
</xs:schema>

