diff options
Diffstat (limited to 'project2/xmlPresenter.cpp')
-rw-r--r-- | project2/xmlPresenter.cpp | 56 |
1 files changed, 39 insertions, 17 deletions
diff --git a/project2/xmlPresenter.cpp b/project2/xmlPresenter.cpp index 906d2c9..244c96c 100644 --- a/project2/xmlPresenter.cpp +++ b/project2/xmlPresenter.cpp @@ -1,37 +1,59 @@ #include "xmlPresenter.h" #include "xmlObjectLoader.h" -#include <libxml/xinclude.h> #include "variables.h" +XmlPresenter::XmlPresenter() : + responseDoc(XmlDocumentPtr(new xmlpp::Document("1.0"))) +{ +} + XmlPresenter::~XmlPresenter() { } -XmlPresenter::XmlPresenter(const std::string & group, const std::string & file) : - present(group + "/" + file + ".xml"), +void +XmlPresenter::initDoc() +{ + nodeStack.push_back(responseDoc->create_root_node(getResponseRootNodeName())); + xmlNewNs(nodeStack.back()->cobj(), BAD_CAST "http://project2.randomdan.homeip.net", BAD_CAST "project2"); + // XSLT Style + char * buf; + if (!getResponseStyle().empty() && asprintf(&buf, "type=\"text/xsl\" href=\"%s\"", + getResponseStyle().c_str()) > 0) { + xmlAddPrevSibling(nodeStack.back()->cobj(), + xmlNewDocPI(responseDoc->cobj(), BAD_CAST "xml-stylesheet", BAD_CAST buf)); + free(buf); + } +} + +XmlProcessPresenter::XmlProcessPresenter(const std::string & group, const std::string & file, bool isInclusion) : + present(group, file, isInclusion), 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"))) + contentType(present.get_document()->get_root_node()->get_attribute_value("contenttype")) { - while (xmlXIncludeProcessFlags(present.get_document()->cobj(), XML_PARSE_NOXINCNODE) > 0); - LoaderBase loader("http://project2.randomdan.homeip.net", true); loader.supportedStorers.insert(Storer::into(&rowSets)); loader.supportedStorers.insert(Storer::into(&views)); loader.supportedStorers.insert(Storer::into(¶meterChecks)); loader.collectAll(this, present.get_document()->get_root_node(), true); + initDoc(); +} - 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); - } +XmlProcessPresenter::~XmlProcessPresenter() +{ +} + +const Glib::ustring & +XmlProcessPresenter::getResponseRootNodeName() const +{ + return responseRootNodeName; +} + +const Glib::ustring & +XmlProcessPresenter::getResponseStyle() const +{ + return responseStyle; } XmlPresenter::XmlDocumentPtr |