#------------------------------------------------------------------------------------ # Copyright Lom M. Hillah - Inception Date: April 25, 2010 # Version: 0.4 of December 30, 2013 # License : GNU GPL v3. See http://www.gnu.org/licenses/ # # This script uses xmllint to validate your PNML Documents. It also uses perl. # I thus assume you already have libxml2 (and perl) installed on your machine. # I also assume you have Internet connectivity, because the PNML gramars are # fetched over the Internet from http://www.pnml.org # The validation results are output in /tmp/pnmlValidation/pnmlValidationReport.html # Note: If you want to keep a previous validation result, rename the output file. # This script is meant to be run on Linux, Unix and Mac OS. #------------------------------------------------------------------------------------ TEMPDIR=/tmp RESULTDIR=$TEMPDIR/pnmlValidation REPORTFILE=$RESULTDIR/pnmlValidationReport.html TITLE="PNML Document(s) validation report" # Create folder in $TMP to contain report file mkdir -p $RESULTDIR # Prepare report file echo "" > $REPORTFILE echo " $TITLE

$TITLE

Session of `date`

 

" >> $REPORTFILE for f in "$@" do # Extracts the URL of the grammar GRUL=`grep "type=" $f | awk -F "=\"" '{print $3}' | sed -e "s/\">/.pntd/g"` BASENAME=`basename $f` echo "

Validation result for $BASENAME

" >> $REPORTFILE xmllint $f --noout --stream --relaxng $GRUL 2>&1 |\ perl -pe 's|^((?:]+>)*)(.*?):(\d+):(.*error.*)|$1 on line $3 : $4
|' |\ xargs echo >> $REPORTFILE echo "

" >> $REPORTFILE done echo " " >> $REPORTFILE echo $REPORTFILE