<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:i="iTree" version="1.0">
    <xsl:import href="iped.xsl"/>
	<xsl:output method="html" encoding="UTF-8" indent="yes" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
		doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"/>

    <xsl:template match="/">
        <html>
            <head>
                <title>i-Tree Streets Data</title>
                <style>
                    .err {
                        background-color:#FF0000;
                        color:#FFFFFF;
                    }
                    th, td {
                        white-space:nowrap;
                        border:1px solid #000000;
                        padding:3px;
                    }
                    table {
                        border:0px;
                        border-collapse:collapse;
                    }
					pre {
						margin:0px;
						font-family:"sans-serif";
					}
                </style>
            </head>
            <body>
                <xsl:apply-templates/>
            </body>
        </html>
    </xsl:template>
     
    <xsl:template match="i:Inventory">
        <table cellspacing="0" cellpadding="0">
            <thead>
                <tr>
                    <th>Id</th>
                    <th>SpCode</th>
                    <th>DBH</th>
                    <th>Zone</th>
                    <th>StreetSeg</th>
                    <th>CityManaged</th>
                    <th>LandUse</th>
                    <th>SiteType</th>
                    <th>LocSite</th>
                    <th>LocNo</th>
                    <th>MtncRec</th>
                    <th>MtncTask</th>
                    <th>SwDamg</th>
                    <th>WireConflict</th>
                    <th>CondWood</th>
                    <th>CondLvs</th>
                    <th>OtherOne</th>
                    <th>OtherTwo</th>
                    <th>OtherThree</th>
                    <th>GPS_Lat</th>
                    <th>GPS_Lon</th>
                    <th>StreetId</th>
                    <th>StreetNumber</th>
                    <th>SurveyorId</th>
                    <th>SurveyDate</th>
                    <th>NoteThisTree</th>
                    <th>Comments</th>
                    <xsl:call-template name="IPED_HEADER"/>
                </tr>              
            </thead>
            <tbody>
                <xsl:apply-templates/>
            </tbody>
        </table>
    </xsl:template>
    
    <xsl:template match="i:Record">
        <tr>
            <td><xsl:value-of select="i:Id"/></td>
            <td><xsl:value-of select="i:SpCode"/></td>
            <td><xsl:value-of select="i:DBH"/></td>
            <td><xsl:value-of select="i:Zone"/></td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:StreetSeg">
                        <xsl:value-of select="i:StreetSeg"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:CityManaged">
                        <xsl:choose>
							<xsl:when test="i:CityManaged=0">No</xsl:when>
							<xsl:when test="i:CityManaged=1">Yes</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="i:CityManaged"/>
								<xsl:attribute name="class">err</xsl:attribute>
							</xsl:otherwise>
						</xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>No</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
				<xsl:choose>
					<xsl:when test="child::i:LandUse">
						<xsl:value-of select="i:LandUse"/>
					</xsl:when>
					<xsl:otherwise>0</xsl:otherwise>
				</xsl:choose>
			</td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:SiteType">
                        <xsl:value-of select="i:SiteType"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:LocSite">
                        <xsl:value-of select="i:LocSite"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:LocNo">
                        <xsl:value-of select="i:LocNo"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:MtncRec">
                        <xsl:value-of select="i:MtncRec"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:MtncTask">
                        <xsl:value-of select="i:MtncTask"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:SwDamg">
                        <xsl:value-of select="i:SwDamg"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:WireConflict">
                        <xsl:value-of select="i:WireConflict"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:CondWood">
                        <xsl:value-of select="i:CondWood"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::iCondLvs">
                        <xsl:value-of select="i:CondLvs"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:OtherOne">
                        <xsl:value-of select="i:OtherOne"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:OtherTwo">
                        <xsl:value-of select="i:OtherTwo"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:OtherThree">
                        <xsl:value-of select="i:OtherThree"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:if test="child::i:GPS_Lat">
                    <xsl:value-of select="i:GPS_Lat"/>
                </xsl:if>
            </td>
            <td>
                <xsl:if test="child::i:GPS_Lon">
                    <xsl:value-of select="i:GPS_Lon"/>
                </xsl:if>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:StreetId">
                        <xsl:value-of select="i:StreetId"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:StreetNumber">
                        <xsl:value-of select="i:StreetNumber"/>
                    </xsl:when>
                    <xsl:otherwise>0</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:if test="child::i:SurveyorId">
                    <xsl:value-of select="i:SurveyorId"/>
                </xsl:if>
            </td>
            <td>
                <xsl:if test="child::i:SurveyDate">
                    <xsl:value-of select="i:SurveyDate"/>
                </xsl:if>
            </td>
            <td>
                <xsl:choose>
                    <xsl:when test="child::i:NoteThisTree">
						<xsl:choose>
							<xsl:when test="i:NoteThisTree='true'">Yes</xsl:when>
							<xsl:when test="i:NoteThisTree='false'">No</xsl:when>
							<xsl:otherwise>
								<xsl:attribute name="class">err</xsl:attribute>
								<xsl:value-of select="i:NoteThisTree"/>
							</xsl:otherwise>
						</xsl:choose>
                    </xsl:when>
                    <xsl:otherwise>No</xsl:otherwise>
                </xsl:choose>
            </td>
            <td>
                <xsl:if test="child::i:Comments">
                    <pre><xsl:value-of select="i:Comments"/></pre>
                </xsl:if>
            </td>
			<xsl:call-template name="IPED_RECORD"/>
        </tr>       
    </xsl:template>
</xsl:stylesheet>

