X-Git-Url: http://lists.indexdata.com/cgi-bin?a=blobdiff_plain;f=src%2Ffilter_query_rewrite.cpp;h=ec3bf0892f6256bdc8c55661440315e3a25774eb;hb=04b73acd94679a3230324eec3ece7a1e4138d8fe;hp=e431b2763e3c50b8222b753173499d469d9dd1ae;hpb=79100c2ae2dac4bdde4f4d46b69e147562b4ec6c;p=metaproxy-moved-to-github.git diff --git a/src/filter_query_rewrite.cpp b/src/filter_query_rewrite.cpp index e431b27..ec3bf08 100644 --- a/src/filter_query_rewrite.cpp +++ b/src/filter_query_rewrite.cpp @@ -1,7 +1,7 @@ -/* $Id: filter_query_rewrite.cpp,v 1.6 2006-03-16 10:40:59 adam Exp $ - Copyright (c) 2005-2006, Index Data. +/* $Id: filter_query_rewrite.cpp,v 1.10 2007-01-25 14:05:54 adam Exp $ + Copyright (c) 2005-2007, Index Data. -%LICENSE% + See the LICENSE file for details */ @@ -10,6 +10,7 @@ #include "package.hpp" #include "util.hpp" +#include "xmlutil.hpp" #include "filter_query_rewrite.hpp" #include @@ -127,7 +128,8 @@ void mp::filter::QueryRewrite::Rep::configure(const xmlNode *ptr) { if (ptr->type != XML_ELEMENT_NODE) continue; - if (!strcmp((const char *) ptr->name, "xslt")) + + if (mp::xml::check_element_mp(ptr, "xslt")) { if (m_stylesheet) { @@ -135,14 +137,29 @@ void mp::filter::QueryRewrite::Rep::configure(const xmlNode *ptr) ("Only one xslt element allowed in query_rewrite filter"); } - std::string fname = mp::xml::get_text(ptr); + 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 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 stylesheet " + ("Failed to read XSLT stylesheet '" + fname - + " in query_rewrite filter"); + + "' in query_rewrite filter"); } } else @@ -163,7 +180,7 @@ static mp::filter::Base* filter_creator() extern "C" { struct metaproxy_1_filter_struct metaproxy_1_filter_query_rewrite = { 0, - "query-rewrite", + "query_rewrite", filter_creator }; }