diff options
author | randomdan <randomdan@localhost> | 2011-04-19 14:30:19 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2011-04-19 14:30:19 +0000 |
commit | 5317555ecc54c501bc6a577e0b90b1c032f1dfd9 (patch) | |
tree | b89ee477cde84a555f57922397445586f026b989 | |
parent | Add conditional execution from sqlTask (diff) | |
download | project2-5317555ecc54c501bc6a577e0b90b1c032f1dfd9.tar.bz2 project2-5317555ecc54c501bc6a577e0b90b1c032f1dfd9.tar.xz project2-5317555ecc54c501bc6a577e0b90b1c032f1dfd9.zip |
Allow rawview to accurately reconstruct a tree when text and elements coexist as children
Fix to keep the source script document in mempry during processing by console app engine (requirement of rawview)
Copy the complete faq answer paragraph node into the html page as is
-rw-r--r-- | project2/console/consoleAppEngine.cpp | 7 | ||||
-rw-r--r-- | project2/console/consoleAppEngine.h | 4 | ||||
-rw-r--r-- | project2/presenter.cpp | 2 | ||||
-rw-r--r-- | project2/presenter.h | 2 | ||||
-rw-r--r-- | project2/rawView.cpp | 14 | ||||
-rw-r--r-- | project2/xmlPresenter.cpp | 4 | ||||
-rw-r--r-- | project2/xmlPresenter.h | 2 |
7 files changed, 17 insertions, 18 deletions
diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp index 3db8ce9..5c81b95 100644 --- a/project2/console/consoleAppEngine.cpp +++ b/project2/console/consoleAppEngine.cpp @@ -2,7 +2,6 @@ #include "consoleEnvironment.h" #include "../iterate.h" #include "../xmlObjectLoader.h" -#include "../xmlScriptParser.h" #include <boost/foreach.hpp> SimpleMessageException(UnknownPlatformAlias); @@ -57,9 +56,9 @@ ConsoleApplicationEngine::ConsoleApplicationEngine(const ConsoleEnvironment * en _env(env), indent(0), runtime(new ConsoleSession()), - out(stdout, true) + out(stdout, true), + request(f.string(), false) { - XmlScriptParser request(f.string(), false); xmlpp::Element * requestRoot = request.get_document()->get_root_node(); rollbackBeforeHandle = requestRoot->get_attribute_value("rollbackBeforeHandle") == "true"; localErrorHandling = requestRoot->get_attribute_value("errorHandling") == "local"; @@ -149,7 +148,7 @@ ConsoleApplicationEngine::addField(const Glib::ustring & name, const Glib::ustri } void -ConsoleApplicationEngine::setText(const VariableType & value) const +ConsoleApplicationEngine::addText(const VariableType & value) const { fprintf(stdout, "%*s<local> = ", indent, ""); boost::apply_visitor(out, value); diff --git a/project2/console/consoleAppEngine.h b/project2/console/consoleAppEngine.h index 93e76ed..3663217 100644 --- a/project2/console/consoleAppEngine.h +++ b/project2/console/consoleAppEngine.h @@ -12,6 +12,7 @@ #include <boost/intrusive_ptr.hpp> #include <boost/filesystem/path.hpp> #include <libxml++/document.h> +#include "../xmlScriptParser.h" class ConsoleEnvironment; @@ -41,7 +42,7 @@ class ConsoleApplicationEngine : public ApplicationEngine, public Presenter, Req void pushSub(const Glib::ustring & ns, const Glib::ustring & name) const; void addAttr(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const; void addField(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const; - void setText(const VariableType & value) const; + void addText(const VariableType & value) const; void popSub() const; private: mutable unsigned int indent; @@ -50,6 +51,7 @@ class ConsoleApplicationEngine : public ApplicationEngine, public Presenter, Req ParamCheckers parameterChecks; SessionPtr runtime; FileStreamVariableWriter out; + XmlScriptParser request; }; #endif diff --git a/project2/presenter.cpp b/project2/presenter.cpp index 73a6cfa..005fa2b 100644 --- a/project2/presenter.cpp +++ b/project2/presenter.cpp @@ -50,7 +50,7 @@ void Presenter::addField(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const { pushSub(name, ns); - setText(value); + addText(value); popSub(); } diff --git a/project2/presenter.h b/project2/presenter.h index 2391a29..cdae0fd 100644 --- a/project2/presenter.h +++ b/project2/presenter.h @@ -19,7 +19,7 @@ class Presenter : public virtual CommonObjects, public virtual IntrusivePtrBase virtual void addAttr(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const; virtual void addField(const Glib::ustring & name, const VariableType & value) const; virtual void addField(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const; - virtual void setText(const VariableType & value) const = 0; + virtual void addText(const VariableType & value) const = 0; virtual void popSub() const = 0; void execute() const; diff --git a/project2/rawView.cpp b/project2/rawView.cpp index d9ca15b..ce4605a 100644 --- a/project2/rawView.cpp +++ b/project2/rawView.cpp @@ -16,7 +16,7 @@ RawView::RawView(const xmlpp::Element * p) : { } - void +void RawView::loadComplete(const CommonObjects *) { } @@ -40,16 +40,14 @@ RawView::copyNode(const Presenter * p, const xmlpp::Element * n) const BOOST_FOREACH(const xmlpp::Attribute * a, al) { p->addAttr(a->get_name(), a->get_value()); } - const xmlpp::TextNode * t = n->get_child_text(); - if (t) { - p->setText(t->get_content()); - } - xmlpp::Node::NodeList ch = n->get_children(); + const xmlpp::Node::NodeList ch = n->get_children(); BOOST_FOREACH(const xmlpp::Node * c, ch) { - const xmlpp::Element * e = dynamic_cast<const xmlpp::Element *>(c); - if (e) { + if (const xmlpp::Element * e = dynamic_cast<const xmlpp::Element *>(c)) { copyNode(p, e); } + else if (const xmlpp::TextNode * t = dynamic_cast<const xmlpp::TextNode *>(c)) { + p->addText(t->get_content()); + } } p->popSub(); } diff --git a/project2/xmlPresenter.cpp b/project2/xmlPresenter.cpp index cc31c2f..d657964 100644 --- a/project2/xmlPresenter.cpp +++ b/project2/xmlPresenter.cpp @@ -83,11 +83,11 @@ XmlPresenter::addAttr(const Glib::ustring & name, const Glib::ustring & ns, cons } void -XmlPresenter::setText(const VariableType & value) const +XmlPresenter::addText(const VariableType & value) const { if (!boost::get<Null>(&value)) { createDoc(); - nodeStack.back()->set_child_text(value); + nodeStack.back()->add_child_text(value); } } diff --git a/project2/xmlPresenter.h b/project2/xmlPresenter.h index cc1312a..ee610ee 100644 --- a/project2/xmlPresenter.h +++ b/project2/xmlPresenter.h @@ -16,7 +16,7 @@ class XmlPresenter : public Presenter { void pushSub(const Glib::ustring & name, const Glib::ustring & ns) const; void addAttr(const Glib::ustring & name, const Glib::ustring & ns, const VariableType & value) const; - void setText(const VariableType & value) const; + void addText(const VariableType & value) const; void popSub() const; virtual XmlDocumentPtr getDataDocument() const; |