public static boolean init(Transformer transformer, LocalDebugger dbg) {
    if (transformer instanceof TransformerImpl) {
      try {
        System.out.println("XALAN: " +
                           Class.forName("org.apache.xalan.Version", true, transformer.getClass().getClassLoader()).getMethod("getVersion")
                             .invoke(null));
        final TransformerImpl tr = (TransformerImpl)transformer;

        tr.setErrorListener(new DefaultErrorHandler(false) {
          @Override
          public void fatalError(TransformerException exception) throws TransformerException {
            if (!(exception.getCause() instanceof DebuggerStoppedException)) {
              super.fatalError(exception);
            }
          }
        });

        try {
          tr.getTraceManager().addTraceListener(new XalanTraceListener(dbg, tr));
        } catch (TooManyListenersException e) {
          throw new AssertionError(e);
        }

        return true;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    return false;
  }
public static boolean init(Transformer transformer, LocalDebugger dbg)