I am using JDOM to read in the existing xml document and then write it back out. Here is a sample of the code:
try{
SAXBuilder builder = new SAXBuilder();
doc = builder.build(fileIn);
root = doc.getRootElement();
}
... add element using .addContent(new Element("Comments", ns).addContent(commentString));
FileOutputStream fileOut = new FileOutputStream(fileName);
XMLOutputter xmlOut = new XMLOutputter();
xmlOut.output(doc, fileOut);
fileOut.flush();
fileOut.close();
My web provider has a way that I can edit the file using a textarea in a html form and when I look at the data there everything looks fine. And if I save the file from the form then the xml/xsl works just fine.