Hi,
I have a long XML document like this :
<cities>
<city>
<name>Paris</name>
<zip>75000</zip>
<alt_names>
<name>paris</name>
</alt_names>
</city>
<city>
<name>Cesson-Sévigné</name>
<zip>35510</zip>
<alt_names>
<name>paris</name>
</alt_names>
</city>
</cities>
My XQuery is supposed to return the cities whose name begin with a few
letters contained in "$cityname". So I use this :
let $search := request:get-parameter("search","")
return
<cities>
{
for $city in
collection("cities")//city[starts-with(alt_names/name,$search)]
return
<city>
{$city/name}
{$city/zip}
</city>
}
</cities>
But there is a problem with the [starts-with(alt_names/name,$search)] part.
It seems that I cannot use the same tag name ("name") both in "city" and in
"alt_names". The error is :
[XPTY0004] No sequence (element name { ... }, element name { ... }) allowed.
1) Is this a bug?
2) What is the equivalent in BaseX to request:get-parameter, which works in
"eXist db" and affects the GET parameter (here "search") to the $search
variable?
Thank you for your help,
Regards,
Grégoire