<?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>2.10</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>

				</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>

	<!-- Status file error codes -->
	<xs:simpleType name="FileErrorCodeType">
		<xs:annotation>
			<xs:documentation>
				Status File Error codes:

				DCRE  = DeCryptionError
				DVE   = DataValidationError
				FEE   = FileExtensionError
				GSE   = GeneralSystemError
				IDTI  = InternalDuplicateTransactionIdentifier
				IFNF  = InvalidFileNameFormat
				IRF   = InvalidReportingFirm
				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|IDTI|IFNF|IRF|ITF|IXF|OK|SNF|SNV|SVE|UFAS|UFSE|XPE|ZDCOE" />
		</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>

	<!-- Transaction reason code -->
	<xs:simpleType name="TransactionReasonCodeType">
		<xs:annotation>
			<xs:documentation>
				Transaction error codes:

				AIIDT  = (AlternativeInstrumenIdentificationDerivativeType Error) DerivativeType must be [O] or [F] for AII.
				AIIMD  = (AlternativeInstrumenIdentificationMaturityDate Error) The AII MaturityDate must be a valid datetime.
				AIIPC  = (AlternativeInstrumenIdentificationPutCallIndicator Error) PutCallIndicator must be [P],[C] or [F] for AII.
				AIISP  = (AlternativeInstrumenIdentificationStrikePrice Error) The AII StrikePrice is invalid.
				AIIXC  = (AlternativeInstrumenIdentificationProductCode Error) ProductCode does not exist or is invalid.
				AIIXPC = (AlternativeInstrumenIdentificationExchangeProductCode Error) ExchangeProductCode must be 1-12 characters.

				DTI    = DuplicateTransactionIdentifier
				ICPC   = InvalidCounterPartyCode
				IISIN  = InvalidISINCode
				IPN	   = InvalidPriceNotation
				ITD    = InvalidTradingDate
				IVI    = InvalidVenueIdentification
				MTI    = MissingTransactionIndicator
				OK     = Ok
				CIM    = Client information missing
				ICC	   = Invalid client code
				RTAC   = ReferingTransactionAlreadyCanceled

			</xs:documentation>
		</xs:annotation>
		<xs:restriction base="xs:string">
			<xs:pattern value="AIIDT|AIIMD|AIIPC|AIISP|AIIXC|AIIXPC|CIM|DTI|ICC|ICPC|IISIN|IPN|ITD|IVI|MTI|OK|RTAC" />
		</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="FileErrorCodeType" />
							<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="TransactionReasonCodeType" 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="TransactionReasonCodeType" 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="2.10" use="required"></xs:attribute>
		</xs:complexType>
	</xs:element>
	
</xs:schema>

