Fix mergelist.xq script
authorLuciano Montanaro <mikelima@cirulla.net>
Sun, 15 Jan 2012 21:31:55 +0000 (22:31 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Sun, 15 Jan 2012 21:31:55 +0000 (22:31 +0100)
The previous version worked only as long as there was a single code...
ehm..

application/resources/stations/mergelist.xq

index 6a68d34..3df28a2 100644 (file)
@@ -1,25 +1,13 @@
 <stations>
 {
-for $doc in ('stations.qpl')
-for $station in doc($doc)//station, 
-    $stationcode in doc('stationcodes.qpl')//station[name = $station/name]
+for $station in doc('stationpositions.qpl')//station
 return
 <station>
-{$station/name}
-{$station/pos}
-{$stationcode/code}
-</station>
-}
-{
-for $doc in ('stations.qpl')
-for $station in doc($doc)//station
-let $stationcode := doc('stationcodes.qpl')//station[name != $station/name]
-where
-$station/name != $stationcode/name
-return
-<station>
-{$station/name}
-{$station/pos}
+{ $station/name }
+{ $station/pos }
+{for $stationcode in doc('stationcodes.qpl')//station
+where $stationcode/name = $station/name
+return $stationcode/code}
 </station>
 }
 </stations>