case "$USE_BACKEND" in
DEFAULT)
	case "$1" in
	stylesheet)
	  ;;
	post-process)
	  if [ "$VERBOSE" -ge 1 ]
	  then
	    echo >&2 "Post-process XSL-FO to DVI"
	  fi
	  # Work around stupid tetex bug with '_' in filenames
	  # Also work around stupid tetex limitation with long lines (bug #101055)
	  sed -e "s,/>,\n/>,g" "$XSLT_PROCESSED" >tmp.fo
	  OUT=output
	  TEXINPUTS="$(dirname "$INPUT_FILE")::$SEARCHPATH"
	  export TEXINPUTS
	  xmltex ${POSTARGS} tmp.fo >$OUT </dev/null || { cat $OUT; exit 1; }
	  [ "$VERBOSE" -ge 2 ] && echo >&2 "First pass complete"
	  # If there were undefined references we need to re-run xmltex.
	  if egrep '^LaTeX Warning: There were undefined references.$' $OUT \
							>/dev/null 2>&1 \
	  || egrep '^LaTeX Warning: Label.s. may have changed\.' $OUT \
							>/dev/null 2>&1
	  then
	    xmltex ${POSTARGS} tmp.fo >$OUT </dev/null
	    [ "$VERBOSE" -ge 2 ] && echo >&2 "Second pass complete"
	    xmltex ${POSTARGS} tmp.fo >$OUT </dev/null
	    if [ "$VERBOSE" -ge 2 ]
	    then
	      echo >&2 "Third pass complete"
	      [ "$VERBOSE" -ge 3 ] && cat $OUT
	    fi
	  fi
	  if [ "$VERBOSE" -ge 1 ]
	  then
	    echo >&2 "Post-process DVI to PS"
	  fi
	  dvips -R -q ${POSTPOSTARGS} -o "$OUTPUT_DIR/$(basename "${XSLT_PROCESSED%.*}").ps" *.dvi
	  ;;
	esac
	;;
FOP)
  if [ ! -x "$FOP_PATH" ]; then
    echo >&2 "Installed FOP is needed for this format. Executable fop was not found"
    echo >&2 "on expected location ${FOP_PATH}." 
    echo >&2 "Please install fop package or change default FOP_PATH in xmlto script."
    exit 1
  fi	
	EXT=$(basename $0) 
	case "$1" in
	stylesheet)
	  ;;
	post-process)
	  if [ "$VERBOSE" -ge 1 ]
	  then
	    echo >&2 "Post-process XSL-FO to PS"
	  fi
	  "$FOP_PATH" ${POSTARGS} -fo "${XSLT_PROCESSED}" -"${EXT}" "$OUTPUT_DIR/$(basename ${XSLT_PROCESSED%.*}).${EXT}"
	  ;;
	esac
	;;
esac
