- std::cout << "REGEX Error code=" << e.code()
- << " position=" << e.position() << "\n";
- }
-
- //std::cout << "QUERY OUT '" << query_out << "'\n";
- // still need to fold this new rpn query string into Z_Query structure...
-}
-
-
-
-void yp2::filter::QueryRewrite::Rep::configure(const xmlNode *filter)
-{
-
- //std::cout << "XML node '" << filter->name << "'\n";
- yp2::xml::check_element_yp2(filter, "filter");
-
- const xmlNode* regex
- = yp2::xml::jump_to_children(filter, XML_ELEMENT_NODE);
-
- while (regex){
- //std::cout << "XML node '" << regex->name << "'\n";
- yp2::xml::check_element_yp2(regex, "regex");
-
- // parsing action
-// const xmlNode* action
-// = yp2::xml::jump_to_children(regex, XML_ATTRIBUTE_NODE);
-// if (action){
-// std::cout << "XML node '" << action->name << "' '";
-// std::cout << yp2::xml::get_text(action) << "'\n";
-// //yp2::xml::check_element_yp2(expression, "expression");
-// }
-
- // parsing regex expression
- std::string expr;
- const xmlNode* expression
- = yp2::xml::jump_to_children(regex, XML_ELEMENT_NODE);
- if (expression){
- yp2::xml::check_element_yp2(expression, "expression");
- expr = yp2::xml::get_text(expression);
- //std::cout << "XML node '" << expression->name << "' '";
- //std::cout << yp2::xml::get_text(expression) << "'\n";
- }
-
- // parsing regex format
- std::string form;
- const xmlNode* format
- = yp2::xml::jump_to_next(expression, XML_ELEMENT_NODE);
- if (format){
- yp2::xml::check_element_yp2(format, "format");
- form = yp2::xml::get_text(format);
- //std::cout << "XML node '" << format->name << "' '";
- //std::cout << yp2::xml::get_text(format) << "'\n";
+ if (ptr->type != XML_ELEMENT_NODE)
+ continue;
+
+ if (mp::xml::check_element_mp(ptr, "xslt"))
+ {
+ if (m_stylesheet)
+ {
+ throw mp::filter::FilterException
+ ("Only one xslt element allowed in query_rewrite filter");
+ }
+
+ std::string fname;// = mp::xml::get_text(ptr);
+
+ for (struct _xmlAttr *attr = ptr->properties;
+ attr; attr = attr->next)
+ {
+ mp::xml::check_attribute(attr, "", "stylesheet");
+ fname = mp::xml::get_text(attr);
+ }
+
+ if (0 == fname.size())
+ throw mp::filter::FilterException
+ ("Attribute <xslt stylesheet=\""
+ + fname
+ + "\"> needs XSLT stylesheet path content"
+ + " in query_rewrite filter");
+
+ m_stylesheet = xsltParseStylesheetFile(BAD_CAST fname.c_str());
+ if (!m_stylesheet)
+ {
+ throw mp::filter::FilterException
+ ("Failed to read XSLT stylesheet '"
+ + fname
+ + "' in query_rewrite filter");
+ }