EVALUATION
This is an issue introduced by an Apache update that although technically correct, was nonetheless an incompatible change. As reported in the CR, it caused NetBeans test failures and spurious reformatting of project metadata of users' projects that the version control tool would take as if there were real changes. The incompatible behavior would more than likely cause many problems to users' applications.
This patch adds an implementation specific property that can be used to essentially neutralize the Apache change to bring back the original behavior. It has been tested to have resolved the NetBeans issue with minimal effort in the NetBeans' part.
The use is:
static final String ORACLE_IS_STANDALONE = "http://www.oracle.com/xml/is-standalone";
//catch IllegalArgumentException when running with previous releases
try {
transformer.setOutputProperty(ORACLE_IS_STANDALONE, "yes");
} catch (IllegalArgumentException e) {
//expected for previous releases
}
|
WORK AROUND
No simple workaround (not regressing other details checked by XMLUtilTest) yet known.
Using simply
Transformer t = tf.newTransformer();
without the special identity transformer behaves poorly even on earlier versions of JAXP, hence the #5064280 workaround.
Using DOM 3 L&S
DOMImplementationLS ls = (DOMImplementationLS) doc.getImplementation().getFeature("LS", "3.0");
LSSerializer ser = ls.createLSSerializer();
ser.getDomConfig().setParameter("format-pretty-print", true);
LSOutput out = ls.createLSOutput();
out.setByteStream(System.out);
ser.write(doc, out);
works nicely in this case but fails in some more advanced cases, such as comments between the XML declaration and the root element.
|