<!-- Listado para finretorno con XPath 1.0 -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/xhtml1/strict" xmlns:a="http://www.catastro.meh.es/" exclude-result-prefixes="a">
	<xsl:output method="html" encoding="ISO-8859-4"/>
	<xsl:decimal-format name="decimales" decimal-separator="," grouping-separator="." digit="#" infinity="0,00" NaN="0,00"/>
	<xsl:decimal-format name="enteros" grouping-separator="." decimal-separator="," digit="#" infinity="0" NaN="0"/>
	<xsl:template match="/">
		<html>
			<head>
				<style type="text/css">
					table{font: normal 9pt verdana}
					table.head{border-left-width: 1; border-rigth-width: 1; border-bottom-width: 1; border-top-width: 1; text-align: center; border-color: rgb(130,136,255)}
					tr.head{font-size: 110%;background-color: rgb(130,136,255)}
					tr#LineaCab{font-weight: 900; color: white; background-color: rgb(130,136,255); border-color: rgb(130,136,255)}
					tr#LineaExpdte{font-weight: 100; font-size: 90%; color: rgb(220,226,255);background-color: rgb(130,136,255); border-color: rgb(130,136,255)}
					th{padding: 0.5em}
					#SinTitulos{background-color: rgb(130,136,255)}
										
					tr.cuerpo{font-size: 80%; vertical-align: top}
					tr#Expdte{height: 2.5em; vertical-align: middle}
					td#DatosExpdte{background-color: rgb(230,236,255); font-weight: bold; text-align: left; padding: 1em}
				</style>
				<title>Resumen del fichero FIN retorno</title>
			</head>
			<body>
				<table class="head" align="center">
					<!-- Titulos de las columnas de la tabla -->
					<tr class="head" id="LineaCab">
						<th colspan="5">Resumen del fichero FIN retorno</th>
					</tr>
					<tr class="head" id="LineaCab">
						<th colspan="2">Expediente</th>
						<th colspan="1">Tipo</th>
						<th colspan="1">Estado</th>
						<th colspan="1">Parcela Catastral / <br/>Referencia Catastral</th>
					</tr>
					<tr class="head" id="LineaExpdte">
						<th colspan="1">Gerencia</th>
						<th colspan="1">Origen</th>
						<th id="SinTitulos" colspan="3"/>
					</tr>
					<tr class="head">
						<th id="SinTitulos" colspan="5" style="height: 5px"/>
					</tr>
					<!--tr class="head"  id="LineaExpdte">
						<th colspan="8" style="height: 20px">
							<xsl:value-of select=".//a:fincacs/a:fincas/a:dt/a:nm[position()=1]"/>
							<xsl:text> (</xsl:text><xsl:value-of select=".//a:fincacs/a:fincas/a:dt/a:np[position()=1]"/><xsl:text>)</xsl:text>
						</th>
					</tr>
					
					<xsl:variable name="seqmunis" select=".//a:fincacs//a:fincas//a:dt//a:nm"/>
					<xsl:variable name="seqprovis" select=".//a:fincacs//a:fincas//a:dt//a:np"/-->
					<xsl:for-each select=".//a:udsa/a:exp">
						<!--xsl:variable name="poseq1" select="position()"/>
						<xsl:variable name="poseq_1" select="$poseq1 - 1"/>
						<xsl:variable name="munix1" select="$seqmunis[$poseq1]"/>
						<xsl:variable name="munix_1" select="$seqmunis[$poseq_1]"/>
						<xsl:variable name="provix1" select="$seqprovis[$poseq1]"/>
						<xsl:variable name="provix_1" select="$seqprovis[$poseq_1]"/>
						<xsl:if test="$munix1 != $munix_1 or ($munix1 = $munix_1 and $provix1 != $provix_1)">
							<tr class="head"  id="LineaExpdte">
								<th colspan="15" style="height: 20px"><xsl:value-of select="concat($munix1,' (',$provix1,')')"/></th>
							</tr>
						</xsl:if-->
						<!-- Datos de las columnas de la tabla. Origen: fichero xml de finretorno a cargar -->
						<!-- Datos de cada Expediente -->
						<tr class="cuerpo" id="Expdte">
							<!-- Identificacion del Expediente -->
							<!-- Datos del Expediente Origen -->
							<td id="DatosExpdte" colspan="1" style="text-align: right">
								<xsl:value-of select="format-number(number(./a:expec/a:rexpec), '###0', 'enteros')"/>
								<xsl:text>.</xsl:text>
								<xsl:apply-templates select="./a:expec/a:eoa"/>
								<xsl:text>/</xsl:text>
								<xsl:apply-templates select="./a:expec/a:aexpec"/>
							</td>
							<!-- Datos del Expediente de la Gerencia -->
							<td id="DatosExpdte" colspan="1" style="text-align: right">
								<xsl:if test="./a:expg">
									<xsl:value-of select="format-number(number(./a:expg/a:rexpg), '###0', 'enteros')"/>
									<xsl:text>.</xsl:text>
									<xsl:apply-templates select="./a:expg/a:ero"/>
									<xsl:text>/</xsl:text>
									<xsl:apply-templates select="./a:expg/a:aexpg"/>
								</xsl:if>
							</td>
							<!-- Tipo de Expediente -->
							<td id="DatosExpdte" colspan="1">
								<xsl:apply-templates select="./a:texp"/>
							</td>
							<td id="DatosExpdte" colspan="1">
								<xsl:choose>
									<xsl:when test="./a:tint = 'F'">
										<xsl:text>FINALIZADO</xsl:text>
									</xsl:when>
									<xsl:when test="./a:tint = 'R'">
										<xsl:text>NO FINALIZADO</xsl:text>
									</xsl:when>
								</xsl:choose>
							</td>
							<!-- Parcela Catastral -->
							<td id="DatosExpdte" colspan="1">
								<xsl:for-each select="../a:lelems//a:fincacs/a:fincas">
									<xsl:apply-templates select=".//a:pc1"/>
									<xsl:apply-templates select=".//a:pc2"/>
									<br/>
								</xsl:for-each>
								<!-- Si no hay fincas, muestra los datos de bienes inmuebles -->
								<xsl:if test="not(../a:lelems//a:fincacs/a:fincas)">
									<xsl:for-each select="../a:lelems//a:lbics/a:bij">
										<xsl:apply-templates select="./a:bi/a:idcat//a:pc1"/>
										<xsl:apply-templates select="./a:bi/a:idcat//a:pc2"/><xsl:text> </xsl:text>
										<xsl:apply-templates select="./a:bi/a:idcat//a:car"/><xsl:text> </xsl:text>
										<xsl:apply-templates select="./a:bi/a:idcat//a:cc1"/><xsl:text> </xsl:text>
										<xsl:apply-templates select="./a:bi/a:idcat//a:cc2"/>
										<br/>
									</xsl:for-each>
								</xsl:if>
							</td>
						</tr>
					</xsl:for-each>
				</table>
			</body>
		</html>
	</xsl:template>
</xsl:stylesheet>
