|
| Rep () |
|
| ~Rep () |
|
void | process (mp::Package &package) const |
|
void | configure (const xmlNode *ptr, bool test_only, const char *path) |
|
Definition at line 41 of file filter_query_rewrite.cpp.
◆ Rep()
mp::filter::QueryRewrite::Rep::Rep |
( |
| ) |
|
◆ ~Rep()
mp::filter::QueryRewrite::Rep::~Rep |
( |
| ) |
|
◆ configure()
void mp::filter::QueryRewrite::Rep::configure |
( |
const xmlNode * |
ptr, |
|
|
bool |
test_only, |
|
|
const char * |
path |
|
) |
| |
Definition at line 154 of file filter_query_rewrite.cpp.
157 for (ptr = ptr->children; ptr; ptr = ptr->next)
159 if (ptr->type != XML_ELEMENT_NODE)
162 if (mp::xml::is_element_mp(ptr,
"xslt"))
166 throw mp::filter::FilterException
167 (
"Only one xslt element allowed in query_rewrite filter");
172 for (
struct _xmlAttr *attr = ptr->properties;
173 attr; attr = attr->next)
175 mp::xml::check_attribute(attr,
"",
"stylesheet");
176 fname = mp::xml::get_text(attr);
179 if (0 == fname.size())
180 throw mp::filter::FilterException
181 (
"Attribute <xslt stylesheet=\""
183 +
"\"> needs XSLT stylesheet path content"
184 +
" in query_rewrite filter");
187 char *cp = yaz_filepath_resolve(fname.c_str(), path, 0, fullpath);
190 throw mp::filter::FilterException(
"Cannot read XSLT " + fname);
196 throw mp::filter::FilterException
197 (
"Failed to read XSLT stylesheet '"
199 +
"' in query_rewrite filter");
202 else if (mp::xml::is_element_mp(ptr,
"charset"))
204 for (
struct _xmlAttr *attr = ptr->properties;
205 attr; attr = attr->next)
207 if (!strcmp((
const char *) attr->name,
"from"))
211 else if (!strcmp((
const char *) attr->name,
"to"))
216 throw mp::filter::FilterException
217 (
"Invalid attribute inside charset inside "
218 "query_rewrite filter");
223 throw mp::filter::FilterException
225 + std::string((
const char *) ptr->name)
226 +
" in query_rewrite filter");
◆ process()
void mp::filter::QueryRewrite::Rep::process |
( |
mp::Package & |
package | ) |
const |
Definition at line 85 of file filter_query_rewrite.cpp.
87 Z_GDU *gdu = package.request().get();
89 if (gdu && gdu->which == Z_GDU_Z3950)
91 Z_APDU *apdu_req = gdu->u.z3950;
92 if (apdu_req->which == Z_APDU_searchRequest)
95 const char *addinfo = 0;
97 Z_SearchRequest *req = apdu_req->u.searchRequest;
101 xmlDocPtr doc_input = 0;
102 yaz_query2xml(req->query, &doc_input);
110 error_code = YAZ_BIB1_MALFORMED_QUERY;
111 addinfo =
"XSLT transform failed for query";
115 const xmlNode *root_element = xmlDocGetRootElement(doc_res);
116 yaz_xml2query(root_element, &req->query, odr,
117 &error_code, &addinfo);
120 xmlFreeDoc(doc_input);
124 (req->query->which == Z_Query_type_1
125 || req->query->which == Z_Query_type_101))
127 yaz_iconv_t cd = yaz_iconv_open(
charset_to.c_str(),
131 int r = yaz_query_charset_convert_rpnquery_check(
132 req->query->u.type_1, odr, cd);
136 error_code = YAZ_BIB1_MALFORMED_QUERY;
137 addinfo =
"could not convert query to target charset";
144 odr.create_searchResponse(apdu_req, error_code, addinfo);
145 package.response() = f_apdu;
148 package.request() = gdu;
◆ charset_from
std::string metaproxy_1::filter::QueryRewrite::Rep::charset_from |
|
private |
◆ charset_to
std::string metaproxy_1::filter::QueryRewrite::Rep::charset_to |
|
private |
◆ m_stylesheet
xsltStylesheetPtr metaproxy_1::filter::QueryRewrite::Rep::m_stylesheet |
|
private |
The documentation for this class was generated from the following file: