public HtmlElement transform(File infile, File outfile) throws Exception {
    HtmlElement htmlElement = null;
    if (infile == null) {
      throw new RuntimeException("null input file");
    }
    if (outfile == null) {
      throw new RuntimeException("null output file");
    }

    String xmlString = transformToXML(infile);
    // debug output
    FileUtils.write(new File("target/debug/transform.xml"), xmlString, Charset.forName("UTF-8"));
    Element xmlElement = XMLUtil.parseXML(xmlString);
    htmlElement = new HtmlFactory().parse(xmlElement);
    XMLUtil.debug(xmlElement, new FileOutputStream("target/firstpass.html"), 1);

    return htmlElement;
  }