#! /bin/bash
+HOST="`hostname`"
+
set -e
[ "$1" ] && cd $1
-BASE_URL=`pwd -P | sed 's|/home/httpd/users/|http://riva.ucam.org/~|'`
+BASE_URL=`pwd -P | sed 's|/home/\([^/]*\)/public_html/|http://'"$HOST"'/~\1/|'`
set +e
shopt -s nullglob
-for x in *.html; do echo $BASE_URL/$x; nsgmls -s $BASE_URL/$x; done
-
+for x in *.html; do
+ echo "$BASE_URL/$x"
+ if head -n 1 "$x" | egrep -q '(xml|XHTML)'; then
+ SP_CHARSET_FIXED=YES SP_ENCODING=XML \
+ SGML_CATALOG_FILES=/usr/share/sgml/declaration/xml.soc \
+ nsgmls -wxml -s "$BASE_URL/$x"
+ else
+ nsgmls -s "$BASE_URL/$x"
+ fi
+done