Originally posted by William Brogden:
In the Java 5 javax.xml.parsers.DocumentBuilderFactory we find the setIgnoringElementContentWhitespace() method. I have not actually tried this but it looks like it could do the job.
Bill
Indeed it would, and does, except for the implementation detail, as documented: "Note that only whitespace which is directly contained within element content that has an element only content model (see XML Rec 3.2.1) will be eliminated." That "element only content model" translates into a DTD or a schema. How else is the parser supposed to know when whitespace is "ignorable" and when it isn't?