#!/bin/sh

if [ -z $1 ] || [ -z $2 ]
  then
  echo "Usage: $0 marcfilemarc outputstem"
  echo "marcfile.mrc will be transformed into 2 files:"
  echo "  outputstem.xml"
  echo "     Will contain the FRBR xml representing the marc records"
  echo "  outputstem.html"
  echo "     Will contain the HTML display of the FRBR xml"
  exit
fi

echo Transforming $1 to MARCXML ...
java -cp marcxml-20080423.jar:marc4j.jar gov.loc.marcxml.MARC2MARC21slim $1 slimfrbr.xml
echo Transforming the MARCXML into FRBR XML and saving to $2.xml ...
java -jar saxon9.jar -warnings:silent -u -o clean.xml slimfrbr.xml http://www.loc.gov/standards/marcxml/frbr/v2/clean.xsl
java -jar saxon9.jar -warnings:silent -u -o match.xml clean.xml    http://www.loc.gov/standards/marcxml/frbr/v2/match.xsl
java -jar saxon9.jar -warnings:silent -u -o $2.xml    match.xml    http://www.loc.gov/standards/marcxml/frbr/v2/FRBRize.xsl
echo Transforming the FRBR XML into HTML and saving to $2.html ...
java -jar saxon9.jar -warnings:silent -a -o $2.html $2.xml
echo Complete

