diff options
author | Jonas Smedegaard <dr@jones.dk> | 2011-12-06 10:49:06 +0700 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2011-12-06 10:49:06 +0700 |
commit | 1d1e3f9cd50a4a513c128ffe449483e56196a52a (patch) | |
tree | a284a6c7c3f882bd3708c64f871e19f2e7881a1b /foaf | |
parent | 77eaef4627817d66fa04075bf641ce6fb96656e7 (diff) |
Add turtle2rdf.sh.
Diffstat (limited to 'foaf')
-rwxr-xr-x | foaf/turtle2rdf.sh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/foaf/turtle2rdf.sh b/foaf/turtle2rdf.sh new file mode 100755 index 0000000..9a87229 --- /dev/null +++ b/foaf/turtle2rdf.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +set -e + +ttlfile="$1" +xmlfile="${2:-$(basename "$ttlfile" .ttl).rdf}" + +exit1() { + echo "ERROR: $1" + exit 1 +} + +[ -e "$ttlfile" ] || exit1 "Turtle file \"$ttlfile\" does not exist." +[ ! -e "$xmlfile" ] || exit1 "RDF/XML file \"$xmlfile\" already exists." + +base="$(perl -ne '/^\@base\s+<(http.+)>/ and print $1 and exit;' "$ttlfile")" || true +rapper ${base:+-I "$base"} -i turtle -o rdfxml-abbrev "$ttlfile" > "$xmlfile" |