diff options
| author | randomdan <randomdan@localhost> | 2011-05-12 19:02:11 +0000 | 
|---|---|---|
| committer | randomdan <randomdan@localhost> | 2011-05-12 19:02:11 +0000 | 
| commit | ed5c47f4458ff145e61db695bf0fb6b3d1bd748c (patch) | |
| tree | 306ca013587f1aa06276c36984569e1b81fec1af | |
| parent | Bridge boost::filesystem2/3 compile gap (diff) | |
| download | project2-ed5c47f4458ff145e61db695bf0fb6b3d1bd748c.tar.bz2 project2-ed5c47f4458ff145e61db695bf0fb6b3d1bd748c.tar.xz project2-ed5c47f4458ff145e61db695bf0fb6b3d1bd748c.zip | |
Support setting presenter node namespaces directly
Copy the XML node namespace and prefix to the presenter in rawView
| -rw-r--r-- | project2/console/consoleAppEngine.cpp | 9 | ||||
| -rw-r--r-- | project2/console/consoleAppEngine.h | 2 | ||||
| -rw-r--r-- | project2/presenter.h | 2 | ||||
| -rw-r--r-- | project2/rawView.cpp | 1 | ||||
| -rw-r--r-- | project2/xmlPresenter.cpp | 17 | ||||
| -rw-r--r-- | project2/xmlPresenter.h | 2 | 
6 files changed, 30 insertions, 3 deletions
| diff --git a/project2/console/consoleAppEngine.cpp b/project2/console/consoleAppEngine.cpp index 5c81b95..1c4f869 100644 --- a/project2/console/consoleAppEngine.cpp +++ b/project2/console/consoleAppEngine.cpp @@ -112,6 +112,15 @@ ConsoleApplicationEngine::addAppData(const Presenter *) const  }  void +ConsoleApplicationEngine::declareNamespace(const Glib::ustring &, const Glib::ustring &) const +{ +} +void +ConsoleApplicationEngine::setNamespace(const Glib::ustring &, const Glib::ustring &) const +{ +} + +void  ConsoleApplicationEngine::pushSub(const Glib::ustring & name, const Glib::ustring & ns) const  {  	fprintf(stdout, "%*s", indent, ""); diff --git a/project2/console/consoleAppEngine.h b/project2/console/consoleAppEngine.h index 3663217..b08dec3 100644 --- a/project2/console/consoleAppEngine.h +++ b/project2/console/consoleAppEngine.h @@ -39,6 +39,8 @@ class ConsoleApplicationEngine : public ApplicationEngine, public Presenter, Req  		// Presenter interface  	public: +		void declareNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const; +		void setNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const;  		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; diff --git a/project2/presenter.h b/project2/presenter.h index cdae0fd..bbfaf82 100644 --- a/project2/presenter.h +++ b/project2/presenter.h @@ -13,8 +13,10 @@ class Presenter : public virtual CommonObjects, public virtual IntrusivePtrBase  		Presenter();  		virtual ~Presenter() = 0; +		virtual void declareNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const = 0;  		virtual void pushSub(const Glib::ustring & name) const;  		virtual void pushSub(const Glib::ustring & name, const Glib::ustring & ns) const = 0; +		virtual void setNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const = 0;  		virtual void addAttr(const Glib::ustring & name, const VariableType & value) const;  		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; diff --git a/project2/rawView.cpp b/project2/rawView.cpp index ce4605a..90569c9 100644 --- a/project2/rawView.cpp +++ b/project2/rawView.cpp @@ -36,6 +36,7 @@ void  RawView::copyNode(const Presenter * p, const xmlpp::Element * n) const  {  	p->pushSub(n->get_name()); +	p->setNamespace(n->get_namespace_prefix(), n->get_namespace_uri());  	xmlpp::Element::AttributeList al = n->get_attributes();  	BOOST_FOREACH(const xmlpp::Attribute * a, al) {  		p->addAttr(a->get_name(), a->get_value()); diff --git a/project2/xmlPresenter.cpp b/project2/xmlPresenter.cpp index d657964..adf7860 100644 --- a/project2/xmlPresenter.cpp +++ b/project2/xmlPresenter.cpp @@ -17,9 +17,8 @@ XmlPresenter::createDoc() const  {  	if (nodeStack.empty()) {  		nodeStack.push_back(responseDoc->create_root_node(getResponseRootNodeName())); -		xmlNewNs(nodeStack.back()->cobj(), -				BAD_CAST ApplicationEngine::getCurrent()->env()->getXmlNamespace().c_str(), -				BAD_CAST ApplicationEngine::getCurrent()->env()->getXmlPrefix().c_str()); +		declareNamespace(ApplicationEngine::getCurrent()->env()->getXmlPrefix(), +				ApplicationEngine::getCurrent()->env()->getXmlNamespace());  		// XSLT Style  		char * buf;  		if (!getResponseStyle().empty() && asprintf(&buf, "type=\"text/xsl\" href=\"%s\"", @@ -67,6 +66,18 @@ XmlPresenter::getDataDocument() const  }  void +XmlPresenter::declareNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const +{ +	xmlNewNs(nodeStack.back()->cobj(), BAD_CAST ns.c_str(), BAD_CAST prefix.c_str()); +} + +void +XmlPresenter::setNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const +{ +	nodeStack.back()->set_namespace_declaration(ns, prefix); +} + +void  XmlPresenter::pushSub(const Glib::ustring & name, const Glib::ustring & ns) const  {  	createDoc(); diff --git a/project2/xmlPresenter.h b/project2/xmlPresenter.h index ee610ee..cd63f1e 100644 --- a/project2/xmlPresenter.h +++ b/project2/xmlPresenter.h @@ -14,6 +14,8 @@ class XmlPresenter : public Presenter {  		XmlPresenter();  		~XmlPresenter(); +		void declareNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const; +		void setNamespace(const Glib::ustring & prefix, const Glib::ustring & ns) const;  		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 addText(const VariableType & value) const; | 
