blob: 99cdc57bda54d835139998997bfc134100132456 (
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#!/bin/bash
usage() {
echo "Usage:" >&2
echo " $0 input-file.xml [workspace.dat]" >&2
exit 101
}
if test $# -lt 1 -o $# -gt 2; then
usage
fi
INPUT="$1"
if test ! -f "$INPUT"; then
echo "$INPUT: not found" >&2
usage
fi
if test "${INPUT%.xml}" != "$INPUT"; then
BASE="${INPUT%.xml}"
INPUT1="$INPUT"
else
echo "$INPUT: not xml" >&2
usage
fi
WORKSPACE="$2"
if test -n "$WORKSPACE"; then
if test ! -f "$WORKSPACE"; then
echo "$WORKSPACE: not found" >&2
usage
fi
if test "${WORKSPACE%.dat}" = "$WORKSPACE"; then
echo "$WORKSPACE: not dat" >&2
usage
fi
fi
CONTEXT=""
set -e
TMPFILE2="$(mktemp -t XXXXXX.xml)"
trap "rm -f $TMPFILE2" 0 1 2 15
rm -f "$BASE-"*.xml
oldrv=100
echo "Running Xcos/XmlParser.py $INPUT1"
Xcos/XmlParser.py "$INPUT1" && rv=$? || rv=$?
if ((rv >= oldrv)); then
echo "ERROR: $rv >= $oldrv" >&2
exit 102
fi
while test $rv -gt 0; do
oldrv=$rv
INPUT1="$BASE-$rv.xml"
xmllint --format "$INPUT1" >"$TMPFILE2"
cp -f "$TMPFILE2" "$INPUT1"
echo "Running Xcos/XmlParser.py $INPUT1"
Xcos/XmlParser.py "$INPUT1" && rv=$? || rv=$?
if ((rv >= oldrv)); then
echo "ERROR: $rv >= $oldrv" >&2
exit 102
fi
done
INPUT1="$BASE-$rv.xml"
xmllint --format "$INPUT1" >"$TMPFILE2"
cp -f "$TMPFILE2" "$INPUT1"
echo "Running Xcos/MxGraphParser.py $INPUT1 $WORKSPACE $CONTEXT"
Xcos/MxGraphParser.py "$INPUT1" "$WORKSPACE" "$CONTEXT"
INPUT1="$BASE.xcos"
echo "Created $INPUT1"
exit 0
|