File writeTeamResultXmlFile(final TeamResult result) {
    Element root = writeTeamResultXml(result);

    File outputFile =
        createTeamResultXmlFile(
            result.getMatch().getMatchNumber(), result.getTeam().getTeamNumber());
    deleteExistingFile(outputFile);
    writeFile(outputFile, new Document(root));
    return outputFile;
  }
  private Element writeTeamResultXml(final TeamResult result) {
    /*  example team result XML file content
    <result matchNumber="1" teamNumber="1" cat1="-1" cat2="-1" cat3="-1" ... >
        Specific notes about this team and this match
    </result>
    */

    Element rootElm = new Element("result");
    rootElm.setAttribute("matchNumber", Integer.toString(result.getMatch().getMatchNumber()));
    rootElm.setAttribute("teamNumber", Integer.toString(result.getTeam().getTeamNumber()));

    for (Category c : result.getScoringCategories()) {
      rootElm.setAttribute(c.getName(), result.getScore(c).toString());
    }

    rootElm.setText(result.getNotes());
    return rootElm;
  }