Reputation: 619
import com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl;
public static Document newDocument( String pName ) {
return DOMImplementationImpl.getDOMImplementation().createDocument(
null,
pName,
DOMImplementationImpl.getDOMImplementation().createDocumentType( pName, null, null ) );
}
I have encounter with below warnings in netbeans
warning: com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl is Sun proprietary API and may be removed in a future release
return DOMImplementationImpl.getDOMImplementation().createDocument(
warning: com.sun.org.apache.xerces.internal.dom.DOMImplementationImpl is Sun proprietary API and may be removed in a future release DOMImplementationImpl.getDOMImplementation().createDocumentType( pName, null, null ) );
Upvotes: 5
Views: 8472
Reputation: 189
Don't try to remove the warning. Rather remove the import statement, and use a different parser, which you initialize using its parser factory.
Upvotes: 1
Reputation: 1502696
Don't refer to a concrete DOMImplementation. Instead, use:
DOMImplementationRegistry registry = DOMImplementationRegistry.newInstance();
DOMImplementation implementation = registry.getDOMImplementation("XML 1.0");
DocumentType type = implementation.createDocumentType(pName, null, null);
Document document = implementation.createDocument(null, pname, type);
Alternatively, use a rather less factory-heavy XML API, like JDOM :) (I've always found the Java W3C DOM API to be a complete pain to work with.)
Yet another alternative would be to use a concrete DOMImplementation, but make it an external one rather than relying on an implementation built into the JDK. This could still be Apache Xerces, just from a jar file.
Upvotes: 8
Reputation: 234847
The way to remove the warning is to avoid using internal, undocumented classes and methods from Sun in your code.
Upvotes: 3