2015-04-16 88 views
0

我已經在倫敦的一個車站 - 沃倫街車站,尤斯頓,我必須返回與沃倫街站有相同自行車可用性的車站,並且至少許多空文檔。我寫了一個小查詢返回沃倫街站和它的可用性,但是如何返回與我的沃倫街站有相同可用性/許多空碼頭的所有其他站點的列表?如何添加where條款或約束條件到我的xquery

<results>{ for $b in doc("http://tinyurl.com/TFLStationsXMLFile") 
    /stations/station 
    where $b/name = "Warren Street Station, Euston" 
    order by $b 
    return  
    <result>  
    { $b/name }   
    { $b/nb_bikes } 
    { $b/nb_empty_docks } 
    </result>} 
    </results> 

回答

0
let $warren-station := doc("http://tinyurl.com/TFLStationsXMLFile")/stations/station[name eq "Warren Street Station, Euston"] 
return 
<results>{ for $b in doc("http://tinyurl.com/TFLStationsXMLFile")/stations/station  
    where $b/nb_bikes eq $warren-station/nb_bikes and $b/nb_empty_docks ge $warren-station/nb_empty_docks 
    order by $b 
    return  
    <result>  
    { $b/name }   
    { $b/nb_bikes } 
    { $b/nb_empty_docks } 
    </result>} 
</results> 

類似的東西。 HTH!