X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2FDEVEL%2Fmathml_editor%2Fsrc%2FCMathMLFactoryXSLT.cc;h=2b714cb91f83d175f1757fb0c627a8f097d49c41;hb=387aeebf96181c051b7f527a0901b173cfcdf194;hp=244d3640b0f60fec1dc11d14cfa200d630b58366;hpb=2f94240bc382ca43017f31b0852f1717fe18090b;p=helm.git diff --git a/helm/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc b/helm/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc index 244d3640b..2b714cb91 100644 --- a/helm/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc +++ b/helm/DEVEL/mathml_editor/src/CMathMLFactoryXSLT.cc @@ -5,42 +5,48 @@ #include "CMathMLFactoryXSLT.hh" #include "AMathMLConsumer.hh" +CMathMLFactoryXSLT::CMathMLFactoryXSLT(ALogger& l, const DOMX::XSLTStylesheet& s) + : AMathMLFactory(l), style(s) +{ + reset(); +} + +void +CMathMLFactoryXSLT::reset() +{ + DOM::DOMImplementation di; + DOM::DocumentType dt; + result = di.createDocument(MATHML_NS_URI, "m:math", dt); +} + void CMathMLFactoryXSLT::documentModified(TDocument& doc) { if (TNode dirty = doc.dirtyNode()) { std::vector< std::pair > dirtyId; - if (result) + if (result.get_documentElement().hasAttribute("xref")) 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) - { - DOM::Element root = res.get_documentElement(); - assert(root); - assert(root.hasAttribute("xref")); + style.save(doc.document(), stdout); + + DOM::Element root = res.get_documentElement(); + assert(root); + assert(root.hasAttribute("xref")); - try - { - bool ok = subst(result.get_documentElement(), root.getAttribute("xref"), result.importNode(root, true)); - assert(ok); - } - catch (DOM::DOMException& e) - { - cout << "!!!!!!!!!!!!!!!! EXCEPTION " << e.code << " " << e.msg << endl; - assert(0); - } + if (result.get_documentElement().hasAttribute("xref")) + { + bool ok = subst(result.get_documentElement(), root.getAttribute("xref"), result.importNode(root, true)); + assert(ok); } else - result = res; + result.replaceChild(result.importNode(root, true), result.get_documentElement()); + + style.save(result, stdout); doc.clearDirty(); - - if (consumer) consumer->documentModified(result); } }