I want to transform this XML-Document (factbook.xml) to HTML using xQuery.
But the code (can be found under the XML below) doesn't work.
I get always the same Error: (I work with BaseX 9.4.2)
Error:
Stopped at C:/Program Files (x86)/BaseX/etc/file2, 9/6:
[XPST0003] Expecting '}', found '{'.
I don't understand why I'm always getting the same error, all brackets are closed.
This is my XML-file: (Part)
<mondial>
<continent id="f0_119" name="Europe"/>
<continent id="f0_123" name="Asia"/>
...
<country id="f0_136" name="Albania"
capital="f0_1461" population="3249136" total_area="28750">
<city id="f0_1461" country="f0_136">
<name>Tirane</name>
<population>192000</population>
</city>
...
<encompassed continent="f0_119" percentage="100"/>
</country>
<country id="f0_149" name="Austria"
capital="f0_1467" population="8023244" total_area="83850">
<province id="f0_17448" name="Upper Austria"
capital="f0_2267" population="1373000">
<city id="f0_2267">
<name>Linz</name>
<population>203000</population>
</city>
</province>
<province id="f0_17447" name="Vienna"
capital="f0_1467" population="1583000">
<city id="f0_1467">
<name>Vienna</name>
<population>1583000</population>
</city>
</province>
...
<encompassed continent="f0_119" percentage="100"/>
</country>
...
<country id="f0_670" name="Turkey"
capital="f0_1797" population="62484480" total_area="780580">
<province id="f0_19040" name="Ankara"
capital="f0_1797" population="3236626">
<city id="f0_1797">
<name>Ankara</name>
<population>2782200</population>
</city>
</province>
...
<encompassed continent="f0_119" percentage="32"/>
<encompassed continent="f0_123" percentage="68"/>
</country>
</mondial>
This is my xQuery-Code:
let $db := /mondial
let $html :=
<html>
<body>
{
for $cont in $db/continent
order by $cont/@name
return <h1>""{$cont/@name}</h1>
{
for $coun in $db/country
order by $coun/@name
where $cont/@id = $count//encompassed/@continent
return <p>
<h2>{coun/@name}</h2>
<b>Capital:</b>
{
for $cap in $coun//city
where $coun/@capital = $cap/@id
return $cap/name
}
<b>Total Area "in" {$cont/@name}:</b>
{
for $area in $coun//encompassed[@continent = $cont/@id]/percentage
return data($coun/@total_area) * ($area div 100)
}
</p>
}
} </body> </html>
return $html
Thanks in advance for your help