Reputation: 69
I need to get the name of course that include in the module "Lenguajes de marcas y sistemas de gestión de información“.
I try to do but I don't know how to link with each other.
The result should be:
Administración de Sistemas Informáticos en Red
Desarrollo de Aplicaciones Web
I have developed this, Thanks for your help.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<ies>
<nombre>IES Abastos</nombre>
<web>http://www.iesabastos.org</web>
<ciclos>
<ciclo id="ASIR">
<nombre>Administración de Sistemas Informáticos en Red</nombre>
<grado>Superior</grado>
<decretoTitulo año="2009" />
</ciclo>
<ciclo id="DAW">
<nombre>Desarrollo de Aplicaciones Web</nombre>
<grado>Superior</grado>
<decretoTitulo año="2010" />
</ciclo>
<ciclo id="SMR">
<nombre>Sistemas Microinformáticos y Redes</nombre>
<grado>Medio</grado>
<decretoTitulo año="2008" />
</ciclo>
</ciclos>
<modulos>
<modulo id="0228">
<nombre>Aplicaciones web</nombre>
<curso>2</curso>
<horasSemanales>4</horasSemanales>
<ciclo>SMR</ciclo>
</modulo>
<modulo id="0372">
<nombre>Gestión de bases de datos</nombre>
<curso>1</curso>
<horasSemanales>5</horasSemanales>
<ciclo>ASIR</ciclo>
</modulo>
<modulo id="0373">
<nombre>Lenguajes de marcas y sistemas de gestión de información</nombre>
<curso>1</curso>
<horasSemanales>3</horasSemanales>
<ciclo>ASIR</ciclo>
<ciclo>DAW</ciclo>
</modulo>
<modulo id="0376">
<nombre>Implantación de aplicaciones web</nombre>
<curso>2</curso>
<horasSemanales>5</horasSemanales>
<ciclo>ASIR</ciclo>
</modulo>
</modulos>
</ies>
XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Ciclos</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Ciclo</th>
</tr>
<xsl:for-each select="ies/modulos/modulo[nombre = 'Lenguajes de marcas y sistemas de gestión de información']">
<xsl:for-each select="ciclo">
<tr>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Result
<html>
<body>
<h2>Ciclos</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Ciclo</th>
</tr>
<tr>
<td>ASIR</td>
</tr>
<tr>
<td>DAW</td>
</tr>
</table>
</body>
</html>
Upvotes: 1
Views: 82
Reputation: 29022
You can use an xsl:key
to get the nombre
of the ciclos
.
Add this key at the top-level
<xsl:key name="keyCiclos" match="ciclos/ciclo" use="@id" />
and then change the inner for-loop to
<tr>
<td><xsl:value-of select="key('keyCiclos',.)/nombre"/></td>
</tr>
Upvotes: 2
Reputation: 1882
Change this:
<xsl:for-each select="ciclo">
<tr>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:for-each>
into:
<xsl:for-each select="ciclo">
<tr>
<td><xsl:value-of select="/ies/ciclos/ciclo[@id=current()]/nombre"/></td>
</tr>
</xsl:for-each>
Do note: current()
function for reference current XSLT node context inside others XPath contexts. Also you could use xsl:key
instruction and key()
function.
Upvotes: 3