X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;ds=sidebyside;f=src%2Ffilter_query_rewrite.cpp;h=2111fc5ba0407ea138aa6319fd972f6e39c0fb27;hb=d0123337d70b0fb97b578cc57467bb94980f1014;hp=fa507072bbd93084003d87290eba4338788bac4d;hpb=1e61b0aa05e2351e33d909f7503eaf936a2d9bb0;p=metaproxy-moved-to-github.git diff --git a/src/filter_query_rewrite.cpp b/src/filter_query_rewrite.cpp index fa50707..2111fc5 100644 --- a/src/filter_query_rewrite.cpp +++ b/src/filter_query_rewrite.cpp @@ -1,15 +1,27 @@ -/* $Id: filter_query_rewrite.cpp,v 1.8 2006-06-10 14:29:12 adam Exp $ - Copyright (c) 2005-2006, Index Data. +/* This file is part of Metaproxy. + Copyright (C) 2005-2009 Index Data - See the LICENSE file for details - */ +Metaproxy is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Metaproxy is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "config.hpp" #include "filter.hpp" #include "package.hpp" #include "util.hpp" +#include "xmlutil.hpp" #include "filter_query_rewrite.hpp" #include @@ -60,7 +72,7 @@ void yf::QueryRewrite::process(mp::Package &package) const m_p->process(package); } -void mp::filter::QueryRewrite::configure(const xmlNode *ptr) +void mp::filter::QueryRewrite::configure(const xmlNode *ptr, bool test_only) { m_p->configure(ptr); } @@ -127,7 +139,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 +148,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 @@ -171,8 +199,9 @@ extern "C" { /* * Local variables: * c-basic-offset: 4 + * c-file-style: "Stroustrup" * indent-tabs-mode: nil - * c-file-style: "stroustrup" * End: * vim: shiftwidth=4 tabstop=8 expandtab */ +