<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"           
	targetNamespace="http://schemas.fi.se/TRS/OutClient"
	xmlns="http://schemas.fi.se/TRS/OutClient" 
	elementFormDefault="unqualified">
	<xs:annotation>
		<xs:appinfo>
			<Status>
				<Status>Production</Status>
				<Description>Production</Description>
				<Version>1.00</Version>
				<Revisions>
					<Revision date="2007-06-08">Schema name convension changed and Fixed Version attibute added at root element</Revision>
					<Revision date="2008-02-29">Item error code ICI added. Reason element added under CustomerClient element.</Revision>

					<Revision date="2008-08-28">File error code IDCI added.</Revision>
				</Revisions>
			</Status>
			<Subject>
				<Project>TRS</Project>
				<Category>Customer client</Category>
			</Subject>
			<Title>TRS - CustomerClient feedback schema</Title>
			<Type>architectural</Type>
			<Description>Response to a reported CustomerClient report</Description>
			<Language>Eng</Language>
		</xs:appinfo>
	</xs:annotation>

	<!--Date specified in the following form YYYY-MM-DDThh:mm:ss with optional timezone -->
	<xs:simpleType name="DateTimeType">
		<xs:annotation>
			<xs:documentation>YYYY-MM-DDThh:mm:ss+/-hh:mm</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:dateTime"></xs:restriction>
	</xs:simpleType>

	<!-- BIC code type -->
	<xs:simpleType name="BICCodeType">
		<xs:annotation>
			<xs:documentation>ISO 9362 - SWIFT/Bank Identifier Code (BIC) - Format: 11(x)</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:token">
			<xs:length value="11" />
		</xs:restriction>
	</xs:simpleType>

	<!-- String with a max length of 40 -->
	<xs:simpleType name="StringType40">
		<xs:annotation>
			<xs:documentation>Format: max 40(x)</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:token">
			<xs:minLength value="1"></xs:minLength>
			<xs:maxLength value="40"></xs:maxLength>
		</xs:restriction>
	</xs:simpleType>

	<!-- String with a max length of 90 -->
	<xs:simpleType name="StringType500">
		<xs:annotation>
			<xs:documentation>Format: max 500(x)</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:token">
			<xs:minLength value="1"></xs:minLength>
			<xs:maxLength value="500"></xs:maxLength>
		</xs:restriction>
	</xs:simpleType>

	<!-- File status -->
	<xs:simpleType name="FileStatusType">
		<xs:annotation>
			<xs:documentation>
				AWE = Accepted With Errors
				ACC = Accepted
				REJ = Rejected
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="ACC|AWE|REJ" />
		</xs:restriction>
	</xs:simpleType>

	<!-- Status file error codes  -->
	<xs:simpleType name="FileErrorCodeType">
		<xs:annotation>
			<xs:documentation>
				Status File Error codes:

				DCRE  = DeCryptionError
				DVE   = DataValidationError
				FEE   = FileExtensionError
				GSE   = GeneralSystemError
				IDCI  = (InternalDuplicateClientIdentifier) The reported file contains one or more clients with identical identifiers
				IFNF  = InvalidFileNameFormat
				IRV   = InvalidReportingVenue
				ITF   = InvalidTechnicalReportingFirm
				IXF   = InvalidXmlFormat
				OK    = Ok
				SNF   = SchemaNotFound
				SNV   = SchemaNotValid
				SVE   = SignerVerificationError
				UFAS  = UploadedFileAlreadySubmitted
				UFSE  = UploadedFileSizeError
				XPE   = XmlParseError
				ZDCOE = ZipDecompressionError

			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="DCRE|DVE|FEE|GSE|IDCI|IFNF|IRV|ITF|IXF|OK|SNF|SNV|SVE|UFAS|UFSE|XPE|ZDCOE" />
		</xs:restriction>
	</xs:simpleType>

	<!-- CustomerClient status -->
	<xs:simpleType name="CustomerClientStatusType">
		<xs:annotation>
			<xs:documentation>
				CustomerClient status types:

				ACCEPTED = Client record is accepted.
				FAILED = Client record is rejected. See Reason element for details.

			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="ACCEPTED|FAILED" />
		</xs:restriction>
	</xs:simpleType>

	<!--  Client reason code -->
	<xs:simpleType name="ClientReasonCodeType">
		<xs:annotation>
			<xs:documentation>
					Client error codes:
					ICI = InvalidClientIdentifier
			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="ICI" />
		</xs:restriction>
	</xs:simpleType>

	<!--Feedback schema-->
	<xs:element name="feedback">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="CustomerClientReport">
					<xs:complexType>
						<xs:simpleContent>
							<xs:extension base="StringType500">
								<xs:attribute name="ReceivedTimestamp" type="DateTimeType" use="required"/>
							</xs:extension>
						</xs:simpleContent>
					</xs:complexType>
				</xs:element>
				<xs:element name="FeedbackReport" minOccurs="1" maxOccurs="1"/>
				<xs:element name="Summary">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="FileStatus" type="FileStatusType" />
							<xs:element name="Code" type="FileErrorCodeType" />
							<xs:element name="Message" type="StringType500" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="TechnicalReportingFirm"  minOccurs="0" maxOccurs="1">
					<xs:complexType>
						<xs:attribute name="Identification" type="BICCodeType" use="required"/>
					</xs:complexType>
				</xs:element>
				<xs:element name="ReportingFirm" minOccurs="0" maxOccurs="unbounded" >
					<xs:complexType>
						<xs:sequence>
							<xs:element name="CustomerClient" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Reason" type="ClientReasonCodeType" minOccurs="0" maxOccurs="unbounded" />
									</xs:sequence>					
									<xs:attribute name="Identification" type="StringType40" />
									<xs:attribute name="Status" type="CustomerClientStatusType" use="required"/>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
						<xs:attribute name="Identification" type="BICCodeType" use="required"/>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
			<xs:attribute name="Version" type="xs:decimal" fixed="1.00" use="required"/>
		</xs:complexType>
	</xs:element>
</xs:schema>

