-/* $Id: filter_query_rewrite.cpp,v 1.7 2006-03-27 12:53:05 adam Exp $
- Copyright (c) 2005-2006, Index Data.
+/* $Id: filter_query_rewrite.cpp,v 1.12 2008-02-20 15:07:52 adam Exp $
+ Copyright (c) 2005-2007, Index Data.
-%LICENSE%
- */
+This file is part of Metaproxy.
+
+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 Metaproxy; see the file LICENSE. If not, write to the
+Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.
+ */
#include "config.hpp"
#include "filter.hpp"
#include "package.hpp"
#include "util.hpp"
+#include "xmlutil.hpp"
#include "filter_query_rewrite.hpp"
#include <yaz/zgdu.h>
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);
}
{
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)
{
("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 <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 stylesheet "
+ ("Failed to read XSLT stylesheet '"
+ fname
- + " in query_rewrite filter");
+ + "' in query_rewrite filter");
}
}
else