<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"           
	targetNamespace="http://schemas.fi.se/TRS/OutTrans"
	xmlns="http://schemas.fi.se/TRS/OutTrans" 
	elementFormDefault="unqualified">
	<xs:annotation>
		<xs:appinfo>
			TRS - Transaction feedback report
		</xs:appinfo>
		<xs:documentation>
			<Status>
				<Status>Production</Status>
				<Description>Production</Description>
				<Version>3.00</Version>
				<Revisions>
					<Revision date="2007-01-31">Error code DTI moved from FileErrorCodeType to TransactionReasonCodeType</Revision>
					<Revision date="2007-04-11">Removed type OriginalFileNameType. FileErrorCodeType "OK"=Ok</Revision>
					<Revision date="2007-06-08">Schema name convension changed and Fixed Version attibute added at root element</Revision>
					<Revision date="2007-06-11">StringType90 changed to StringType500 in order to length of errormessages</Revision>
					<Revision date="2007-08-24">Updates removed</Revision>
					<Revision date="2007-09-20">Errorcode RTAC readded</Revision>
					<Revision date="2007-09-20">Schema harmonized with other TRS schemas</Revision>

					<Revision date="2008-08-27">Changed version to 2.1</Revision>
					<Revision date="2008-08-27">Added new error codes because of AII</Revision>
					<Revision date="2008-08-28">Changed the order of the transaction error codes to be in alphabetical order.</Revision>
          <!-- New schema version 3.0  -->
          <Revision date="2010-06-29">Removed types "FileErrorCodeType" and "TransactionReasonCodeType"</Revision>
          <Revision date="2010-06-29">Changed version to 3.00</Revision>

        </Revisions>
			</Status>
			<Subject>
				<Project>TRS</Project>
				<Category>Transaction</Category>
			</Subject>
			<Title>TRS - Transaction feedback report format</Title>
			<Type>Architectural</Type>
			<Description>Result of sending a transactionreport to a CA</Description>
			<Language>English</Language>
		</xs:documentation>
	</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 -->
	<xs:simpleType name="BICCodeType">
		<xs:annotation>
			<xs:documentation>ISO 9362 - SWIFT/Bank Identifier Code (BIC) - Format: 11(x)(A-Z|0-9)</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:token">
			<xs:length value="11" />
			<xs:pattern id="upperCaseLetters11" value="[A-Z|0-9]{0,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 500 -->
	<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>

	<!-- Transaction status -->
	<xs:simpleType name="TransactionStatusType">
		<xs:annotation>
			<xs:documentation>
				Transaction status types:

				ACCEPTED = Transaction is accepted.
				FAILED = Transaction has failed. See Reason-element for error details.
				IGNORED = Transaction is ignored.

			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="ACCEPTED|FAILED|IGNORED" />
		</xs:restriction>
	</xs:simpleType>

	<!-- Feedback schema -->
	<xs:element name="feedback">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="TransactionReport">
					<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="xs:token" />
							<xs:element name="Message" type="StringType500" />
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<xs:element name="TechnicalReportingFirm"  minOccurs="0" maxOccurs="1">
					<xs:complexType>
						<xs:sequence>
							<xs:element name="Summary" >
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Transactions" type="xs:unsignedInt" minOccurs="1" maxOccurs="1"/>
										<xs:element name="Cancellations" type="xs:unsignedInt"  minOccurs="1" maxOccurs="1"/>
									</xs:sequence>
								</xs:complexType>
							</xs:element>
						</xs:sequence>
						<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="Transaction" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Reason" type="xs:token" minOccurs="0" maxOccurs="unbounded" />
									</xs:sequence>
									<xs:attribute name="TransactionReferenceNumber" type="StringType40" />
									<xs:attribute name="Status" type="TransactionStatusType" use="required"/>
								</xs:complexType>
							</xs:element>
							<xs:element name="CancellationTransaction" minOccurs="0" maxOccurs="unbounded">
								<xs:complexType>
									<xs:sequence>
										<xs:element name="Reason" type="xs:token" minOccurs="0" maxOccurs="unbounded" />
									</xs:sequence>
									<xs:attribute name="TransactionReferenceNumber" type="StringType40" />
									<xs:attribute name="Status" type="TransactionStatusType" 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="3.00" use="required"></xs:attribute>
		</xs:complexType>
	</xs:element>
	
</xs:schema>

