<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" 
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
		xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
		xsi:noNamespaceSchemaLocation="c041-9-0.xsd">
		
    <!-- Version: 9.0 -->
	<!-- Created: July 2012 -->
	
	<xsl:include href="pbdmi-common-9.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">
                <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>

                    <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>

                    <!--loop through GRADRT child elements-->
                    <xsl:for-each select="GraduationRate">

                        <xsl:element name="TABLETYPE">
                            <xsl:attribute name="TYPEABBRV">GRADRT</xsl:attribute>
                            <xsl:attribute name="TOTALINDICATOR">
                                <xsl:value-of select="TotalIndicator"/>
                            </xsl:attribute>

                            <xsl:apply-templates select="MajorRacialEthnic">
                                <xsl:with-param name="value">
                                    <xsl:value-of select="MajorRacialEthnic"/>
                                </xsl:with-param>
                            </xsl:apply-templates>

                            <xsl:apply-templates select="Sex">
                                <xsl:with-param name="value">
                                    <xsl:value-of select="Sex"/>
                                </xsl:with-param>
                            </xsl:apply-templates>

                            <xsl:apply-templates select="LepStatusOnly">
                                <xsl:with-param name="value">
                                    <xsl:value-of select="LepStatusOnly"/>
                                </xsl:with-param>
                            </xsl:apply-templates>

                            <xsl:apply-templates select="DisabilityStatusOnly">
                                <xsl:with-param name="value">
                                    <xsl:value-of select="DisabilityStatusOnly"/>
                                </xsl:with-param>
                            </xsl:apply-templates>

                            <xsl:apply-templates select="EconomicDisadvantagedStatus">
                                <xsl:with-param name="value">
                                    <xsl:value-of select="EconomicDisadvantagedStatus"/>
                                </xsl:with-param>
                            </xsl:apply-templates>

                            <xsl:apply-templates select="MigrantStatus">
                                <xsl:with-param name="value">
                                    <xsl:value-of select="MigrantStatus"/>
                                </xsl:with-param>
                            </xsl:apply-templates>

                            <xsl:apply-templates select="Amount">
                                <xsl:with-param name="value">
                                    <xsl:value-of select="Amount"/>
                                </xsl:with-param>
                            </xsl:apply-templates>

                            <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>
