summaryrefslogtreecommitdiffstats
path: root/scripts/rdfcompare
blob: 6430bf4c07f2ca9405e75f11b0186439d867be8b (plain)
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
#!/bin/sh
#
# Compare two RDF graphs
#
# Needs an external utility to do a true graph compare.
#


PROGRAM=`basename $0`

CMP=cmp
DIFF=diff

tmpdiff=/tmp/rdfcompare$$

if [ $# -lt 1 ] ; then
    echo "$PROGRAM: compare two RDF graphs for isomorphism" 1>&2
    echo "USAGE: $PROGRAM RDF-FILE-1 RDF-FILE-2" 1>&2
    echo "where both files are RDF graphs serialized as N-Triples" 1>&2
    exit 0
fi

# Try a simple compare first
$CMP $1 $2 2>&1
status=$?
if test $status -eq 0; then
  exit 0
fi

echo "$program: Doing an RDF graph compare" 1>&2

if test "X$NTC" != X; then
  $NTC $1 $2 > $tmpdiff 2>&1
  status=$?
  if test $status != 0; then
    $DIFF -u $1 $2
  fi
elif test "X$JENAROOT" != X; then
  RDFCOMPARE="$JENAROOT/bin/rdfcompare"

  $RDFCOMPARE $1 $2 N-TRIPLE N-TRIPLE
  status=$?
  if test $status != 0; then
    $DIFF -u $1 $2
  fi
else
  $DIFF -u $1 $2 > $tmpdiff
  status=$?
  if test $status != 0; then
    cat $tmpdiff
    rm $tmpdiff
  fi
fi

exit $status