#include "xmlPresenter.h" XmlPresenter::~XmlPresenter() { } XmlPresenter::XmlPresenter(const std::string & group, const std::string & file) : Presenter(group, file), responseRootNodeName(present.get_document()->get_root_node()->get_attribute_value("root")), responseStyle(present.get_document()->get_root_node()->get_attribute_value("style")), contentType(present.get_document()->get_root_node()->get_attribute_value("contenttype")), responseDoc(XmlDocumentPtr(new xmlpp::Document("1.0"))) { nodeStack.push_back(responseDoc->create_root_node(responseRootNodeName)); xmlNewNs(nodeStack.back()->cobj(), BAD_CAST "http://project2.randomdan.homeip.net", BAD_CAST "project2"); // XSLT Style char * buf; if (responseStyle.length() && asprintf(&buf, "type=\"text/xsl\" href=\"%s\"", responseStyle.c_str()) > 0) { xmlAddPrevSibling(nodeStack.back()->cobj(), xmlNewDocPI(responseDoc->cobj(), BAD_CAST "xml-stylesheet", BAD_CAST buf)); free(buf); } } XmlPresenter::XmlDocumentPtr XmlPresenter::getDataDocument() const { return responseDoc; } void XmlPresenter::pushSub(const Glib::ustring & name, const Glib::ustring & ns) const { nodeStack.push_back(nodeStack.back()->add_child(name, ns)); } void XmlPresenter::addAttr(const Glib::ustring & name, const Glib::ustring & ns, const Glib::ustring & value) const { nodeStack.back()->set_attribute(name, value, ns); } void XmlPresenter::setText(const Glib::ustring & value) const { nodeStack.back()->set_child_text(value); } void XmlPresenter::popSub() const { nodeStack.pop_back(); }