Hi,
This has come up several times before, but I cannot persuade the DOM parser to ignore whitespace in an XML document. I've read through all the previous queries on the problem, and I
1. validate against a schema (this works, as it complains if I change the XML)
2. use xerces 2.5, which ought to validate against schemas correctly
3. set setIgnoringElementContentWhitespace(true)
4. in the schema explicitly set mixed="false" in every complexType definition
I've modified the DomEcho02 example from the tutorial, and it still shows me text nodes around every child node. Has anybody got any ideas why this is not working the way it should?
The code setting up the factory is:
if (argv.length != 2) {
System.err.println("Usage: java DomEcho filename schema");
System.exit(1);
}
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
factory.setIgnoringComments(true);
factory.setIgnoringElementContentWhitespace(true);
factory.setAttribute(
"http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
try {
factory.setAttribute(
"http://java.sun.com/xml/jaxp/properties/schemaSource",
new InputSource(new FileInputStream(argv[1])));
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(new File(argv[0]));
makeFrame();
} ....
I'd appreciate any help on this one!
Adriaan