I want to make a table in which I'm going to make an unordered list with the names of the hotels and the number of stars like this:
Hoteles
· Macuya (4)
· Fuentevino (2)
· Tresarazos (3)
Using this code:
<vacaciones>
<destino identificador="p023">
<estancias>
<hotel estrellas="4">Macuya</hotel>
</estancias>
</destino>
<destino identificador="m036">
<estancias>
<hotel estrellas="2">Fuentevino</hotel>
<hotel estrellas="3">Tresarazos</hotel>
</estancias>
</destino>
</vacaciones>
I tried this in eXide, but the names come together without spaces and the number of stars isn't shown:
<table>
<tr>
<th>Hoteles</th>
</tr>
{for $i in doc("/db/exercise/vacaciones.xml")//destino
return
<tr>
<td>
<ul>
<li>
{$i/estancias/hotel/text()} ({$i/estancias/hotel/@estrellas/text()})
</li>
</ul>
</td>
</tr>
}
</table>
I think you want to nest a further for .. return ..
expression (and correct the attribute selection although I have simply used the ||
string concatenation operator):
<table>
<tr>
<th>Hoteles</th>
</tr>
{
for $i in //destino
return
<tr>
<td>
<ul>
{
for $hotel in $i/estancias/hotel
return
<li>
{
$hotel || '(' || $hotel/@estrellas || ')'
}
</li>
}
</ul>
</td>
</tr>
}
</table>