#!/bin/bash
# check - Validate Some XHTML 1.0 Subset Files
# Author: Sean B. Palmer, inamidst.com
# Usage: ./check <directory> <schema> <normaliser>

if ! which rnv &> /dev/null
then echo Requires RNV >&2
     exit 1
fi

cd ${1:-.}

find -name '*.html' | \
while read LINE
   do grep -q '<html xmlns="http://www.w3.org/1999/xhtml"' $LINE
      if (( $? ))
      then echo "- $LINE (Not XHTML)" && echo && continue
      fi

      ${3:-code/xhtmlnorm.py -a} $LINE > /tmp/rnv.$$.stdin
      rnv -q ${2:-proj/quality/xhtml.rnc} /tmp/rnv.$$.stdin 2>&1 | \
         grep error > /tmp/rnv.$$.stdout
      echo "$? $LINE"
      sed 's/^/   /' /tmp/rnv.$$.stdout
      echo 

      rm /tmp/rnv.$$.stdin
      rm /tmp/rnv.$$.stdout
done

# [EOF]