void (DocumentType dt, String s) { if (dt == null || s == null) return; // Default behavior is to attempt a setInternalSubset() call using // reflection. This method is not part of the DOM spec, but it's // available on Xerces 1.4.4+. It's not currently in Crimson. try { Class<? extends DocumentType> dtclass = dt.getClass(); Method setInternalSubset = dtclass.getMethod( "setInternalSubset", String.class); setInternalSubset.invoke(dt, s); } catch (InvocationTargetException | IllegalAccessException | SecurityException | NoSuchMethodException e) { // ignore } }