#!/bin/sh

# Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
# Copyright (C) 2008 - INRIA
#
# This file must be used under the terms of the CeCILL.
# This source file is licensed as described in the file COPYING, which
# you should have received as part of this distribution.  The terms
# are also available at
# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt

if [ $# -eq 0 ]; then
    echo "Usage: scivalid xml_file ... xml_file"
    echo "Validates specified XML files against the scilab.rnc schema."
    exit 1
fi

binDir=`dirname $0`
schemaDir=$binDir/../schema



# libDir path
# ==============================================================================

if [ -e "$binDir/../../../thirdparty" ]; then
	libDir=$binDir/../../../thirdparty
elif [ -e "$binDir/../../../../../thirdparty" ]; then
	libDir=$binDir/../../../../../thirdparty
else
	echo "Could not find the thirdparty directory."
	exit 2
fi

# jar checks
# ==============================================================================

if [ ! -e "$libDir/jing.jar" ]; then
    echo "Don't find the jing.jar file."
    exit 3
fi

# validation
# ==============================================================================

java -jar "$libDir/jing.jar" "$schemaDir/scilab.rng" "$@"

