public Document createDOM(Map<String, Vector<Integer>> map,
Vector<Topic> topics) throws ParserConfigurationException {
Element mapNode = new Element("chat-map");
Document doc = new Document(mapNode);
for (int i = 0; i < topics.size(); i++) {
Topic t = (Topic) topics.elementAt(i);
Element topicNode = new Element("chat-topic");
topicNode.setAttribute(new Attribute("name", t.getName()));
mapNode.addContent(topicNode);
// keys
Iterator keys = t.getKeys().iterator();
Element keysElem = new Element("chat-keys");
topicNode.addContent(keysElem);
while (keys.hasNext()) {
String keyText = (String) keys.next();
Element keyNode = new Element("chat-key");
keysElem.addContent(keyNode);
keyNode.setText(keyText);
}
// answers in a mapping with the answers as keys and their
// frequencies as Integers as values
Map answersMapping = t.getAnswers();
Iterator answers = answersMapping.keySet().iterator();
Element answersElem = new Element("chat-answers");
topicNode.addContent(answersElem);
while (answers.hasNext()) {
String answerText = "";