Added xmlpattern script to merge station codes
authorLuciano Montanaro <mikelima@cirulla.net>
Sun, 15 Jan 2012 19:42:16 +0000 (20:42 +0100)
committerLuciano Montanaro <mikelima@cirulla.net>
Sun, 15 Jan 2012 19:42:16 +0000 (20:42 +0100)
application/resources/stations/mergelist.xq [new file with mode: 0644]
application/resources/stations/stationcodes.qpl [new file with mode: 0644]

diff --git a/application/resources/stations/mergelist.xq b/application/resources/stations/mergelist.xq
new file mode 100644 (file)
index 0000000..6a68d34
--- /dev/null
@@ -0,0 +1,25 @@
+<stations>
+{
+for $doc in ('stations.qpl')
+for $station in doc($doc)//station, 
+    $stationcode in doc('stationcodes.qpl')//station[name = $station/name]
+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>
+}
+</stations>
diff --git a/application/resources/stations/stationcodes.qpl b/application/resources/stations/stationcodes.qpl
new file mode 100644 (file)
index 0000000..70f5c00
--- /dev/null
@@ -0,0 +1,19 @@
+<stations>
+    <station>
+        <name>Genova Piazza Principe sotterranea</name>
+       <code>S04701</code>
+    </station>
+    <station>
+        <name>Genova San Biagio</name>
+       <code>S04222</code>
+    </station>
+    <station>
+        <name>Genova Voltri</name>
+       <code>S04534</code>
+    </station>
+    <station>
+        <name>Torino Porta Nuova</name>
+        <code>S00219</code>
+    </station>
+</stations>
+