corrected logical error in finding indexation stylesheet
[idzebra-moved-to-github.git] / recctrl / alvis.c
index c7fd287..01db970 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: alvis.c,v 1.12 2006-05-23 15:21:58 marc Exp $
+/* $Id: alvis.c,v 1.14 2006-05-24 12:56:56 marc Exp $
    Copyright (C) 1995-2005
    Index Data ApS
 
@@ -208,6 +208,11 @@ static ZEBRA_RES create_schemas(struct filter_info *tinfo, const char *fname)
                attr_content(attr, "default", &schema->default_schema);
                attr_content(attr, "snippet", &schema->include_snippet);
            }
+            /*yaz_log(YLOG_LOG, "XSLT add %s %s %s", 
+              schema->name, schema->identifier, schema->stylesheet); */
+
+            /* find requested schema */
+
            if (schema->stylesheet)
                schema->stylesheet_xsp =
                    xsltParseStylesheetFile(
@@ -237,19 +242,20 @@ static struct filter_schema *lookup_schema(struct filter_info *tinfo,
                                           const char *est)
 {
     struct filter_schema *schema;
+
     for (schema = tinfo->schemas; schema; schema = schema->next)
-    {
+    { 
         /* 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;
     }
 
@@ -599,11 +605,17 @@ static int filter_retrieve (void *clientData, struct recRetrieveCtrl *p)
        set_param_str(params, "filename", p->fname, p->odr);
     if (p->staticrank >= 0)
        set_param_int(params, "rank", p->staticrank, p->odr);
+
     if (esn)
         set_param_str(params, "schema", esn, p->odr);
     else
-        set_param_str(params, "schema", "", p->odr);
-    /* should use default elem set here .. */
+        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);
     set_param_int(params, "size", p->recordSize, p->odr);