100 const char *file_include_path)
102 while (node && mp::xml::check_element_mp(node,
"filter"))
104 const struct _xmlAttr *attr;
105 std::string id_value;
106 std::string type_value;
107 for (attr = node->properties; attr; attr = attr->next)
109 std::string name = std::string((
const char *) attr->name);
112 if (attr->children && attr->children->type == XML_TEXT_NODE)
113 value = std::string((
const char *)attr->children->content);
117 else if (name ==
"type")
119 else if (name ==
"base")
122 throw mp::XMLError(
"Only attribute id or type allowed"
123 " in filter element. Got " + name);
128 yaz_log(YLOG_LOG,
"Loading %s (dlpath %s)",
132 boost::shared_ptr<mp::filter::Base> fb(
m_factory->create(type_value));
134 fb->configure(node, test_only, file_include_path);
137 throw mp::XMLError(
"Filter " + id_value +
" already defined");
141 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
148 const char *file_include_path,
153 if (mp::xml::is_element_mp(node,
"filters"))
155 const xmlNode* node1 =
156 mp::xml::jump_to_children(node, XML_ELEMENT_NODE);
160 else if (mp::xml::check_element_mp(node,
"filter"))
162 const struct _xmlAttr *attr;
163 std::string refid_value;
164 std::string type_value;
165 for (attr = node->properties; attr; attr = attr->next)
167 std::string name = std::string((
const char *) attr->name);
170 if (attr->children && attr->children->type == XML_TEXT_NODE)
171 value = std::string((
const char *)attr->children->content);
175 else if (name ==
"type")
177 else if (name ==
"base")
180 throw mp::XMLError(
"Only attribute 'refid' or 'type'"
181 " allowed for element 'filter'."
184 if (refid_value.length())
186 std::map<std::string,
187 boost::shared_ptr<const mp::filter::Base > >::iterator it;
190 throw mp::XMLError(
"Unknown filter refid "
193 route.
m_list.push_back(it->second);
195 else if (type_value.length())
199 yaz_log(YLOG_LOG,
"Loading %s (dlpath %s)",
203 boost::shared_ptr<mp::filter::Base>
204 filter_base(
m_factory->create(type_value));
206 filter_base->configure(node, test_only, file_include_path);
208 route.
m_list.push_back(filter_base);
212 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
220 const char *file_include_path)
222 mp::xml::check_element_mp(node,
"route");
224 while (mp::xml::is_element_mp(node,
"route"))
226 const struct _xmlAttr *attr;
227 std::string id_value;
228 for (attr = node->properties; attr; attr = attr->next)
230 std::string name = std::string((
const char *) attr->name);
233 if (attr->children && attr->children->type == XML_TEXT_NODE)
234 value = std::string((
const char *)attr->children->content);
238 else if (name ==
"base")
241 throw mp::XMLError(
"Only attribute 'id' allowed for"
249 const xmlNode* node3 = mp::xml::jump_to_children(node, XML_ELEMENT_NODE);
255 std::map<std::string,RouterFleXML::Route>::iterator it;
258 throw mp::XMLError(
"Route id='" + id_value
259 +
"' already exist");
262 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
270 if (mp::xml::is_element_mp(node,
"filters"))
273 mp::xml::jump_to_children(node, XML_ELEMENT_NODE);
276 else if (mp::xml::is_element_mp(node,
"filter"))
279 mp::xml::jump_to_children(node, XML_ELEMENT_NODE);
282 const struct _xmlAttr *attr;
285 for (attr = n->properties; attr; attr = attr->next)
287 if (!strcmp((
const char *) attr->name,
"route"))
291 if (attr->children && attr->children->type == XML_TEXT_NODE)
292 value = std::string((
const char *)attr->children->content);
294 std::map<std::string,RouterFleXML::Route>::iterator it;
298 throw mp::XMLError(
"Route '" + value +
"' does not exist");
302 n = mp::xml::jump_to_next(n, XML_ELEMENT_NODE);
305 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
311 const char *file_include_path)
314 throw mp::XMLError(
"Empty XML Document");
316 const xmlNode* root = xmlDocGetRootElement(doc);
318 if (file_include_path)
320 int r = yaz_xml_include_glob((xmlNode *) root, file_include_path,
321 YAZ_FILE_GLOB_FAIL_NOTEXIST);
323 throw mp::XMLError(
"YAZ XML Include failed");
326 mp::xml::check_element_mp(root,
"metaproxy");
328 const xmlNode* node = mp::xml::jump_to_children(root, XML_ELEMENT_NODE);
330 if (mp::xml::is_element_mp(node,
"dlpath"))
333 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
336 if (mp::xml::check_element_mp(node,
"start"))
338 const struct _xmlAttr *attr;
339 for (attr = node->properties; attr; attr = attr->next)
341 std::string name = std::string((
const char *) attr->name);
344 if (attr->children && attr->children->type == XML_TEXT_NODE)
345 value = std::string((
const char *)attr->children->content);
349 else if (name ==
"base")
352 throw mp::XMLError(
"Only attribute route allowed"
353 " in element 'start'. Got " + name);
355 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
358 if (mp::xml::is_element_mp(node,
"filters"))
362 test_only, file_include_path);
364 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
367 mp::xml::check_element_mp(node,
"routes");
370 test_only, file_include_path);
372 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
375 throw mp::XMLError(
"Unexpected element "
376 + std::string((
const char *)node->name));
379 node = mp::xml::jump_to_children(root, XML_ELEMENT_NODE);
382 if (mp::xml::is_element_mp(node,
"filters"))
384 mp::xml::jump_to_children(node,
386 else if (mp::xml::is_element_mp(node,
"routes"))
388 const xmlNode* n = mp::xml::jump_to_children(node,
392 if (mp::xml::is_element_mp(n,
"route"))
395 mp::xml::jump_to_children(n, XML_ELEMENT_NODE));
398 n = mp::xml::jump_to_next(n, XML_ELEMENT_NODE);
401 node = mp::xml::jump_to_next(node, XML_ELEMENT_NODE);
403 std::map<std::string,RouterFleXML::Route>::iterator it;
406 throw mp::XMLError(
"Start route '" +
m_start_route +
"' not found");