-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgramps2rdf.sh
57 lines (50 loc) · 1.26 KB
/
gramps2rdf.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
usage="$(basename "$0") [-h] [-i filename] -- convert a gramps XML document into RDF
where:
-h show this help text
-i input document
-f force (erase existing output document)
-b base uri for resources"
CONFIG="$(pwd)/config"
if test -f "$CONFIG"; then
echo "Using $CONFIG config file."
else
echo "file $CONFIG does not exist"
echo "Please read $(pwd)/config.CHANGEME"
exit
fi
source config
while getopts ':hfbi:' option; do
case "$option" in
h) echo "$usage"
exit
;;
i) GRAMPS_XML=$OPTARG
;;
b) BASE=$OPTARG
;;
f) FORCE="True"
;;
:) printf "missing argument for -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
\?) printf "illegal option: -%s\n" "$OPTARG" >&2
echo "$usage" >&2
exit 1
;;
esac
done
FILE=${GRAMPS_XML##*/}
OUT=out/${FILE%%.*}.ttl
if test -f "$OUT"; then
echo "$OUT already exist..."
if [ -z $FORCE ]; then
echo " ...use -f to erase"
exit 1
else
echo " ... -f option provided: will be erased"
fi
fi
echo $OUT
java -jar $RML_JAR -m rml/gramps2rdf.ttl -m "<http://mapping.ex.com/myLogicalSource> <http://semweb.mmlab.be/ns/rml#source> \"$GRAMPS_XML\" ." -s "turtle" -o $OUT