/usr/bin/xmlrev is in xmldiff-xmlrev 0.6.10-2build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | #!/bin/bash
#
# (c) 2001-2004 Nicolas Chauvat <nicolas.chauvat@logilab.fr> - License is GPL
set -e
DIFF="xmldiff -x"
TMPFILE_S=$(mktemp /tmp/xmlrev.start.XXXXXX) || exit 1
TMPFILE_X=$(mktemp /tmp/xmlrev.dest.XXXXXX) || exit 1
TMPFILE_D=$(mktemp /tmp/xmlrev.xupdate.XXXXXX) || exit 1
TMPFILE_XSLT=$(mktemp /tmp/xmlrev.xslt.XXXXXX) || exit 1
TMPFILES="$TMPFILE_S $TMPFILE_X $TMPFILE_D $TMPFILE_XSLT"
function guess_doc_type() {
# $1 filepath
FT=`file -b -- "$1"`
case "$FT" in
*SGML*)
echo SGML
;;
*XML*)
echo XML
;;
*text*)
case "$1" in
*.xml|*.XML|*.xsl|*.XSL|*.xslt|*.XSLT)
echo XML
;;
esac
;;
esac
}
function sgml_to_xml() {
# $1 filepath
sgmlnorm "$1" > "$TMPFILE_S"
xmllint --sgml --nowarning "$TMPFILE_S" | grep -v "<!DOCTYPE"
}
function normalize() {
# $1 filepath
DT=`guess_doc_type "$1"`
case "$DT" in
SGML)
sgml_to_xml "$1" > "$TMPFILE_X"
echo $TMPFILE_X
;;
XML)
echo $1
;;
esac
}
function check_args(){
if [ -z "$1" ] || [ -z "$2" ]
then
usage
exit 1
fi
for filename in "$1" "$2"
do
if [ ! -e "$filename" ]
then
echo Error:
echo $filename not found
echo
usage
exit 2
fi
DOC=`normalize "$filename"`
if [ -z "$DOC" ]
then
echo Error: $filename is not an XML or SGML file
usage
exit 3
fi
done
}
function diff() {
check_args "$1" "$2"
DOC_OLD=`normalize "$1"`
DOC_NEW=`normalize "$2"`
$DIFF "$DOC_OLD" "$DOC_NEW" || true
}
function revision() {
check_args "$1" "$2"
DOC_OLD=`normalize "$1"`
DOC_NEW=`normalize "$2"`
$DIFF "$DOC_OLD" "$DOC_NEW" > "$TMPFILE_D" || true
xsltproc "$ML_DIR"/xmlrev.xslt "$TMPFILE_D" > "$TMPFILE_XSLT"
xsltproc "$TMPFILE_XSLT" "$DOC_OLD"
}
function usage(){
echo "USAGE: $0 [OPTIONS] from_file to_file"
echo
echo OPTIONS:
echo " --revision"
echo " show difference between revisions as an HTML file (default)"
echo " --diff"
echo " show difference between revisions as xupdate"
}
ML_DIR=/usr/share/sgml/stylesheet/xmldiff
case "$1" in
--help)
usage
exit 0
;;
--revision)
revision "$2" "$3"
;;
--diff)
diff "$2" "$3"
;;
*)
revision "$1" "$2"
;;
esac
rm -f $TMPFILES
|