}
}
}
public void write(String sFileName) {
NewDOMDocument doc = new NewDOMDocument(sFileName,".xml");
Document dom = null;
try {
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = builderFactory.newDocumentBuilder();
DOMImplementation domImpl = builder.getDOMImplementation();
dom = domImpl.createDocument("","config",null);
}
catch (Throwable t) {
t.printStackTrace();
}
Element rootElement = dom.getDocumentElement();
for (int i=0; i<OPTION_COUNT; i++) {
Element optionNode = dom.createElement("option");
optionNode.setAttribute("name",options[i].getName());
optionNode.setAttribute("value",options[i].getString());
rootElement.appendChild(optionNode);
}
// Write math symbol map
Enumeration msEnum = mathSymbols.keys();
while (msEnum.hasMoreElements()) {
String sName = (String) msEnum.nextElement();
String sLatex = (String) mathSymbols.get(sName);
Element msNode = dom.createElement("math-symbol-map");
msNode.setAttribute("name",sName);
msNode.setAttribute("latex",sLatex);
rootElement.appendChild(msNode);
}
writeStyleMap(dom,par,"paragraph");
writeStyleMap(dom,parBlock,"paragraph-block");
writeStyleMap(dom,text,"text");
writeStyleMap(dom,list,"list");
writeStyleMap(dom,listItem,"listitem");
Element hmNode = dom.createElement("heading-map");
hmNode.setAttribute("max-level",Integer.toString(headingMap.getMaxLevel()));
rootElement.appendChild(hmNode);
for (int i=1; i<=headingMap.getMaxLevel(); i++) {
Element hlmNode = dom.createElement("heading-level-map");
hlmNode.setAttribute("writer-level",Integer.toString(i));
hlmNode.setAttribute("name",headingMap.getName(i));
hlmNode.setAttribute("level",Integer.toString(headingMap.getLevel(i)));
hmNode.appendChild(hlmNode);
}
// writeXStyleMap(dom,xpar,"paragraph");
// writeXStyleMap(dom,xtext,"text");
// writeXStyleMap(dom,xlist,"list");
// writeXStyleMap(dom,xframe,"frame");
// writeXStyleMap(dom,xframe,"attribute");
writeContent(dom,customPreamble,"custom-preamble");
doc.setContentDOM(dom);
try {
doc.write(new FileOutputStream(sFileName));
} catch(IOException e) {
System.out.println("Oops - problem writing the configuration");
e.printStackTrace();
}
}