|
|
@@ -26,9 +26,7 @@ import net.ranides.assira.xml.XMLElements;
|
|
|
import net.ranides.assira.xml.XMLException;
|
|
|
|
|
|
import lombok.experimental.UtilityClass;
|
|
|
-import org.w3c.dom.DOMException;
|
|
|
-import org.w3c.dom.Document;
|
|
|
-import org.w3c.dom.Node;
|
|
|
+import org.w3c.dom.*;
|
|
|
import org.xml.sax.InputSource;
|
|
|
import org.xml.sax.SAXException;
|
|
|
|
|
|
@@ -91,7 +89,10 @@ public final class W3ElementFactory {
|
|
|
|
|
|
private static Node parse(XMLElement target, String xml) {
|
|
|
try {
|
|
|
- String wxml="<__fragment__>" + xml + "</__fragment__>";
|
|
|
+ DocumentType tt = target.document().node().getDoctype();
|
|
|
+ String doctype = tt == null ? "" : "<!DOCTYPE __fragment__ [" + tt.getInternalSubset() + "] >";
|
|
|
+
|
|
|
+ String wxml = doctype + "<__fragment__>" + xml + "</__fragment__>";
|
|
|
Document cdoc = builder().parse(new InputSource(new StringReader(wxml)));
|
|
|
return target.document().node().importNode(cdoc.getDocumentElement(),true);
|
|
|
} catch(SAXException | DOMException | ParserConfigurationException | IOException cause) {
|