-
Bug
-
Resolution: Fixed
-
P3
-
9, 10, 11, 12
Starting from JDK 9, LSSerializer skips the default namespace. The following test fails in JDK 9 and later:
public void testDefaultNS() throws Exception {
String xml = "<a "
+ "xmlns=\"http://openjdk_java_net/xml/defaultNS\" "
+ "xmlns:p1=\"http://openjdk_java_net/xml/serializer/\">"
+ "<b>in default namespace</b></a>";
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
LSSerializer ls = getSerializer(db);
String out = ls.writeToString(getDoc(db, xml));
Assert.assertTrue(out.contains("defaultNS"));
}
private LSSerializer getSerializer(DocumentBuilder db) throws Exception {
DOMImplementationLS di = (DOMImplementationLS) db.getDOMImplementation();
return di.createLSSerializer();
}
private Document getDoc(DocumentBuilder db, String xml) throws Exception {
InputSource is = new InputSource(new StringReader(xml));
return db.parse(is);
}
public void testDefaultNS() throws Exception {
String xml = "<a "
+ "xmlns=\"http://openjdk_java_net/xml/defaultNS\" "
+ "xmlns:p1=\"http://openjdk_java_net/xml/serializer/\">"
+ "<b>in default namespace</b></a>";
DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
LSSerializer ls = getSerializer(db);
String out = ls.writeToString(getDoc(db, xml));
Assert.assertTrue(out.contains("defaultNS"));
}
private LSSerializer getSerializer(DocumentBuilder db) throws Exception {
DOMImplementationLS di = (DOMImplementationLS) db.getDOMImplementation();
return di.createLSSerializer();
}
private Document getDoc(DocumentBuilder db, String xml) throws Exception {
InputSource is = new InputSource(new StringReader(xml));
return db.parse(is);
}
- csr for
-
JDK-8223423 New methods for creating DOM and SAX factories with Namespace support
-
- Closed
-
- relates to
-
JDK-8035467 Xerces Update: Move to Xalan based DOM L3 serializer. Deprecate Xerces' native serializer.
-
- Resolved
-