I made this XQuery query but it doesn't work, and I don't know why. My XML is like this :
<entries xmlns="http://ref.otcnice.com/webservice/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:SchemaLocation="http://ref.otcnice.com/webservice/entries.xsd">
<entry>
<ID>1021</ID>
<name_fr>AC BY MARRIOTT NICE</name_fr>
<standings_levels>
<standings_level>1 étoiles</standings_level>
</standings_levels>
<tariffs>
<tariff>
<name>Chambre simple</name>
<min>120</min>
</tariff>
</tariffs>
</entry>
</entries>
And I want to make an avg on 'min' because I have a lot of other entry like this, so I made this :
let $hotel := doc('data/entries_hotels.xml')/entries/entry where $hotel/standings_levels/standings_level = '1 étoile'
return
let $prixUneEtoile := avg($hotel/tariffs/tariff/min)
return
<data>
<y>{$prixUneEtoile}</y>
</data>
The problem is the While doesn't work, and the avg is made on all entries and not only entries with '1 étoile'
I have tried this : let $hotel := doc('data/entries_hotels.xml')/entries/entry where $hotel/standings_levels/standings_level[text() eq '1 étoiles']
and the same problem appears.
I don't understand where is the problem.
Any Help?
Thanks