- cout << "recreating subtree with id " << std::string(dirty["id"]) << endl;
- std::vector< std::pair<DOM::GdomeString, DOM::GdomeString> > dirtyId;
- if (result)
- dirtyId.push_back(std::make_pair(DOM::GdomeString("id"),
- DOM::GdomeString("'" + std::string(dirty["id"]) + "'")));
- DOM::Document res = style.apply(doc.document(), dirtyId);
- assert(res);
- style.save(doc.document(), stdout);
- style.save(res, stdout);
- if (result)
- {
- cout << "REPLACING A FRAGMENT OF THE DOCUMENT" << endl;
- DOM::Element root = res.get_documentElement();
- assert(root);
- assert(root.hasAttribute("xref"));
-
- if (result.get_documentElement().getAttribute("xref") == root.getAttribute("xref"))
- {
- cout << "REPLACING ROOT" << endl;
- // the following remove should not be necessary
- // according to the spec replaceChild should work just fine
- result.removeChild(result.get_documentElement());
- result.appendChild(result.importNode(root, true));
- }
- else
- try
- {
- cout << "before" << endl;
- bool ok = subst(result.get_documentElement(), root.getAttribute("xref"), result.importNode(root, true));
- assert(ok);
- cout << "after" << endl;
- }
- catch (DOM::DOMException e)
- {
- cout << "!!!!!!!!!!!!!!!! EXCEPTION " << e.code << " " << e.msg << endl;
- assert(0);
- }
- }
- else
- {
- cout << "SETTING THE DOCUMENT FOR THE FIRST TIME" << endl;
- result = res;
-
- DOM::EventTarget et(result);
- assert(et);
- cout << "SETTING EVENT LISTENER (EDITOR) ON " << static_cast<GdomeNode*>(result) << endl;
- et.addEventListener("DOMSubtreeModified", l1, true);
-
- if (GUI_load_document(gdome_cast_doc(static_cast<GdomeNode*>(result))) < 0)
- cerr << "c'e' stato un errore" << endl;
- }
-
- doc.clearDirty();