<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <!-- Version: 9.0 -->
	<!-- Created: March 2012 -->
	<!-- Modified: May 2012 -->

	<xsl:include href="pbdmi-common-9.xsl"/>

	<xsl:output indent="yes" method="xml"/>

	<xsl:template match="*">

		<!-- HEADER -->
		<xsl:element name="FILETRANSMISSION">
			<xsl:attribute name="FILELAYOUTTYPE">
				<xsl:value-of select="FileLayoutType"/>
			</xsl:attribute>
			<xsl:attribute name="FILEID">
				<xsl:value-of select="FileId"/>
			</xsl:attribute>
			<xsl:attribute name="SCHOOLYEAR">
				<xsl:value-of select="SchoolYear"/>
			</xsl:attribute>

			<xsl:variable name="fips" select="FipsStateCode"/>

			<!--loop through agency elements-->
			<xsl:for-each select="Agency">
				<!--<AGENCY FIPSSTATECODE="01" STATEAGENCYIDNUMBER="01" STATELEAIDNUMBER="001000-0000001">-->
				<xsl:element name="AGENCY">
					<xsl:attribute name="FIPSSTATECODE">
						<xsl:value-of select="$fips"/>
					</xsl:attribute>
					<xsl:attribute name="STATEAGENCYIDNUMBER">
						<xsl:value-of select="StateAgencyIdNumber"/>
					</xsl:attribute>

					<xsl:if test="StateLeaIdNumber">
						<xsl:attribute name="STATELEAIDNUMBER">
							<xsl:value-of select="StateLeaIdNumber"/>
						</xsl:attribute>
					</xsl:if>

					<!--loop through MEPSTUDELIG child elements-->
					<xsl:for-each select="MepEligible12Month">

						<!--<TABLETYPE TYPEABBRV="MEPSTUDELIG" TOTALINDICATOR="N">-->
						<xsl:element name="TABLETYPE">
							<xsl:attribute name="TYPEABBRV">MEPSTUDELIG</xsl:attribute>
							<xsl:attribute name="TOTALINDICATOR">
								<xsl:value-of select="TotalIndicator"/>
							</xsl:attribute>

							<!--<CATEGORY TYPE="AGEGRDALL" VALUE="12"/>-->
							<xsl:apply-templates select="AgeGradeAll">
								<xsl:with-param name="value">
									<xsl:value-of select="AgeGradeAll"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<CATEGORY TYPE="RACEETHNIC" VALUE="AM7"/>-->
							<xsl:apply-templates select="RaceEthnic">
								<xsl:with-param name="value">
									<xsl:value-of select="RaceEthnic"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<CATEGORY TYPE="AGEGRDWOU3" VALUE="12"/>-->
							<xsl:apply-templates select="AgeGradeWoUnder3">
								<xsl:with-param name="value">
									<xsl:value-of select="AgeGradeWoUnder3"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<CATEGORY TYPE="MEPPOSONLY" VALUE="PS"/>-->
							<xsl:apply-templates select="MigrantPriorityForServicesOnly">
								<xsl:with-param name="value">
									<xsl:value-of select="MigrantPriorityForServicesOnly"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<CATEGORY TYPE="LEPONLY" VALUE="LEP"/>-->
							<xsl:apply-templates select="LepStatusOnly">
								<xsl:with-param name="value">
									<xsl:value-of select="LepStatusOnly"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<CATEGORY TYPE="DISABSTATUS" VALUE="WDIS"/>-->
							<xsl:apply-templates select="DisabilityStatusOnly">
								<xsl:with-param name="value">
									<xsl:value-of select="DisabilityStatusOnly"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<CATEGORY TYPE="MOBILSTATUSMNTH" VALUE="LQM12"/>-->
							<xsl:apply-templates select="MobilityStatusQualifyingMoves">
								<xsl:with-param name="value">
									<xsl:value-of select="MobilityStatusQualifyingMoves"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<CATEGORY TYPE="MOBILSTATUSSY" VALUE="QMRSY"/>-->
							<xsl:apply-templates select="MobilityStatusSy">
								<xsl:with-param name="value">
									<xsl:value-of select="MobilityStatusSy"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<AMOUNT>500</AMOUNT>-->
							<xsl:apply-templates select="Amount">
								<xsl:with-param name="value">
									<xsl:value-of select="Amount"/>
								</xsl:with-param>
							</xsl:apply-templates>

							<!--<EXPLANATION></EXPLANATION>-->
							<xsl:apply-templates select="Explanation">
								<xsl:with-param name="value">
									<xsl:value-of select="Explanation"/>
								</xsl:with-param>
							</xsl:apply-templates>
						</xsl:element>
					</xsl:for-each>
				</xsl:element>
			</xsl:for-each>
		</xsl:element>
	</xsl:template>
</xsl:stylesheet>