IDZEBRA  2.2.7
mod_alvis.c
Go to the documentation of this file.
1 /* This file is part of the Zebra server.
2  Copyright (C) Index Data
3 
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
7 version.
8 
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 
18 */
19 
20 #if HAVE_CONFIG_H
21 #include <config.h>
22 #endif
23 #include <stdio.h>
24 #include <assert.h>
25 #include <ctype.h>
26 
27 #include <yaz/diagbib1.h>
28 #include <yaz/tpath.h>
29 #include <yaz/oid_db.h>
30 #include <yaz/snprintf.h>
31 
32 #include <libxml/xmlversion.h>
33 #include <libxml/parser.h>
34 #include <libxml/tree.h>
35 #include <libxml/xmlIO.h>
36 #include <libxml/xmlreader.h>
37 #include <libxslt/transform.h>
38 #include <libxslt/xsltutils.h>
39 
40 #if YAZ_HAVE_EXSLT
41 #include <libexslt/exslt.h>
42 #endif
43 
44 #include <idzebra/util.h>
45 #include <idzebra/recctrl.h>
46 
47 struct filter_schema {
48  const char *name;
49  const char *identifier;
50  const char *stylesheet;
52  const char *default_schema;
53  /* char default_schema; */
54  xsltStylesheetPtr stylesheet_xsp;
55 };
56 
57 struct filter_info {
58  xmlDocPtr doc;
59  char *fname;
60  char *full_name;
61  const char *profile_path;
63  const char *split_path;
64  ODR odr;
66  xmlTextReaderPtr reader;
67 };
68 
69 #define ZEBRA_SCHEMA_XSLT_NS "http://indexdata.dk/zebra/xslt/1"
70 
71 #define XML_STRCMP(a,b) strcmp((char*)a, b)
72 #define XML_STRLEN(a) strlen((char*)a)
73 
74 static const char *zebra_xslt_ns = ZEBRA_SCHEMA_XSLT_NS;
75 
76 static void set_param_str(const char **params, const char *name,
77  const char *value, ODR odr)
78 {
79  char *quoted = odr_malloc(odr, 3 + strlen(value));
80  yaz_snprintf(quoted, 3 + strlen(value), "'" ZINT_FORMAT "'", value);
81  while (*params)
82  params++;
83  params[0] = name;
84  params[1] = quoted;
85  params[2] = 0;
86 }
87 
88 static void set_param_int(const char **params, const char *name,
89  zint value, ODR odr)
90 {
91  char *quoted = odr_malloc(odr, 30); /* 25 digits enough for 2^64 */
92  yaz_snprintf(quoted, 30, "'" ZINT_FORMAT "'", value);
93  while (*params)
94  params++;
95  params[0] = name;
96  params[1] = quoted;
97  params[2] = 0;
98 }
99 
100 #define ENABLE_INPUT_CALLBACK 0
101 
102 #if ENABLE_INPUT_CALLBACK
103 static int zebra_xmlInputMatchCallback (char const *filename)
104 {
105  yaz_log(YLOG_LOG, "match %s", filename);
106  return 0;
107 }
108 
109 static void * zebra_xmlInputOpenCallback (char const *filename)
110 {
111  return 0;
112 }
113 
114 static int zebra_xmlInputReadCallback (void * context, char * buffer, int len)
115 {
116  return 0;
117 }
118 
119 static int zebra_xmlInputCloseCallback (void * context)
120 {
121  return 0;
122 }
123 #endif
124 
125 static void *filter_init(Res res, RecType recType)
126 {
127  struct filter_info *tinfo = (struct filter_info *) xmalloc(sizeof(*tinfo));
128  tinfo->reader = 0;
129  tinfo->fname = 0;
130  tinfo->full_name = 0;
131  tinfo->profile_path = 0;
132  tinfo->split_level = 0;
133  tinfo->split_path = 0;
134  tinfo->odr = odr_createmem(ODR_ENCODE);
135  tinfo->doc = 0;
136  tinfo->schemas = 0;
137 
138 #if YAZ_HAVE_EXSLT
139  exsltRegisterAll();
140 #endif
141 
142 #if ENABLE_INPUT_CALLBACK
143  xmlRegisterDefaultInputCallbacks();
144  xmlRegisterInputCallbacks(zebra_xmlInputMatchCallback,
145  zebra_xmlInputOpenCallback,
146  zebra_xmlInputReadCallback,
147  zebra_xmlInputCloseCallback);
148 #endif
149  return tinfo;
150 }
151 
152 static int attr_content(struct _xmlAttr *attr, const char *name,
153  const char **dst_content)
154 {
155  if (!XML_STRCMP(attr->name, name) && attr->children
156  && attr->children->type == XML_TEXT_NODE)
157  {
158  *dst_content = (const char *)(attr->children->content);
159  return 1;
160  }
161  return 0;
162 }
163 
164 static void destroy_schemas(struct filter_info *tinfo)
165 {
166  struct filter_schema *schema = tinfo->schemas;
167  while (schema)
168  {
169  struct filter_schema *schema_next = schema->next;
170  if (schema->stylesheet_xsp)
171  xsltFreeStylesheet(schema->stylesheet_xsp);
172  xfree(schema);
173  schema = schema_next;
174  }
175  tinfo->schemas = 0;
176  xfree(tinfo->fname);
177  if (tinfo->doc)
178  xmlFreeDoc(tinfo->doc);
179  tinfo->doc = 0;
180 }
181 
182 static ZEBRA_RES create_schemas(struct filter_info *tinfo, const char *fname)
183 {
184  char tmp_full_name[1024];
185  xmlNodePtr ptr;
186  tinfo->fname = xstrdup(fname);
187 
188  if (yaz_filepath_resolve(tinfo->fname, tinfo->profile_path,
189  NULL, tmp_full_name))
190  tinfo->full_name = xstrdup(tmp_full_name);
191  else
192  tinfo->full_name = xstrdup(tinfo->fname);
193 
194  yaz_log(YLOG_LOG, "alvis filter: loading config file %s", tinfo->full_name);
195 
196  tinfo->doc = xmlParseFile(tinfo->full_name);
197 
198  if (!tinfo->doc)
199  {
200  yaz_log(YLOG_WARN, "alvis filter: could not parse config file %s",
201  tinfo->full_name);
202 
203  return ZEBRA_FAIL;
204  }
205 
206  ptr = xmlDocGetRootElement(tinfo->doc);
207  if (!ptr || ptr->type != XML_ELEMENT_NODE
208  || XML_STRCMP(ptr->name, "schemaInfo"))
209  {
210  yaz_log(YLOG_WARN,
211  "alvis filter: config file %s :"
212  " expected root element <schemaInfo>",
213  tinfo->full_name);
214  return ZEBRA_FAIL;
215  }
216 
217  for (ptr = ptr->children; ptr; ptr = ptr->next)
218  {
219  if (ptr->type != XML_ELEMENT_NODE)
220  continue;
221  if (!XML_STRCMP(ptr->name, "schema"))
222  {
223  struct _xmlAttr *attr;
224  struct filter_schema *schema = xmalloc(sizeof(*schema));
225  schema->name = 0;
226  schema->identifier = 0;
227  schema->stylesheet = 0;
228  schema->default_schema = 0;
229  schema->next = tinfo->schemas;
230  schema->stylesheet_xsp = 0;
231  tinfo->schemas = schema;
232  for (attr = ptr->properties; attr; attr = attr->next)
233  {
234  attr_content(attr, "identifier", &schema->identifier);
235  attr_content(attr, "name", &schema->name);
236  attr_content(attr, "stylesheet", &schema->stylesheet);
237  attr_content(attr, "default", &schema->default_schema);
238  }
239  /*yaz_log(YLOG_LOG, "XSLT add %s %s %s",
240  schema->name, schema->identifier, schema->stylesheet); */
241 
242  /* find requested schema */
243 
244  if (schema->stylesheet)
245  {
246  char tmp_xslt_full_name[1024];
247  if (!yaz_filepath_resolve(schema->stylesheet, tinfo->profile_path,
248  NULL, tmp_xslt_full_name))
249  {
250  yaz_log(YLOG_WARN,
251  "alvis filter: stylesheet %s not found in path %s",
252  schema->stylesheet, tinfo->profile_path);
253  return ZEBRA_FAIL;
254  }
255  schema->stylesheet_xsp
256  = xsltParseStylesheetFile((const xmlChar*) tmp_xslt_full_name);
257  if (!schema->stylesheet_xsp)
258  {
259  yaz_log(YLOG_WARN,
260  "alvis filter: could not parse xslt stylesheet %s",
261  tmp_xslt_full_name);
262  return ZEBRA_FAIL;
263  }
264  }
265  }
266  else if (!XML_STRCMP(ptr->name, "split"))
267  {
268  struct _xmlAttr *attr;
269  for (attr = ptr->properties; attr; attr = attr->next)
270  {
271  const char *split_level_str = 0;
272  attr_content(attr, "level", &split_level_str);
273  tinfo->split_level =
274  split_level_str ? atoi(split_level_str) : 0;
275  }
276  }
277  else
278  {
279  yaz_log(YLOG_WARN, "Bad element %s in %s", ptr->name, fname);
280  return ZEBRA_FAIL;
281  }
282  }
283  return ZEBRA_OK;
284 }
285 
286 static struct filter_schema *lookup_schema(struct filter_info *tinfo,
287  const char *est)
288 {
289  struct filter_schema *schema;
290 
291  for (schema = tinfo->schemas; schema; schema = schema->next)
292  {
293  /* find requested schema */
294  if (est)
295  {
296  if (schema->identifier && !strcmp(schema->identifier, est))
297  return schema;
298 
299  if (schema->name && !strcmp(schema->name, est))
300  return schema;
301  }
302  /* or return default schema if defined */
303  else if (schema->default_schema)
304  return schema;
305  }
306 
307  /* return first schema if no default schema defined */
308  if (tinfo->schemas)
309  return tinfo->schemas;
310 
311  return 0;
312 }
313 
314 static ZEBRA_RES filter_config(void *clientData, Res res, const char *args)
315 {
316  struct filter_info *tinfo = clientData;
317  if (!args || !*args)
318  {
319  yaz_log(YLOG_WARN, "alvis filter: need config file");
320  return ZEBRA_FAIL;
321  }
322 
323  if (tinfo->fname && !strcmp(args, tinfo->fname))
324  return ZEBRA_OK;
325 
326  tinfo->profile_path = res_get(res, "profilePath");
327  yaz_log(YLOG_LOG, "alvis filter: profilePath %s", tinfo->profile_path);
328 
329  destroy_schemas(tinfo);
330  return create_schemas(tinfo, args);
331 }
332 
333 static void filter_destroy(void *clientData)
334 {
335  struct filter_info *tinfo = clientData;
336  destroy_schemas(tinfo);
337  xfree(tinfo->full_name);
338  if (tinfo->reader)
339  xmlFreeTextReader(tinfo->reader);
340  odr_destroy(tinfo->odr);
341  xfree(tinfo);
342 }
343 
344 static int ioread_ex(void *context, char *buffer, int len)
345 {
346  struct recExtractCtrl *p = context;
347  return p->stream->readf(p->stream, buffer, len);
348 }
349 
350 static int ioclose_ex(void *context)
351 {
352  return 0;
353 }
354 
355 static void index_cdata(struct filter_info *tinfo, struct recExtractCtrl *ctrl,
356  xmlNodePtr ptr, RecWord *recWord)
357 {
358  for(; ptr; ptr = ptr->next)
359  {
360  index_cdata(tinfo, ctrl, ptr->children, recWord);
361  if (ptr->type != XML_TEXT_NODE)
362  continue;
363  recWord->term_buf = (const char *)ptr->content;
364  recWord->term_len = XML_STRLEN(ptr->content);
365  (*ctrl->tokenAdd)(recWord);
366  }
367 }
368 
369 static void index_node(struct filter_info *tinfo, struct recExtractCtrl *ctrl,
370  xmlNodePtr ptr, RecWord *recWord)
371 {
372  for(; ptr; ptr = ptr->next)
373  {
374  index_node(tinfo, ctrl, ptr->children, recWord);
375  if (ptr->type != XML_ELEMENT_NODE || !ptr->ns ||
376  XML_STRCMP(ptr->ns->href, zebra_xslt_ns))
377  continue;
378  if (!XML_STRCMP(ptr->name, "index"))
379  {
380  const char *name_str = 0;
381  const char *type_str = 0;
382  const char *xpath_str = 0;
383  struct _xmlAttr *attr;
384  for (attr = ptr->properties; attr; attr = attr->next)
385  {
386  attr_content(attr, "name", &name_str);
387  attr_content(attr, "xpath", &xpath_str);
388  attr_content(attr, "type", &type_str);
389  }
390  if (name_str)
391  {
392  const char *prev_type = recWord->index_type; /* save default type */
393 
394  if (type_str && *type_str)
395  recWord->index_type = (const char *) type_str; /* type was given */
396  recWord->index_name = name_str;
397  index_cdata(tinfo, ctrl, ptr->children, recWord);
398 
399  recWord->index_type = prev_type; /* restore it again */
400  }
401  }
402  }
403 }
404 
405 static void index_record(struct filter_info *tinfo,struct recExtractCtrl *ctrl,
406  xmlNodePtr ptr, RecWord *recWord)
407 {
408  const char *type_str = "update";
409 
410  if (ptr && ptr->type == XML_ELEMENT_NODE && ptr->ns &&
411  !XML_STRCMP(ptr->ns->href, zebra_xslt_ns)
412  && !XML_STRCMP(ptr->name, "record"))
413  {
414  const char *id_str = 0;
415  const char *rank_str = 0;
416  struct _xmlAttr *attr;
417  for (attr = ptr->properties; attr; attr = attr->next)
418  {
419  attr_content(attr, "type", &type_str);
420  attr_content(attr, "id", &id_str);
421  attr_content(attr, "rank", &rank_str);
422  }
423  if (id_str)
424  sscanf(id_str, "%255s", ctrl->match_criteria);
425 
426  if (rank_str)
427  ctrl->staticrank = atozint(rank_str);
428  ptr = ptr->children;
429  }
430 
431  if (!strcmp("update", type_str))
432  index_node(tinfo, ctrl, ptr, recWord);
433  else if (!strcmp("delete", type_str))
434  yaz_log(YLOG_WARN, "alvis filter delete: to be implemented");
435  else
436  yaz_log(YLOG_WARN, "alvis filter: unknown record type '%s'",
437  type_str);
438 }
439 
440 static int extract_doc(struct filter_info *tinfo, struct recExtractCtrl *p,
441  xmlDocPtr doc)
442 {
443  RecWord recWord;
444  const char *params[10];
445  xmlChar *buf_out;
446  int len_out;
447 
448  struct filter_schema *schema = lookup_schema(tinfo, zebra_xslt_ns);
449 
450  params[0] = 0;
451  set_param_str(params, "schema", zebra_xslt_ns, tinfo->odr);
452 
453  (*p->init)(p, &recWord);
454 
455  if (schema && schema->stylesheet_xsp)
456  {
457  xmlNodePtr root_ptr;
458  xmlDocPtr resDoc =
459  xsltApplyStylesheet(schema->stylesheet_xsp,
460  doc, params);
461  if (p->flagShowRecords)
462  {
463  xmlDocDumpMemory(resDoc, &buf_out, &len_out);
464  fwrite(buf_out, len_out, 1, stdout);
465  xmlFree(buf_out);
466  }
467  root_ptr = xmlDocGetRootElement(resDoc);
468  if (root_ptr)
469  index_record(tinfo, p, root_ptr, &recWord);
470  else
471  {
472  yaz_log(YLOG_WARN, "No root for index XML record."
473  " split_level=%d stylesheet=%s",
474  tinfo->split_level, schema->stylesheet);
475  }
476  xmlFreeDoc(resDoc);
477  }
478  xmlDocDumpMemory(doc, &buf_out, &len_out);
479  if (p->flagShowRecords)
480  fwrite(buf_out, len_out, 1, stdout);
481  if (p->setStoreData)
482  (*p->setStoreData)(p, buf_out, len_out);
483  xmlFree(buf_out);
484 
485  xmlFreeDoc(doc);
486  return RECCTRL_EXTRACT_OK;
487 }
488 
489 static int extract_split(struct filter_info *tinfo, struct recExtractCtrl *p)
490 {
491  int ret;
492 
493  if (p->first_record)
494  {
495  if (tinfo->reader)
496  xmlFreeTextReader(tinfo->reader);
497  tinfo->reader = xmlReaderForIO(ioread_ex, ioclose_ex,
498  p /* I/O handler */,
499  0 /* URL */,
500  0 /* encoding */,
501  XML_PARSE_XINCLUDE
502  | XML_PARSE_NOENT
503  | XML_PARSE_NONET);
504  }
505  if (!tinfo->reader)
507 
508  ret = xmlTextReaderRead(tinfo->reader);
509  while (ret == 1)
510  {
511  int type = xmlTextReaderNodeType(tinfo->reader);
512  int depth = xmlTextReaderDepth(tinfo->reader);
513  if (type == XML_READER_TYPE_ELEMENT && tinfo->split_level == depth)
514  {
515  xmlNodePtr ptr = xmlTextReaderExpand(tinfo->reader);
516  if (ptr)
517  {
518  xmlNodePtr ptr2 = xmlCopyNode(ptr, 1);
519  xmlDocPtr doc = xmlNewDoc((const xmlChar*) "1.0");
520 
521  xmlDocSetRootElement(doc, ptr2);
522 
523  return extract_doc(tinfo, p, doc);
524  }
525  else
526  {
527  xmlFreeTextReader(tinfo->reader);
528  tinfo->reader = 0;
530  }
531  }
532  ret = xmlTextReaderRead(tinfo->reader);
533  }
534  xmlFreeTextReader(tinfo->reader);
535  tinfo->reader = 0;
536  return RECCTRL_EXTRACT_EOF;
537 }
538 
539 static int extract_full(struct filter_info *tinfo, struct recExtractCtrl *p)
540 {
541  if (p->first_record) /* only one record per stream */
542  {
543  xmlDocPtr doc = xmlReadIO(ioread_ex, ioclose_ex, p /* I/O handler */,
544  0 /* URL */,
545  0 /* encoding */,
546  XML_PARSE_XINCLUDE
547  | XML_PARSE_NOENT
548  | XML_PARSE_NONET);
549  if (!doc)
551  /* else {
552  xmlNodePtr root = xmlDocGetRootElement(doc);
553  if (!root)
554  return RECCTRL_EXTRACT_ERROR_GENERIC;
555  } */
556 
557  return extract_doc(tinfo, p, doc);
558  }
559  else
560  return RECCTRL_EXTRACT_EOF;
561 }
562 
563 static int filter_extract(void *clientData, struct recExtractCtrl *p)
564 {
565  struct filter_info *tinfo = clientData;
566 
567  odr_reset(tinfo->odr);
568  if (tinfo->split_level == 0 || p->setStoreData == 0)
569  return extract_full(tinfo, p);
570  else
571  return extract_split(tinfo, p);
572 }
573 
574 static int ioread_ret(void *context, char *buffer, int len)
575 {
576  struct recRetrieveCtrl *p = context;
577  return p->stream->readf(p->stream, buffer, len);
578 }
579 
580 static int ioclose_ret(void *context)
581 {
582  return 0;
583 }
584 
585 static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
586 {
587  /* const char *esn = zebra_xslt_ns; */
588  const char *esn = 0;
589  const char *params[32];
590  struct filter_info *tinfo = clientData;
591  xmlDocPtr resDoc;
592  xmlDocPtr doc;
593  struct filter_schema *schema;
594 
595  if (p->comp)
596  {
597  if (p->comp->which == Z_RecordComp_simple
598  && p->comp->u.simple->which == Z_ElementSetNames_generic)
599  {
600  esn = p->comp->u.simple->u.generic;
601  }
602  else if (p->comp->which == Z_RecordComp_complex
603  && p->comp->u.complex->generic->elementSpec
604  && p->comp->u.complex->generic->elementSpec->which ==
605  Z_ElementSpec_elementSetName)
606  {
607  esn = p->comp->u.complex->generic->elementSpec->u.elementSetName;
608  }
609  }
610  schema = lookup_schema(tinfo, esn);
611  if (!schema)
612  {
613  p->diagnostic =
614  YAZ_BIB1_SPECIFIED_ELEMENT_SET_NAME_NOT_VALID_FOR_SPECIFIED_;
615  return 0;
616  }
617 
618  params[0] = 0;
619  set_param_int(params, "id", p->localno, p->odr);
620  if (p->fname)
621  set_param_str(params, "filename", p->fname, p->odr);
622  if (p->staticrank >= 0)
623  set_param_int(params, "rank", p->staticrank, p->odr);
624 
625  if (esn)
626  set_param_str(params, "schema", esn, p->odr);
627  else
628  if (schema->name)
629  set_param_str(params, "schema", schema->name, p->odr);
630  else if (schema->identifier)
631  set_param_str(params, "schema", schema->identifier, p->odr);
632  else
633  set_param_str(params, "schema", "", p->odr);
634 
635  if (p->score >= 0)
636  set_param_int(params, "score", p->score, p->odr);
637  set_param_int(params, "size", p->recordSize, p->odr);
638 
639  doc = xmlReadIO(ioread_ret, ioclose_ret, p /* I/O handler */,
640  0 /* URL */,
641  0 /* encoding */,
642  XML_PARSE_XINCLUDE | XML_PARSE_NOENT | XML_PARSE_NONET);
643  if (!doc)
644  {
645  p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS;
646  return 0;
647  }
648 
649  if (!schema->stylesheet_xsp)
650  resDoc = doc;
651  else
652  {
653  resDoc = xsltApplyStylesheet(schema->stylesheet_xsp,
654  doc, params);
655  xmlFreeDoc(doc);
656  }
657  if (!resDoc)
658  {
659  p->diagnostic = YAZ_BIB1_SYSTEM_ERROR_IN_PRESENTING_RECORDS;
660  }
661  else if (!p->input_format
662  || !oid_oidcmp(p->input_format, yaz_oid_recsyn_xml))
663  {
664  xmlChar *buf_out;
665  int len_out;
666 
667  if (schema->stylesheet_xsp)
668  xsltSaveResultToString(&buf_out, &len_out, resDoc,
669  schema->stylesheet_xsp);
670  else
671  xmlDocDumpMemory(resDoc, &buf_out, &len_out);
672 
673  p->output_format = yaz_oid_recsyn_xml;
674  p->rec_len = len_out;
675  p->rec_buf = odr_malloc(p->odr, p->rec_len);
676  memcpy(p->rec_buf, buf_out, p->rec_len);
677  xmlFree(buf_out);
678  }
679  else if (!oid_oidcmp(p->output_format, yaz_oid_recsyn_sutrs))
680  {
681  xmlChar *buf_out;
682  int len_out;
683 
684  if (schema->stylesheet_xsp)
685  xsltSaveResultToString(&buf_out, &len_out, resDoc,
686  schema->stylesheet_xsp);
687  else
688  xmlDocDumpMemory(resDoc, &buf_out, &len_out);
689 
690  p->output_format = yaz_oid_recsyn_sutrs;
691  p->rec_len = len_out;
692  p->rec_buf = odr_malloc(p->odr, p->rec_len);
693  memcpy(p->rec_buf, buf_out, p->rec_len);
694 
695  xmlFree(buf_out);
696  }
697  else
698  {
699  p->diagnostic = YAZ_BIB1_RECORD_SYNTAX_UNSUPP;
700  }
701  xmlFreeDoc(resDoc);
702  return 0;
703 }
704 
705 static struct recType filter_type = {
706  0,
707  "alvis",
708  filter_init,
713 };
714 
715 RecType
716 #if IDZEBRA_STATIC_ALVIS
717 idzebra_filter_alvis
718 #else
720 #endif
721 
722 [] = {
723  &filter_type,
724  0,
725 };
726 /*
727  * Local variables:
728  * c-basic-offset: 4
729  * c-file-style: "Stroustrup"
730  * indent-tabs-mode: nil
731  * End:
732  * vim: shiftwidth=4 tabstop=8 expandtab
733  */
734 
static void index_cdata(struct filter_info *tinfo, struct recExtractCtrl *ctrl, xmlNodePtr ptr, RecWord *recWord)
Definition: mod_alvis.c:355
static void filter_destroy(void *clientData)
Definition: mod_alvis.c:333
#define ZEBRA_SCHEMA_XSLT_NS
Definition: mod_alvis.c:69
static struct filter_schema * lookup_schema(struct filter_info *tinfo, const char *est)
Definition: mod_alvis.c:286
RecType idzebra_filter[]
Definition: mod_alvis.c:722
#define XML_STRCMP(a, b)
Definition: mod_alvis.c:71
static ZEBRA_RES create_schemas(struct filter_info *tinfo, const char *fname)
Definition: mod_alvis.c:182
#define XML_STRLEN(a)
Definition: mod_alvis.c:72
static int filter_retrieve(void *clientData, struct recRetrieveCtrl *p)
Definition: mod_alvis.c:585
static int ioclose_ret(void *context)
Definition: mod_alvis.c:580
static int filter_extract(void *clientData, struct recExtractCtrl *p)
Definition: mod_alvis.c:563
static struct recType filter_type
Definition: mod_alvis.c:705
static int ioclose_ex(void *context)
Definition: mod_alvis.c:350
static void set_param_int(const char **params, const char *name, zint value, ODR odr)
Definition: mod_alvis.c:88
static int ioread_ret(void *context, char *buffer, int len)
Definition: mod_alvis.c:574
static int attr_content(struct _xmlAttr *attr, const char *name, const char **dst_content)
Definition: mod_alvis.c:152
static void * filter_init(Res res, RecType recType)
Definition: mod_alvis.c:125
static void index_record(struct filter_info *tinfo, struct recExtractCtrl *ctrl, xmlNodePtr ptr, RecWord *recWord)
Definition: mod_alvis.c:405
static void set_param_str(const char **params, const char *name, const char *value, ODR odr)
Definition: mod_alvis.c:76
static int extract_doc(struct filter_info *tinfo, struct recExtractCtrl *p, xmlDocPtr doc)
Definition: mod_alvis.c:440
static void index_node(struct filter_info *tinfo, struct recExtractCtrl *ctrl, xmlNodePtr ptr, RecWord *recWord)
Definition: mod_alvis.c:369
static int ioread_ex(void *context, char *buffer, int len)
Definition: mod_alvis.c:344
static void destroy_schemas(struct filter_info *tinfo)
Definition: mod_alvis.c:164
static int extract_full(struct filter_info *tinfo, struct recExtractCtrl *p)
Definition: mod_alvis.c:539
static int extract_split(struct filter_info *tinfo, struct recExtractCtrl *p)
Definition: mod_alvis.c:489
static const char * zebra_xslt_ns
Definition: mod_alvis.c:74
static ZEBRA_RES filter_config(void *clientData, Res res, const char *args)
Definition: mod_alvis.c:314
#define RECCTRL_EXTRACT_EOF
Definition: recctrl.h:164
#define RECCTRL_EXTRACT_ERROR_GENERIC
Definition: recctrl.h:165
#define RECCTRL_EXTRACT_OK
Definition: recctrl.h:163
const char * res_get(Res r, const char *name)
Definition: res.c:294
const char * term_buf
Definition: recctrl.h:56
const char * index_type
Definition: recctrl.h:52
int term_len
Definition: recctrl.h:58
const char * index_name
Definition: recctrl.h:54
int(* readf)(struct ZebraRecStream *s, char *buf, size_t count)
read function
Definition: recctrl.h:75
const char * split_path
Definition: mod_alvis.c:63
char * fname
Definition: mod_alvis.c:59
int split_level
Definition: mod_alvis.c:62
char * full_name
Definition: mod_alvis.c:60
struct filter_schema * schemas
Definition: mod_alvis.c:65
const char * profile_path
Definition: mod_alvis.c:61
xmlDocPtr doc
Definition: mod_alvis.c:58
xmlTextReaderPtr reader
Definition: mod_alvis.c:66
xsltStylesheetPtr stylesheet_xsp
Definition: mod_alvis.c:54
const char * default_schema
Definition: mod_alvis.c:52
const char * identifier
Definition: mod_alvis.c:49
const char * stylesheet
Definition: mod_alvis.c:50
struct filter_schema * next
Definition: mod_alvis.c:51
const char * name
Definition: mod_alvis.c:48
record extract for indexing
Definition: recctrl.h:101
int flagShowRecords
Definition: recctrl.h:108
void(* init)(struct recExtractCtrl *p, RecWord *w)
Definition: recctrl.h:103
char match_criteria[256]
Definition: recctrl.h:109
void(* tokenAdd)(RecWord *w)
Definition: recctrl.h:105
zint staticrank
Definition: recctrl.h:110
void(* setStoreData)(struct recExtractCtrl *p, void *buf, size_t size)
Definition: recctrl.h:106
int first_record
Definition: recctrl.h:107
struct ZebraRecStream * stream
Definition: recctrl.h:102
const Odr_oid * input_format
Definition: recctrl.h:123
Z_RecordComposition * comp
Definition: recctrl.h:124
struct ZebraRecStream * stream
Definition: recctrl.h:119
const Odr_oid * output_format
Definition: recctrl.h:134
zint staticrank
Definition: recctrl.h:128
char * fname
Definition: recctrl.h:130
void * rec_buf
Definition: recctrl.h:135
Definition: res.c:46
long zint
Zebra integer.
Definition: util.h:66
#define ZEBRA_FAIL
Definition: util.h:81
#define ZINT_FORMAT
Definition: util.h:72
zint atozint(const char *src)
Definition: zint.c:55
#define ZEBRA_OK
Definition: util.h:82
short ZEBRA_RES
Common return type for Zebra API.
Definition: util.h:80