NPE sur #importNode Document jTidy
Bonjour à tous,
J'utilise jTidy pour récupérer des fichiers HTML en XHTML et ensuite incorporer le contenu du body dans mes propres balises org.w3c.dom :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| Tidy converter = new Tidy();
converter.setQuiet(true);
converter.setXmlOut(true);
//converter.setXHTML(true);
converter.setEncloseText(true);
Document doc = converter.parseDOM(new FileInputStream(file), null);
// nettoyer enveloppe HTML (la fabrique inclue elle-même HTML/HEAD+BODY)
NodeList body = doc.getElementsByTagName("body");
NodeList bodyContents = ((Element) body.item(0)).getChildNodes();
...
Element bodyNode = xmlDoc.createElement("body");
for (int i = 0; i < bodyContents.getLength(); i++) {
bodyNode.appendChild(xmlDoc.importNode(bodyContents.item(i), true));
} |
Et voici le résultat :
Citation:
org.w3c.dom.DOMException: DOM method not supported
at org.w3c.tidy.DOMDocumentImpl.getImplementation(DOMDocumentImpl.java:129)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1536)
at com.sun.org.apache.xerces.internal.dom.CoreDocumentImpl.importNode(CoreDocumentImpl.java:1498)
...
J'ai cru comprendre, subliminalement, que d'affecter un certain handler pourrait aider... mais lequel, et où ? Mystère ! :calim2:
Le source jTidy :
Code:
1 2 3 4 5 6 7 8
| /**
* @todo DOM level 2 getImplementation() Not implemented. Throws NOT_SUPPORTED_ERR.
* @see org.w3c.dom.Document#getImplementation
*/
public org.w3c.dom.DOMImplementation getImplementation()
{
throw new DOMException(DOMException.NOT_SUPPORTED_ERR, "DOM method not supported");
} |
:calim2::calim2:
Si quelqu'un a une idée, je suis volontiers preneur !
Merci d'avance.