optimize for C source code
[idzebra-moved-to-github.git] / recctrl / xslt.c
index a118277..6787510 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: xslt.c,v 1.14 2005-08-19 21:41:37 adam Exp $
+/* $Id: xslt.c,v 1.17 2005-08-24 08:30:37 adam Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -96,6 +96,9 @@ static void set_param_int(const char **params, const char *name,
     params[2] = 0;
 }
 
+#define ENABLE_INPUT_CALLBACK 0
+
+#if ENABLE_INPUT_CALLBACK
 static int zebra_xmlInputMatchCallback (char const *filename)
 {
     yaz_log(YLOG_LOG, "match %s", filename);
@@ -116,8 +119,9 @@ static int zebra_xmlInputCloseCallback (void * context)
 {
     return 0;
 }
+#endif
 
-static void *filter_init_xslt(Res res, RecType recType)
+static void *filter_init(Res res, RecType recType)
 {
     struct filter_info *tinfo = (struct filter_info *) xmalloc(sizeof(*tinfo));
     tinfo->reader = 0;
@@ -128,7 +132,7 @@ static void *filter_init_xslt(Res res, RecType recType)
     tinfo->doc = 0;
     tinfo->schemas = 0;
 
-#if 0
+#if ENABLE_INPUT_CALLBACK
     xmlRegisterDefaultInputCallbacks();
     xmlRegisterInputCallbacks(zebra_xmlInputMatchCallback,
                              zebra_xmlInputOpenCallback,
@@ -440,8 +444,8 @@ static int extract_split(struct filter_info *tinfo, struct recExtractCtrl *p)
 
            xmlDocSetRootElement(doc, ptr2);
 
-           return extract_doc(tinfo, p, doc);      
-       }
+           return extract_doc(tinfo, p, doc);   
+       }
        ret = xmlTextReaderRead(tinfo->reader);
     }
     xmlFreeTextReader(tinfo->reader);
@@ -543,7 +547,7 @@ static const char *snippet_doc(struct recRetrieveCtrl *p, int text_mode,
 static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
 {
     const char *esn = zebra_xslt_ns;
-    const char *params[10];
+    const char *params[20];
     struct filter_info *tinfo = clientData;
     xmlDocPtr resDoc;
     xmlDocPtr doc;
@@ -552,13 +556,18 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
 
     if (p->comp)
     {
-       if (p->comp->which != Z_RecordComp_simple
-           || p->comp->u.simple->which != Z_ElementSetNames_generic)
+       if (p->comp->which == Z_RecordComp_simple
+           && p->comp->u.simple->which == Z_ElementSetNames_generic)
+       {
+           esn = p->comp->u.simple->u.generic;
+       }
+       else if (p->comp->which == Z_RecordComp_complex 
+                && p->comp->u.complex->generic->elementSpec
+                && p->comp->u.complex->generic->elementSpec->which ==
+                Z_ElementSpec_elementSetName)
        {
-           p->diagnostic = YAZ_BIB1_PRESENT_COMP_SPEC_PARAMETER_UNSUPP;
-           return 0;
+           esn = p->comp->u.complex->generic->elementSpec->u.elementSetName;
        }
-       esn = p->comp->u.simple->u.generic;
     }
     schema = lookup_schema(tinfo, esn);
     if (!schema)
@@ -646,10 +655,10 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
     return 0;
 }
 
-static struct recType filter_type_xslt = {
+static struct recType filter_type = {
     0,
     "xslt",
-    filter_init_xslt,
+    filter_init,
     filter_config,
     filter_destroy,
     filter_extract,
@@ -664,6 +673,6 @@ idzebra_filter
 #endif
 
 [] = {
-    &filter_type_xslt,
+    &filter_type,
     0,
 };