<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
	xmlns:xdwc="http://tdi.texas.gov/DWCForms"
	xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
	targetNamespace="http://tdi.texas.gov/DWCForms"
>

	<!-- simpleType definitions -->

	<!-- Two alpha characters -->
	<xsd:simpleType name="typeChar2">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[a-zA-Z]{2}" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Three digit string -->
	<xsd:simpleType name="typeNumber3">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[0-9]{3}" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Used for US area codes -->
	<xsd:simpleType name="typePhone3">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[1-9][0-9]{2}" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Used for US phone numbers -->
	<xsd:simpleType name="typePhone7">
		<xsd:restriction base="xsd:string">
			<!-- required for US phones -->
			<xsd:pattern value="[1-9][0-9]{6}" />
			<!-- used for non-US phones only -->
			<xsd:pattern value="[0-9]+" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Used for US phone numbers Extensions -->
	<xsd:simpleType name="typePhoneExtension">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[0-9]*" />
			<xsd:maxLength value="10" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Federal Employer ID Number (US). -->
	<xsd:simpleType name="typeFEIN">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[0-9]{9}" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Six-Digit NAICS Code -->
	<xsd:simpleType name="typeNAICS">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[0-9]{6}" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Used for US postal codes only -->
	<xsd:simpleType name="typeZip">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[0-9]{5}" />
			<xsd:pattern value="[0-9]{5}[0-9]{4}" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Date string of yyyy-mm-dd -->
	<xsd:simpleType name="typeDate">
		<xsd:restriction base="xsd:string">
			<!-- date format: yyyy-mm-dd -->
			<xsd:pattern value="[1-2][0-9]{3}\-[0-1][0-9]\-[0-3][0-9]" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Filing Reason Code Annual or Terminated or Closed  or Other -->
	<xsd:simpleType name="typeFilingReasonType">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="Annual|Terminated|Closed|Other" />
		</xsd:restriction>
	</xsd:simpleType>

	<!-- Email Address -->
	<xsd:simpleType name="typeEmail">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,20}" />
		</xsd:restriction>
	</xsd:simpleType>


	<!-- Generic complexType definitions -->

	<!-- USA Phone number -->
	<xsd:complexType name="typePhone">
		<xsd:sequence>
			<!-- AreaCode required for US phones -->
			<xsd:element name="AreaCode" type="xdwc:typePhone3" minOccurs="1" maxOccurs="1" />
			<!-- US phone number. 7-digits for US. -->
			<xsd:element name="Number" type="xdwc:typePhone7" minOccurs="1" maxOccurs="1" />
			<!-- Optional extension.  Digits only. -->
			<xsd:element name="Extension" type="xdwc:typePhoneExtension" minOccurs="0" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>

	<!-- USA Address -->
	<xsd:complexType name="typeAddress">
		<xsd:sequence>
			<!-- US Address. Line always required. -->
			<xsd:element name="Line" type="xsd:string" minOccurs="1" maxOccurs="1" />
			<!-- US City is always required -->
			<xsd:element name="City" type="xsd:string" minOccurs="1" maxOccurs="1" />
			<!-- US State -->
			<xsd:element name="State" type="xdwc:typeChar2" minOccurs="1" maxOccurs="1" />
			<!-- 5 or 9-digit ZIP required for US addresses (no punctuation) -->
			<xsd:element name="Zip" type="xdwc:typeZip" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>
	<!-- Point Of Contact -->
	<xsd:complexType name="typePOC">
		<xsd:sequence>
			<!-- Contact Info. All elements required. -->
			<xsd:element name="Name" type="xsd:string" minOccurs="1" maxOccurs="1" />
			<xsd:element name="Phone" type="xdwc:typePhone" minOccurs="1" maxOccurs="1" />
			<xsd:element name="EMail" type="xdwc:typeEmail" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>
	<!-- Effective Dates -->
	<xsd:complexType name="typeDateRange">
		<xsd:sequence>
			<xsd:element name="FromDate" type="xdwc:typeDate" minOccurs="1" maxOccurs="1" />
			<xsd:element name="ToDate" type="xdwc:typeDate" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>


	<!-- ***************** ELEMENT DEFINITIONS *************  -->
	<!-- Bulk DWC005   -->

	<xsd:element name="BulkDWC005">
		<xsd:complexType>
			<xsd:sequence>
				<!-- Non-Subscriber Info -->
				<xsd:element name="DWC005" type="xdwc:typeBulkDWC005" minOccurs="1"
					maxOccurs="unbounded" />
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>

	<!-- Bulk DWC005 data format -->
	<!-- Non-Subscriber Info -->
	<xsd:complexType name="typeBulkDWC005">
		<xsd:sequence>
			<!-- Required field. Primary Employer Information -->
			<xsd:element name="Employer" type="xdwc:typeEmployer" minOccurs="1" maxOccurs="1" />
			<!-- Required field. Filing Reason details -->
			<xsd:element name="FilingReason" type="xdwc:typeFilingReason" minOccurs="1"
				maxOccurs="1" />
			<!-- Optional field. Additional Business Locations  -->
			<xsd:element name="Location" type="xdwc:typeLocation" minOccurs="0"
				maxOccurs="unbounded" />
		</xsd:sequence>
	</xsd:complexType>

	<!-- For Filing Reason details. -->
	<xsd:complexType name="typeFilingReason">
		<xsd:sequence>
			<!-- Required field. The filing reason selected is effective from yyyy-mm-dd to
			yyyy-mm-dd. -->
			<xsd:element name="EffectiveDates" type="xdwc:typeDateRange" minOccurs="1" maxOccurs="1" />

			<!-- Required field. Value will be Annual or Terminated or Closed or Other-->
			<xsd:element name="FilingReasonType" type="xdwc:typeFilingReasonType" minOccurs="1"
				maxOccurs="1" />

			<!-- Required if FilingReasonType value is Terminated  -->
			<xsd:element name="Terminated" type="xdwc:typeTerminated" minOccurs="0" maxOccurs="1" />

			<!-- Required if FilingReasonType value is Closed -->
			<xsd:element name="Closed" type="xdwc:typeDate" minOccurs="0" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>

	<xsd:complexType name="typeTerminated">
		<xsd:sequence>
			<!-- Required field. -->
			<xsd:element name="PolicyInfo" type="xdwc:typePolicyInfo" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>

	<!-- If PolicyInfo present, then all elements are required -->
	<xsd:complexType name="typePolicyInfo">
		<xsd:sequence>
			<!--  Policy Termination Effective date in the format yyyy-mm-dd -->
			<xsd:element name="PolicyTerminationDate" type="xdwc:typeDate" minOccurs="1"
				maxOccurs="1" />
			<!-- Policy Number -->
			<xsd:element name="Policy" type="xsd:string" minOccurs="1" maxOccurs="1" />
			<!-- Carrier Name -->
			<xsd:element name="Carrier" type="xsd:string" minOccurs="1" maxOccurs="1" />
			<!-- Date insurer informed of termination (yyyy-mm-dd) -->
			<xsd:element name="DateInformed" type="xdwc:typeDate" minOccurs="1" maxOccurs="1" />
			<!-- Date employees were (will be) notified of termination (yyyy-mm-dd) -->
			<xsd:element name="DateNotified" type="xdwc:typeDate" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>

	<!-- Employer details-->
	<xsd:complexType name="typeEmployer">
		<xsd:sequence>
			<!-- Employer Business Name -->
			<xsd:element name="Name" type="xsd:string" minOccurs="1" maxOccurs="1" />
			<!-- Federal Employer ID Number -->
			<xsd:element name="FEIN" type="xdwc:typeFEIN" minOccurs="1" maxOccurs="1" />
			<!-- Employer Business Mailing Address -->
			<xsd:element name="Address" type="xdwc:typeAddress" minOccurs="1" maxOccurs="1" />
			<!-- Six-Digit NAICS Code -->
			<xsd:element name="NAICSCode" type="xdwc:typeNAICS" minOccurs="1" maxOccurs="1" />
			<!-- Contact Information -->
			<xsd:element name="Contact" type="xdwc:typePOC" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>

	<!-- Additional Business Locations -->
	<xsd:complexType name="typeLocation">
		<xsd:sequence>
			<!-- EffectiveDat is in the format yyyy-mm-dd  -->
			<xsd:element name="EffectiveDate" type="xdwc:typeDate" minOccurs="1" maxOccurs="1" />
			<!-- Business/Location Name -->
			<xsd:element name="Name" type="xsd:string" minOccurs="1" maxOccurs="1" />
			<!-- Business/Location FEIN -->
			<xsd:element name="FEIN" type="xdwc:typeFEIN" minOccurs="1" maxOccurs="1" />
			<!-- Business/Location Address -->
			<xsd:element name="Address" type="xdwc:typeAddress" minOccurs="1" maxOccurs="1" />
		</xsd:sequence>
	</xsd:complexType>
</xsd:schema>