I'm working on a program that is using Dom4J to write xml files. The database schema I am writing to has a handy xml validation and import schema. Dom4J is working great, but, I can't seem to figure out how to set the 'preserve' field in Dom4J's XMLWriter class. I have a particular element where I need the encoded '\n's preserved.
The javadoc for this class is a little underdocumented http://dom4j.sourceforge.net/dom4j-1.6.1/apidocs/org/dom4j/io/XMLWriter.html
I've tried playing around with on OutputFormat object but no dice.
Can anyone tell me how to ensure that an XMLWriter object preserves's the whitespace of dom4j tree's elements when writing to file.
Thanks,
Donald
Say I am starting with:
Element accession = factory.createElement("title");
List<String> AUT = new ArrayList<String>;
AUT.add("author1");
AUT.add("author2");
String title = "Title";
I would like to have an output similar to:
<title>author1
author2
Title</title>
With the line returns encoded into the title field.
DefaultEntity e = new DefaultEntity("#10");
if(AUT.size() > 1) {
for(String a : AUT) {
accession.addText(a);
accession.add(e);
}
accession.addText(title);
}
This does not work as it is an IllegalAddException.