summaryrefslogtreecommitdiff
path: root/project2/envproc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'project2/envproc.cpp')
-rw-r--r--project2/envproc.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/project2/envproc.cpp b/project2/envproc.cpp
index be864a5..feb5ad1 100644
--- a/project2/envproc.cpp
+++ b/project2/envproc.cpp
@@ -17,25 +17,28 @@ EnvironmentProcessor::init()
page = elems.size() > 0 ? elems[0] : "index";
}
-
-boost::shared_ptr<xmlpp::Document>
-EnvironmentProcessor::process() const
+void
+EnvironmentProcessor::Initialise()
{
xmlpp::DomParser present("present/" + page + ".xml");
while (xmlXIncludeProcessFlags(present.get_document()->cobj(), XML_PARSE_NOXINCNODE) > 0);
xmlpp::Element * presentRoot = present.get_document()->get_root_node();
+ responseRootNodeName = presentRoot->get_attribute_value("root");
+ responseStyle = presentRoot->get_attribute_value("style");
// Collect datasources
- RdbmsDataSources rdbmsDataSources;
- collectAll<_RdbmsDataSource>(rdbmsDataSources, presentRoot, "rdbmsdatasource", &_Project2SourceObject::name, true, true);
+ collectAll<_RdbmsDataSource>(datasources, presentRoot, "rdbmsdatasource", &_Project2SourceObject::name, true, true);
// Collect views
- SqlViews sqlViews;
- collectAll<_SqlView>(sqlViews, presentRoot, "sqlview", &_SqlView::name, true, true);
- //
+ collectAll<_SqlView>(views, presentRoot, "sqlview", &_SqlView::name, true, true);
+}
+
+boost::shared_ptr<xmlpp::Document>
+EnvironmentProcessor::process() const
+{
boost::shared_ptr<xmlpp::Document> responseDoc = boost::shared_ptr<xmlpp::Document>(new xmlpp::Document("1.0"));
- xmlpp::Element * responseRoot = responseDoc->create_root_node(presentRoot->get_attribute_value("root"));
+ xmlpp::Element * responseRoot = responseDoc->create_root_node(responseRootNodeName);
try {
- BOOST_FOREACH(SqlViews::value_type s, sqlViews) {
- s.second->execute(rdbmsDataSources, responseRoot, this);
+ BOOST_FOREACH(Views::value_type s, views) {
+ s.second->execute(responseRoot, this);
}
}
catch (...) {
@@ -59,7 +62,7 @@ EnvironmentProcessor::process() const
// XSLT Style
char * buf;
if (asprintf(&buf, "type=\"text/xsl\" href=\"%s\"",
- presentRoot->get_attribute_value("style").c_str()) > 0) {
+ responseStyle.c_str()) > 0) {
xmlAddPrevSibling(responseRoot->cobj(),
xmlNewDocPI(responseDoc->cobj(), BAD_CAST "xml-stylesheet", BAD_CAST buf));
}