summaryrefslogtreecommitdiff
path: root/foaf/turtle2rdf.sh
blob: 9a87229dd8b6b2aca54f359106500273a9b4b08f (plain)
  1. #!/bin/sh
  2. set -e
  3. ttlfile="$1"
  4. xmlfile="${2:-$(basename "$ttlfile" .ttl).rdf}"
  5. exit1() {
  6. echo "ERROR: $1"
  7. exit 1
  8. }
  9. [ -e "$ttlfile" ] || exit1 "Turtle file \"$ttlfile\" does not exist."
  10. [ ! -e "$xmlfile" ] || exit1 "RDF/XML file \"$xmlfile\" already exists."
  11. base="$(perl -ne '/^\@base\s+<(http.+)>/ and print $1 and exit;' "$ttlfile")" || true
  12. rapper ${base:+-I "$base"} -i turtle -o rdfxml-abbrev "$ttlfile" > "$xmlfile"