#!/bin/sh
set +u

os=`uname -s`
if [ "$os" = "Linux" ]; then
    scriptFile=`readlink -f "$0"`
else
    scriptFile="$0"
fi
pfwHome=`dirname "$scriptFile"`

#
# Determine which is the class path.
#
jars="$pfwHome/tagsoup.jar"

if [ -f "$pfwHome/paste_from_word.jar" ]; then
    cp="$pfwHome/paste_from_word.jar:$jars"
else
    echo "paste_from_word.jar not found"
    exit 2
fi

# ----------------------------------------------------------------------------
# MODIFY VARIABLE BELOW IF NEEDED TO!
#
# Variable xxeHome must point to the directory when XMLmind XML Editor 
# has been installed. Example: xxeHome=/opt/xxe-perso-11_2_3
# ----------------------------------------------------------------------------

xxeHome="$pfwHome/../.."

if [ -f "$xxeHome/bin/xxe.jar" ]; then
    xxeCode="$xxeHome/bin/xxe.jar"
elif [ -d "$pfwHome/../../11xxe/class" ]; then
    xxeHome="$pfwHome/../../11xxe"
    xxeCode="$xxeHome/class"
else
    echo "xxe.jar not found; please edit this script to set variable xxeHome"
    exit 3
fi

cp="$xxeCode:$xxeHome/bin/xmlresolver.jar:$xxeHome/bin/saxon.jar:$cp"

exec java -classpath "$cp" \
    com.xmlmind.xmleditext.paste_from_word.engine.Engine "$@"
