Мне нужно преобразовать org.w3c.dom.Document
в org.jdom.Document
Я пробовал следующее:
InputStream inputStream = new ByteArrayInputStream(str.getBytes());
Tidy tidy = new Tidy();
tidy.setMakeClean(false);
tidy.setShowWarnings(true); //tidy.setShowWarnings(false);
tidy.setTidyMark(false);
tidy.setNumEntities(true);
tidy.setQuoteAmpersand(true);
tidy.setQuoteMarks(true);
tidy.setQuoteNbsp(false);
tidy.setHideEndTags(false);
tidy.setDropEmptyParas(false);
Document tidyDOM =tidy.parseDOM(inputStream, null);
DOMBuilder domBuilder = new DOMBuilder();
org.jdom.Document jdomDoc = domBuilder.build(tidyDOM);
domBuilder.build(tidyDOM)
выдает следующее исключение:
org.jdom.IllegalNameException: The name "html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"" is not legal for JDOM/XML DocTypes: XML names cannot contain the character " ".
at org.jdom.DocType.setElementName(DocType.java:171)
at org.jdom.DocType.<init>(DocType.java:111)
at org.jdom.DocType.<init>(DocType.java:144)
at org.jdom.DefaultJDOMFactory.docType(DefaultJDOMFactory.java:118)
at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:332)
at org.jdom.input.DOMBuilder.buildTree(DOMBuilder.java:170)
at org.jdom.input.DOMBuilder.build(DOMBuilder.java:135)
at test.JaxenTest.testParsingVisitor(JaxenTest.java:58)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)