<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <!-- Author: Ed Calhoun - AEM Corporation -->
  <!-- Version: 2.0 -->

  <xsl:include href="pbdmi_common_2.xsl"/>

  <xsl:output indent="yes"/>

  <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>

		<!--loop through agency elements-->
		<xsl:for-each select="Agency">
			<!--<AGENCY FIPSSTATECODE="01" STATEAGENCYIDNUMBER="01" >-->
			<xsl:element name="AGENCY">
				<xsl:attribute name="FIPSSTATECODE">
					<xsl:value-of select="FipsStateCode"/>
				</xsl:attribute>
				<xsl:attribute name="STATEAGENCYIDNUMBER">
					<xsl:value-of select="StateAgencyIdNumber"/>
				</xsl:attribute>
					
				<!--loop through MEMBER child elements-->
				<xsl:for-each select="Membership">
					<!--<TABLETYPE TYPEABBRV="MEMBER" TOTALINDICATOR="N">-->
					<xsl:element name="TABLETYPE">
						<xsl:attribute name="TYPEABBRV">MEMBER</xsl:attribute>
						<xsl:attribute name="TOTALINDICATOR">
							<xsl:value-of select="TotalIndicator"/>
						</xsl:attribute>

						<!--<CATEGORY TYPE="GRADELVMEM" VALUE="07"/>-->
						<xsl:apply-templates select="Grade">
						    <xsl:with-param name="value">
						       <xsl:value-of select="Grade"/>
						    </xsl:with-param>
						</xsl:apply-templates>

						<!--<CATEGORY TYPE="RACEETHNIC" VALUE="AS"/>-->
						<xsl:apply-templates select="RaceEthnic">
						    <xsl:with-param name="value">
						       <xsl:value-of select="RaceEthnic"/>
						    </xsl:with-param>
						</xsl:apply-templates>

						<!--<CATEGORY TYPE="GENDER" VALUE="F"/>-->
						<xsl:apply-templates select="Gender">
						    <xsl:with-param name="value">
						       <xsl:value-of select="Gender"/>
						    </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>
