- if (!strcmp((const char *) attr->name, "from"))
- rule.regex = mp::xml::get_text(attr->children);
- else if (!strcmp((const char *) attr->name, "to"))
- rule.recipe = mp::xml::get_text(attr->children);
+ if (p->type != XML_ELEMENT_NODE)
+ continue;
+ if (!strcmp((const char *) p->name, "rewrite"))
+ {
+ Replace replace;
+ const struct _xmlAttr *attr;
+ for (attr = p->properties; attr; attr = attr->next)
+ {
+ if (!strcmp((const char *) attr->name, "from"))
+ replace.regex = mp::xml::get_text(attr->children);
+ else if (!strcmp((const char *) attr->name, "to"))
+ replace.recipe = mp::xml::get_text(attr->children);
+ else
+ throw mp::filter::FilterException
+ ("Bad attribute "
+ + std::string((const char *) attr->name)
+ + " in rewrite section of http_rewrite");
+ }
+ yaz_log(YLOG_LOG, "Found rewrite rule from '%s' to '%s'",
+ replace.regex.c_str(), replace.recipe.c_str());
+ replace.parse_groups();
+ if (!replace.regex.empty())
+ rule->replace_list.push_back(replace);
+ }