#!/bin/bash
#
# verify that a given DAX-3.2 is sane and parsable. 
# Warning: This requires Xerces-J 2.10 or greater. 
#
# $Id$

PEGASUS_CONFIG="`dirname $0`/pegasus-config"
eval `$PEGASUS_CONFIG --sh-dump`
. $PEGASUS_SHARE_DIR/common.sh

# check version of Xerces-J
xerces=`${JAVA} org.apache.xerces.impl.Version`
version=`echo $xerces | \
    perl -alne '@x=split/\./,$F[1]; print $x[0]*1000000+$x[1]*1000+$x[2]'`

if [ "X$version" = 'X' ]; then
    echo "ERROR: Unable to determine version of your Xerces-J" 1>&2
    exit 1
elif [ $version -lt 2010000 ]; then
    echo "ERROR: Sorry, your version of Xerces ($xerces) is too old." 1>&2
    echo "At least version 2.10.0 is required for the DAX validator." 1>&2
    exit 1
else
    ${JAVA} "-Dpegasus.home=${PEGASUS_HOME}" $addon edu.isi.pegasus.planner.client.DAXValidator "$@"
fi
