[XPATH].Ej5.Ejercicio xpath factbook.xml (continentes) (blogger)
CONSULTA 1
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 1 -->
<h1>Consulta 1</h1>
<h2>Nombre de los continentes</h2>
<ul>
{
for $M in /mondial
for $C in $M/continent/@name/data()
return
<li>{$C}</li>
}
</ul>
</body>
</html>
CONSULTA 2
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 2 -->
<h1>Consulta 2</h1>
<h2>Nombre del río que ocupa la décima posición</h2>
<ul>
{
for $M in /mondial
for $R in $M//river/@name/data()
return
<li>{$R}</li>
}
</ul>
</body>
</html>
CONSULTA 3
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 3 -->
<h1>Consulta 3</h1>
<h2>Nombre de la isla cuya superficie es 13935</h2>
<ul>
{
for $M in /mondial
for $I in $M/island[@area="13935"]/@name/data()
return
<li>{$I}</li>
}
</ul>
</body>
</html>
CONSULTA 4
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 4 -->
<h1>Consulta 4</h1>
<h2>Nombre de los países que no tienen frontera con otros países (luego son islas)</h2>
<ul>
{
for $M in /mondial
for $I in $M/island/@name/data()
return
<li>{$I}</li>
}
</ul>
</body>
</html>
CONSULTA 5
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 5 -->
<h1>Consulta 5</h1>
<h2>Nombre de organizaciones que tengan más de 5 miembros</h2>
<ul>
{
for $M in //mondial
for $O in $M/organization[count(members)>5]/@name/data()
return
<li>{$O}</li>
}
</ul>
</body>
</html>
CONSULTA 6
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 6 -->
<h1>Consulta 6</h1>
<h2>Nodos descendientes de la provincia de nombre Madrid, descendiente del país Spain</h2>
<ul>
{
for $S in //country[name="Spain"]
for $M in $S/province[@name="Madrid"]
return
<li>{$M}</li>
}
</ul>
</body>
</html>
CONSULTA 7
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 7 -->
<h1>Consulta 7</h1>
<h2>Nombre y gobierno de los países cuya población sea menor que 1.000.000</h2>
{
for $C in //city[population<1000000]
for $N in $C/name/text()
for $P in $C/population/text()
return
<ul>
<li>{$N}</li>
<li>{$P}</li>
</ul>
}
</body>
</html>
CONSULTA 8
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 8 -->
<h1>Consulta 8</h1>
<h2>Nombre de los países que tengan una ciudad llamada Cordoba</h2>
<ul>
{
for $C in //city[name="Cordoba"]
for $P in $C/../../@name/data()
return
<li>{$P}</li>
}
</ul>
</body>
</html>
CONSULTA 9
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 9 -->
<h1>Consulta 9</h1>
<h2>Nombre de los lagos ubicados en Russia</h2>
<ul>
{
for $ID in //country[name="Russia"]/@id
for $NOMBRE in //lake/located[@country="f0_358"]/../@name/data()
return
<li>{$NOMBRE}</li>
}
</ul>
</body>
</html>
CONSULTA 10
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<!-- Esto es la Consulta 10 -->
<h1>Consulta 10</h1>
<h2>Nombre de los países cuyo territorio está en Europe</h2>
<ul>
{
for $ID in //continent[@name="Europe"]/@id
for $NOMBRE in //@continent[.="f0_119"]/../../name/text()
return
<li>{$NOMBRE}</li>
}
</ul>
</body>
</html>










No hay comentarios:
Publicar un comentario