- void parse_xml_config_dom() {
-
- if (!m_xmlconf_doc){
- std::cerr << "XML configuration DOM pointer empty" << std::endl;
- }
-
- const xmlNode* root = xmlDocGetRootElement(m_xmlconf_doc);
-
- if ((std::string((const char *) root->name) != "yp2")
- || (std::string((const char *)(root->ns->href))
- != "http://indexdata.dk/yp2/config/1")
- )
- xml_dom_error(root,
- "expected <yp2 xmlns=\"http://indexdata.dk/yp2/config/1\">, got ");
+ std::map<std::string,
+ RouterFleXML::Route>::iterator m_route_it;
+ std::list<boost::shared_ptr <const mp::filter::Base> >::iterator m_filter_it;
+ };
+}
+
+void mp::RouterFleXML::Rep::parse_xml_filters(xmlDocPtr doc,
+ const xmlNode *node,
+ bool test_only,
+ const char *file_include_path)
+{
+ unsigned int filter_nr = 0;
+ while (node && mp::xml::check_element_mp(node, "filter"))
+ {
+ filter_nr++;
+
+ const struct _xmlAttr *attr;
+ std::string id_value;
+ std::string type_value;
+ for (attr = node->properties; attr; attr = attr->next)
+ {
+ std::string name = std::string((const char *) attr->name);
+ std::string value;
+
+ if (attr->children && attr->children->type == XML_TEXT_NODE)
+ value = std::string((const char *)attr->children->content);
+
+ if (name == "id")
+ id_value = value;
+ else if (name == "type")
+ type_value = value;
+ else
+ throw mp::XMLError("Only attribute id or type allowed"
+ " in filter element. Got " + name);
+ }
+
+ if (!m_factory->exist(type_value))
+ {
+ yaz_log(YLOG_LOG, "Loading %s (dlpath %s)",
+ type_value.c_str(), m_dl_path.c_str());
+ m_factory->add_creator_dl(type_value, m_dl_path);
+ }
+ mp::filter::Base* filter_base = m_factory->create(type_value);
+
+ filter_base->configure(node, test_only, file_include_path);
+
+ if (m_id_filter_map.find(id_value) != m_id_filter_map.end())
+ throw mp::XMLError("Filter " + id_value + " already defined");
+
+ m_id_filter_map[id_value] =
+ boost::shared_ptr<mp::filter::Base>(filter_base);
+
+ node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
+ }
+}
+
+void mp::RouterFleXML::Rep::parse_xml_filters1(xmlDocPtr doc,
+ const xmlNode *node,
+ bool test_only,
+ const char *file_include_path,
+ Route &route)
+{
+ while (node)
+ {
+ if (mp::xml::is_element_mp(node, "filters"))
+ {
+ const xmlNode* node1 =
+ mp::xml::jump_to_children(node, XML_ELEMENT_NODE);
+
+ parse_xml_filters1(doc, node1, test_only, file_include_path, route);
+ }
+ else if (mp::xml::check_element_mp(node, "filter"))
+ {
+ const struct _xmlAttr *attr;
+ std::string refid_value;
+ std::string type_value;
+ for (attr = node->properties; attr; attr = attr->next)
+ {
+ std::string name = std::string((const char *) attr->name);
+ std::string value;