Still no language-independent means to create
a new Document
object
Does provide an implementation-independent method for Java only:
DOMImplementation impl = DOMImplementationFactory.getDOMImplementation();
package org.w3c.dom;
public abstract class DOMImplementationFactory {
// The system property to specify the DOMImplementation class name.
private static String property = "org.w3c.dom.DOMImplementation";
// The default DOMImplementation class name to use.
private static String defaultImpl = "NO DEFAULT IMPLEMENTATION SET";
public static DOMImplementation getDOMImplementation()
throws ClassNotFoundException, InstantiationException,
IllegalAccessException, ClassCastException {
// Retrieve the system property
String impl;
try {
impl = System.getProperty(property, defaultImpl);
}
catch (SecurityException e) {
// fallback on default implementation in case of security problem
impl = defaultImpl;
}
// Attempt to load, instantiate and return the implementation class
return (DOMImplementation) Class.forName(impl).newInstance();
}
}