5 #include "TDocument.hh"
6 #include "CMathMLFactoryXSLTDiff.hh"
7 #include "AMathMLConsumer.hh"
9 CMathMLFactoryXSLTDiff::CMathMLFactoryXSLTDiff(ALogger& l, const DOMX::XSLTStylesheet& s)
10 : AMathMLFactory(l), style(s)
12 DOM::DOMImplementation di;
14 result = di.createDocument(MATHML_NS_URI, "m:math", dt);
18 CMathMLFactoryXSLTDiff::documentModified(TDocument& doc)
21 std::vector< std::pair<DOM::GdomeString, DOM::GdomeString> > dirtyId;
22 if (TNode dirty = doc.dirtyNode())
23 if (false && result.get_documentElement().hasAttribute("xref"))
24 dirtyId.push_back(std::make_pair(DOM::GdomeString("id"),
25 DOM::GdomeString("'" + std::string(dirty["id"]) + "'")));
27 DOM::Document res = style.apply(doc.document());
29 //cout << "*** THE DIRTY FRAGMENT HAS ID = " << std::string(dirty["id"]) << endl;
30 //style.save(doc.document(), stdout);
31 cout << "*** THE CURRENT DOCUMENT:" << endl;
32 if (result) style.save(result, stdout);
33 cout << "*** THE NEW DOCUMENT:" << endl;
34 style.save(res, stdout);
35 cout << "*** THE DIFF:" << endl;
36 DOMX::Diff diff = DOMX::Diff::diff(result, res);
37 style.save(diff.document(), stdout);
44 CMathMLFactoryXSLTDiff::subst(const DOM::Element& e1, const DOM::GdomeString& id, const DOM::Element& e2)
48 if (e1.getAttribute("xref") == id)
50 DOMX::Diff diff = DOMX::Diff::diff(e1, e2);
51 style.save(diff.document(), stdout);
57 DOM::Node p = e1.get_firstChild();
60 while (p && p.get_nodeType() != DOM::Node::ELEMENT_NODE) p = p.get_nextSibling();
62 if (subst(p, id, e2)) return true;
63 else p = p.get_nextSibling();