From: Pierre Choffet Date: Thu, 23 Dec 2021 21:58:56 +0000 (-0500) Subject: Add Wdef file generator X-Git-Url: https://git.choffet.net/?a=commitdiff_plain;h=4cc348a1daae948bffbf1c5ca95d3eefa21464ea;p=wmo_to_wikidata.git Add Wdef file generator After verifying cleaned stations.xml file validity, update.sh now writes the corresponding wdef on standard output. --- diff --git a/README b/README index 9538894..d6ca8ff 100644 --- a/README +++ b/README @@ -1,6 +1,9 @@ wmo_to_wikidata - Import World Meteorological Organization weather stations metadata into Wikidata. +Repository: https://git.choffet.net/?p=wmo_to_wikidata.git + + This repository contains a set of scripts that download, clean, verify, compare WMO stations metadata before importing it into Wikidata as needed. @@ -25,4 +28,4 @@ prepackaged for most GNU/Linux distros. The repositories contains the following tools: - update.sh Ensure WMO stations cache is up to date, convert original JSON into XML, - clean and validate data. + clean, validate data and generate a new valid WDEF file. diff --git a/hardcoded/territories.xml b/hardcoded/territories.xml new file mode 100644 index 0000000..46607fc --- /dev/null +++ b/hardcoded/territories.xml @@ -0,0 +1,221 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/update.sh b/update.sh index dd6df55..353f3de 100755 --- a/update.sh +++ b/update.sh @@ -15,7 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -set -euxo pipefail +set -euo pipefail # Script cache dir CACHE_DIR=${CACHE_DIR:-"${HOME}/.cache/wmo_to_wikidata/"} @@ -62,4 +62,11 @@ ensureStationsCache xmlstarlet tr -s xslts/stations_clean.xslt "${STATIONS_CACHE_PATH}" | xmlstarlet fo -t > "${STATIONS_CLEANED_CACHE_PATH}" # Validate stations cache -xmlstarlet val -e -s schemas/stations.xsd "${STATIONS_CLEANED_CACHE_PATH}" +xmlstarlet val -e -q -s schemas/stations.xsd "${STATIONS_CLEANED_CACHE_PATH}" + +# Generate, validate, echo and delete WDEF file +WDEF_PATH=$(mktemp) +xmlstarlet tr -s xslts/generate_wdef.xslt "${STATIONS_CLEANED_CACHE_PATH}" > "${WDEF_PATH}" +xmlstarlet val -e -q -s wdef_schemas/wdef.xsd "${WDEF_PATH}" +cat "${WDEF_PATH}" +rm "${WDEF_PATH}" diff --git a/xslts/generate_wdef.xslt b/xslts/generate_wdef.xslt new file mode 100644 index 0000000..379343d --- /dev/null +++ b/xslts/generate_wdef.xslt @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ?E + + + + + + + + + + + + + + ?P31- + + + + + ?V1-P31- + + + Q190107 + + + + + + + + + ?P625- + + + + + ?V1-P625- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Q2 + + + + + + + + + + + ?P4136- + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + weather station + + + + + + + + station météorologique + + + + + + + + + + + + + + + + + + + + + + + + + ?P17- + + + + + ?V1-P17- + + + + + + + + + + + + + + + + ?P2044- + + + + + ?V1-P2044- + + + + + + + + + + + + + + + ?V + + -P17- + + + + + + + + + + + + + + P729 + + + P730 + + + + + + + + + + + + 9 + + + + 10 + + + + 11 + + + + + + + + + + + + + + + + + 01 + + + + + + + + + + + + + + + + + + + + + + + + + + ? + + - + + + + + ?V + + - + + - + + + + + + + + + + - + + - + + T12:00:00Z + + + + + + + + + ABCDEFGHIJKLMNOPQRSTUVWXYZ + abcdefghijklmnopqrstuvwxyz + + + + + + + + + + + + + + + + + + + + + + 1 + + + 0.1 + + + 0.01 + + + 0.001 + + + +