#!/bin/bash
# Change directory to whatever directory this file is in.
cd "${BASH_SOURCE%/*}"

# Figure out what files to compile.
FILES=*.xml

for I in $FILES
do
    # Get the filename to use (eg, example.xml => example.html).
    IFS='.' read -a array <<< "$I"
    T="${array[0]}.html"

    printf "Compiling $I => $T\033[31m\n"

    # Compile it with xsltproc.
    N="1"
    xsltproc View.xsl $I > $T || N=0

    # Output.
    if [ "${N}" -eq "1" ]
    then
      printf "\033[93mSuccess!"
    else
      printf "\033[1mError!"
    fi
    printf "\033[0m\n"
done
