2 # Tests reading of ISO2709 and checks that we get identical MARCXML
4 # Reads marc?.marc files , Generates marc*.xml files
5 # If Libxml2 is present, also turbomarc*xml.
6 # as well as reverse transformation from *marc*.xml files are parsed again..
11 ../util/yaz-marcdump -i marcxml >/dev/null 2>&1
12 if test $? = "3"; then
16 ../util/yaz-marcdump -o xml,marcxml >/dev/null 2>&1
17 if test $? = "4"; then
25 for f in ${srcdir}/marc[0-9].marc; do
26 fb=`basename ${f} .marc`
27 CHR=`cat ${srcdir}/${fb}.chr`
28 NEW=${PREFIX}${fb}.new.xml
29 OLD=${srcdir}/${PREFIX}${fb}.xml
30 DIFF=`basename ${f}`.diff
31 #echo "../util/yaz-marcdump -f $CHR -t utf-8 -i marc -o ${OUTPUT_FORMAT} $f > $NEW"
32 ../util/yaz-marcdump -f $CHR -t utf-8 -i marc -o ${OUTPUT_FORMAT} $f > $NEW
33 if test $? != "0"; then
34 echo "$f: yaz-marcdump returned error"
36 elif test -f $OLD; then
37 if diff $OLD $NEW >$DIFF; then
41 echo "$f: $NEW and $OLD differ"
45 echo "$f: Making test result $OLD for the first time"
46 if test -x /usr/bin/xmllint; then
47 if xmllint --noout $NEW >out 2>stderr; then
48 echo "$f: $NEW is well-formed"
51 echo "$f: $NEW not well-formed"
55 echo "xmllint not found. install libxml2-utils"
60 if test -z "$noxml"; then
63 # compare with original (binary) marc record.
65 NEW=`basename ${f}`.new.marc
66 DIFF=`basename ${f}`.diff
67 #echo "../util/yaz-marcdump -f utf-8 -t utf-8 -i ${REVERT_FORMAT} -o marc $f > $NEW"
68 ../util/yaz-marcdump -f utf-8 -t utf-8 -i ${REVERT_FORMAT} -o marc $f > $NEW
69 if test $? != "0"; then
70 echo "Failed decode of $f"
72 elif test -f $OLD; then
73 if diff $OLD $NEW >$DIFF; then
77 echo "$f: $NEW and $OLD Differ"
81 echo "$f: Making test result $OLD for the first time"
85 REVERT=`basename ${f}`.marc.revert
86 #../util/yaz-marcdump -f utf-8 -t $CHR -i ${REVERT_FORMAT} -o marc $f > $REVERT
87 #hexdump -cx $REVERT > $REVERT.hex
88 #hexdump -cx $ORIGINAL > $ORIGINAL.hex
89 #diff $REVERT.hex $ORIGINAL.hex > $REVERT.diff
95 binmarc_convert "marcxml" "marcxml" ""
96 echo "binmarc -> marcxml: $?"
99 if test -z "$noxmlwrite"; then
100 binmarc_convert "xml,marcxml" "marcxml" "xml2"
101 echo "binmarc -> marcxml(libxml2): $?"
104 binmarc_convert "turbomarc" "turbomarc" "t"
105 echo "binmarc -> turbomarc: $?"
107 if test -z "$noxmlwrite"; then
108 binmarc_convert "xml,turbomarc" "turbomarc" "xml2t"
109 echo "binmarc -> turbomarc(libxml2): $?"