<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<!-- Author: Hector Tello - AEM Corporation -->
	<!-- Version: 3.0 -->

	<xsl:include href="pbdmi-common-3.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>

					<xsl:if test="StateSchoolIdNumber">
						<xsl:attribute name="STATESCHOOLIDNUMBER">
							<xsl:value-of select="StateSchoolIdNumber"/>
						</xsl:attribute>
					</xsl:if>

					<!-- DG664 – Truants-->
					<xsl:if test="Truants">
						<xsl:element name="TRUANTS">
							<xsl:value-of select="Truants"/>
						</xsl:element>
					</xsl:if>

					<!-- DG514 - Combined MEP Funds Indicator Table-->
					<xsl:if test="MepFundsIndicator">
						<xsl:element name="MEPFUNDSINDICATOR">
							<xsl:value-of select="MepFundsIndicator"/>
						</xsl:element>
					</xsl:if>

					<!-- 603 - GFSA Reporting Status -->
					<xsl:if test="GfsaReportStatus">
						<xsl:element name="GFSAREPORTSTAT">
							<xsl:value-of select="GfsaReportStatus"/>
						</xsl:element>
					</xsl:if>

					<!-- DG56 - Economically Disadvantaged Students-->
					<xsl:if test="EconomicallyDisadvantagedCount">
						<xsl:element name="ECOCIRCUM">
							<xsl:value-of select="EconomicallyDisadvantagedCount"/>
						</xsl:element>
					</xsl:if>

					<!-- DG595 - Average Daily Attendance -->
					<xsl:if test="AverageDailyAttendance">
						<xsl:element name="AVGDAILYATTEND">
							<xsl:value-of select="AverageDailyAttendance"/>
						</xsl:element>
					</xsl:if>

					<!-- DG110 – MEP Students Eligible Regular School Year -->
					<xsl:if test="MepEligible">
						<xsl:element name="MIGRNTELIG">
							<xsl:value-of select="MepEligible"/>
						</xsl:element>
					</xsl:if>

					<!-- DG614 - REAP Alternative Funding Indicator -->
					<xsl:if test="ReapAlternativeFundingInd">
						<xsl:element name="REAPALTFUNDIND">
							<xsl:value-of select="ReapAlternativeFundingInd"/>
						</xsl:element>
					</xsl:if>

					<!-- DG651 – Supplemental Services – Funds Spent -->
					<xsl:if test="SupplServicesFundsSpent">
						<xsl:element name="SLPSERFUNDSPENT">
							<xsl:value-of select="SupplServicesFundsSpent"/>
						</xsl:element>
					</xsl:if>

					<!-- DG652 – School Choice – Funds Spent -->
					<xsl:if test="SchoolChoiceFundsSpent">
						<xsl:element name="SCHCHOFUNDSPENT">
							<xsl:value-of select="SchoolChoiceFundsSpent"/>
						</xsl:element>
					</xsl:if>

					<!-- DG546 – Supplemental Services – Received Services -->
					<xsl:if test="StudentsReceivedSES">
						<xsl:element name="STRCVDSPLSER">
							<xsl:value-of select="StudentsReceivedSES"/>
						</xsl:element>
					</xsl:if>

					<xsl:if test="StudentsAppliedForSES">
						<!-- DG575 – Supplemental Services – Applied to Receive Services -->
						<xsl:element name="STAPRCSPLSER">
							<xsl:value-of select="StudentsAppliedForSES"/>
						</xsl:element>
					</xsl:if>

					<xsl:if test="StudentsEligibleSES">
						<!-- DG578 – Supplemental Services – Eligible to Receive Services -->
						<xsl:element name="STELRCSPLSER">
							<xsl:value-of select="StudentsEligibleSES"/>
						</xsl:element>
					</xsl:if>

					<xsl:if test="StudentsOfferedSES">
						<!-- DG612 – Supplemental Services – Offered -->
						<xsl:element name="STOFRDSPLSER">
							<xsl:value-of select="StudentsOfferedSES"/>
						</xsl:element>
					</xsl:if>

					<!--<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:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2006. Progress Software Corporation. All rights reserved.
<metaInformation>
<scenarios ><scenario default="no" name="SEA" userelativepaths="yes" externalpreview="no" url="TestFiles\x102_sea.xml" htmlbaseurl="" outputurl="TestFiles\transformed\x102_sea.xml" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="yes" validator="internal" customvalidator="" ><validatorSchema value="..\LegacyXSD\x102_sea_nclb_end_status_v3.xsd"/></scenario><scenario default="no" name="LEA" userelativepaths="yes" externalpreview="no" url="TestFiles\x102_lea.xml" htmlbaseurl="" outputurl="TestFiles\transformed\x102_lea.xml" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="yes" validator="internal" customvalidator="" ><validatorSchema value="..\LegacyXSD\x102_lea_nclb_end_status_v3.xsd"/></scenario><scenario default="yes" name="School" userelativepaths="yes" externalpreview="no" url="TestFiles\x102_school.xml" htmlbaseurl="" outputurl="TestFiles\transformed\x102_school.xml" processortype="internal" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml="" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="yes" validator="internal" customvalidator="" ><validatorSchema value="..\LegacyXSD\x102_school_nclb_end_status_v3.xsd"/></scenario></scenarios><MapperMetaTag><MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/><MapperBlockPosition></MapperBlockPosition><TemplateContext></TemplateContext><MapperFilter side="source"></MapperFilter></MapperMetaTag>
</metaInformation>
-->
