removing the XSLT filter from the build, only keeping the ALVIS filter
[idzebra-moved-to-github.git] / recctrl / xslt.c
index 15dce30..10354bb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: xslt.c,v 1.22 2006-05-23 15:21:58 marc Exp $
+/* $Id: xslt.c,v 1.27 2006-05-31 16:11:58 marc Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -33,6 +33,7 @@ Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
 #include <libxml/xmlIO.h>
 #include <libxml/xmlreader.h>
 #include <libxslt/transform.h>
+/* #include <libxslt/xsltutils.h> */
 
 #include <idzebra/util.h>
 #include <idzebra/recctrl.h>
@@ -237,6 +238,7 @@ static ZEBRA_RES create_schemas(struct filter_xslt_info *tinfo,
                attr_content(attr, "default", &schema->default_schema);
                attr_content(attr, "snippet", &schema->include_snippet);
            }
+
            if (schema->stylesheet){
               yaz_filepath_resolve(schema->stylesheet, tinfo->profile_path, 
                                    NULL, tmp_xslt_full_name);
@@ -275,15 +277,15 @@ static struct filter_xslt_schema *lookup_schema(struct filter_xslt_info *tinfo,
     {
         /* find requested schema */
        if (est) 
-       {
+       {    
            if (schema->identifier && !strcmp(schema->identifier, est))
-               return schema;
+                return schema;
+            
            if (schema->name && !strcmp(schema->name, est))
                return schema;
-       }
-
+       } 
         /* or return default schema if defined */
-       if (schema->default_schema)
+        else if (schema->default_schema)
            return schema;
     }
 
@@ -642,10 +644,15 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
     if (p->staticrank >= 0)
        set_param_int(params, "rank", p->staticrank, p->odr);
 
-     /* should use default elem set here .. */     if (esn)
-         set_param_str(params, "schema", esn, p->odr);
-     else
-         set_param_str(params, "schema", "", p->odr);
+     if (esn)
+        set_param_str(params, "schema", esn, p->odr);
+    else
+        if (schema->name)
+            set_param_str(params, "schema", schema->name, p->odr);
+        else if (schema->identifier)
+            set_param_str(params, "schema", schema->identifier, p->odr);
+        else
+            set_param_str(params, "schema", "", p->odr);
 
     if (p->score >= 0)
        set_param_int(params, "score", p->score, p->odr);
@@ -687,7 +694,9 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
     {
        xmlChar *buf_out;
        int len_out;
-       xmlDocDumpMemory(resDoc, &buf_out, &len_out);
+
+        xsltSaveResultToString(&buf_out, &len_out, resDoc,
+                               schema->stylesheet_xsp);        
 
        p->output_format = VAL_TEXT_XML;
        p->rec_len = len_out;
@@ -700,7 +709,9 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
     {
        xmlChar *buf_out;
        int len_out;
-       xmlDocDumpMemory(resDoc, &buf_out, &len_out);
+
+        xsltSaveResultToString(&buf_out, &len_out, resDoc,
+                               schema->stylesheet_xsp);        
 
        p->output_format = VAL_SUTRS;
        p->rec_len = len_out;