public GlosslistHandler(String inDir, String outDir) throws Exception {
    Directory in = new Directory(inDir);
    if (!in.exists()) throw new IOException(inDir);

    Collection<File> files = in.getFiles();

    con = new XPathContext();
    con.addNamespace("db", dbns);

    for (File file : files) {
      System.out.println("processing glossentries in " + file.getName());
      if (file.getCanonicalPath().endsWith(".xml")) {
        Builder builder = new Builder();
        Document doc = builder.build(file);
        try {
          doc = process(doc);
        } catch (Exception e) {
          System.err.println("Error processing " + file.getName());
          throw e;
        }
        serialize(doc, new File(outDir, file.getName()));
      }
    }
  }