<xsd:schema 
	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns="http://entp.hud.gov/caivrs"
        targetNamespace="http://entp.hud.gov/caivrs"
        elementFormDefault="qualified">

<!-- complex elements -->

<xsd:complexType name="inputType">
	<xsd:sequence>
		<xsd:element name="MORTGAGEDATA" type="mortgageDataInputType"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="outputType">
	<xsd:sequence>
		<xsd:element name="MORTGAGEDATA" type="mortgageDataOutputType"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="mortgageDataInputType">
	<xsd:sequence>
		<xsd:element name="PROCESSSTATUS" type="ProcessStatusInputType"/>
		<xsd:element name="BORROWER" type="borrInputType" minOccurs="1" maxOccurs="5"/>
		<xsd:element name="APPLICATION" type="applicationType"/>
	</xsd:sequence>
	<xsd:attribute name="MISMOVersionID" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="mortgageDataOutputType">
	<xsd:sequence>
		<xsd:element name="PROCESSSTATUS" type="ProcessStatusOutputType"/>
		<xsd:element name="BORROWER" type="borrOutputType" minOccurs="1" maxOccurs="5"/>
		<xsd:element name="APPLICATION" type="applicationType"/>
	</xsd:sequence>
	<xsd:attribute name="MISMOVersionID" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="ProcessStatusInputType">
	<xsd:sequence>
		<xsd:element name="ProcessStatusCode" type="ProcessStatusCodeInputType"/>
		<xsd:element name="ProcessStatusRequestor" type="xsd:string"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="ProcessStatusOutputType">
	<xsd:sequence>
		<xsd:element name="ProcessStatusCode" type="ProcessStatusCodeOutputType"/>
		<xsd:element name="ProcessStatusMessage" type="mType"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="mType">
        <xsd:simpleContent>
            <xsd:extension base="xsd:string">
                <xsd:attribute name="sCode" type="xsd:integer"/>
            </xsd:extension>
        </xsd:simpleContent>
</xsd:complexType>

<xsd:complexType name="borrInputType">
	<xsd:sequence>
		<xsd:element name="SSN" type="xsd:string"/>
		<xsd:element name="UnitedStatesTaxPayerIdentificationNumber" type="xsd:string"/>
	</xsd:sequence>
	<xsd:attribute name="BORROWERID" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="borrOutputType">
	<xsd:sequence>
		<xsd:element name="SSN" type="xsd:string"/>
		<xsd:element name="UnitedStatesTaxPayerIdentificationNumber" type="xsd:string"/>
		<xsd:element name="CAIVRSAuthorizationCode" type="xsd:string"/>
		<xsd:element name="CAIVRSAgencyNegativeReports" type="reportType"/>
	</xsd:sequence>
	<xsd:attribute name="BORROWERID" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="reportType">
	<xsd:sequence>
		<xsd:element name="AgencyName" type="xsd:string"/>
		<xsd:element name="CaseNumber" type="xsd:string"/>
		<xsd:element name="CaseType" type="xsd:string"/>
		<xsd:element name="PhoneReferral" type="xsd:string"/>
	</xsd:sequence>
	<xsd:attribute name="CAIVRSAgencyNegativeReportsID" type="xsd:string"/>
</xsd:complexType>

<xsd:complexType name="applicationType">
	<xsd:sequence>
		<xsd:element name="UNDERWRITINGCASE" type="uwcType"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="uwcType">
	<xsd:sequence>
		<xsd:element name="FHAVA" type="fhavaType"/>
	</xsd:sequence>
</xsd:complexType>

<xsd:complexType name="fhavaType">
	<xsd:sequence>
		<xsd:element name="FHAVAOriginatorIdentifier" type="xsd:string"/>
		<xsd:element name="FHAVAAgencyIdentifier" type="agencyType"/>
	</xsd:sequence>
</xsd:complexType>

<!-- simple elements -->

<xsd:simpleType name="ProcessStatusCodeInputType">
	<xsd:restriction base="xsd:string">
		<xsd:enumeration value="Query"/>
		<xsd:enumeration value="Update"/>
	</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="ProcessStatusCodeOutputType">
	<xsd:restriction base="xsd:string">
		<xsd:enumeration value="SuccessNoUpdatesAllowed"/>
		<xsd:enumeration value="Error"/>
		<xsd:enumeration value="UNAVAILABLE"/>
	</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="agencyType">
	<xsd:restriction base="xsd:string">
		<xsd:enumeration value="FHATitleOne"/>
		<xsd:enumeration value="HUD-312Rehabilitation"/>
		<xsd:enumeration value="FHASingleFamily"/>
		<xsd:enumeration value="DepartmentOfVeteransAffairs"/>
		<xsd:enumeration value="USDA RuralHousing"/>
		<xsd:enumeration value="USDA FarmServices"/>
		<xsd:enumeration value="SmallBusinessAdministration"/>
		<xsd:enumeration value="Treasury-FDIC"/>
		<xsd:enumeration value="USDARuralDevelopment"/>
		<xsd:enumeration value="HUDNativeAmericanPrograms"/>
		<xsd:enumeration value="HUDGoodNeighbor"/>
	</xsd:restriction>
</xsd:simpleType>


</xsd:schema>