/**
   * Rewrite results to a simple XML String
   *
   * @param result
   * @return
   */
  protected static String rewriteResultToXMLString(HashMap<TPENode, Match> result) {
    StringBuffer r = new StringBuffer();
    for (TPENode noderesult : result.keySet()) {
      Match rmatch = result.get(noderesult);

      // do not print missing optional elements
      if (rmatch != null) r.append(rmatch.toString());
    }
    return r.toString();
  }
  protected static ArrayList<HashMap<TPENode, Match>> matchToResults(Match m) {
    ArrayList<HashMap<TPENode, Match>> myresults = new ArrayList<HashMap<TPENode, Match>>();

    for (HashMap<TPENode, Match> line : m.mapResults(buildEmptyResultMatch(m.tpenode))) {
      myresults.add(line);
    }
    return myresults;
  }