Align sequence numbers for words in z:index sections for mod_dom.
authorAdam Dickmeiss <adam@indexdata.dk>
Thu, 23 Oct 2008 09:35:09 +0000 (11:35 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Thu, 23 Oct 2008 09:35:09 +0000 (11:35 +0200)
index/mod_dom.c
test/xslt/dctoindex.xsl
test/xslt/dom1.c

index ad97171..7ade71d 100644 (file)
@@ -813,10 +813,18 @@ static void index_value_of(struct filter_info *tinfo,
     {
         xmlChar *text = xmlNodeGetContent(node);
         size_t text_len = strlen((const char *)text);
-       
+        
         /* if there is no text, we do not need to proceed */
         if (text_len)
         {            
+            /* keep seqno base so that all text will have
+               identical seqno's for multiple fields , e.g
+               <z:index name="title:w any:w title:p">.. */
+            
+            zint seqno_base = recword->seqno;
+            zint seqno_max = recword->seqno;
+       
+
             const char *look = index_p;
             const char *bval;
             const char *eval;
@@ -864,6 +872,7 @@ static void index_value_of(struct filter_info *tinfo,
 
                 /* actually indexing the text given */
 
+                recword->seqno = seqno_base;
                 recword->index_name = (const char *)index;
                 if (*type)
                     recword->index_type = (const char *) type;
@@ -878,12 +887,16 @@ static void index_value_of(struct filter_info *tinfo,
                 
                 (extctr->tokenAdd)(recword);
 
+                if (seqno_max < recword->seqno)
+                    seqno_max = recword->seqno;
+
                 /* eat whitespaces */
                 if (*look && ' ' == *look)
                 {
                     look++;
                 } 
             }
+            recword->seqno = seqno_max;
         }
         xmlFree(text); 
     }
index 106c947..407397e 100644 (file)
@@ -23,9 +23,7 @@
 
   <xsl:template match="/*">
     <z:record>
-      <z:index name="any:w">
         <xsl:apply-templates/>
-      </z:index>
 
       <xsl:call-template name="special-indexes"/>
 
@@ -38,7 +36,7 @@
   </xsl:template>
 
   <xsl:template match="/*/*[namespace-uri() = 'http://purl.org/dc/elements/1.1/']">
-    <z:index name="{local-name()}:w">
+    <z:index name="any:w {local-name()}:w">
       <xsl:value-of select="."/>
     </z:index>
   </xsl:template>
index 957b83a..e22dbfd 100644 (file)
@@ -126,14 +126,17 @@ void tst(int argc, char **argv)
     YAZ_CHECK(tl_query(zh, "@attr 1=title b", 1));
 
     zh = index_some(zs, "dom.gutenberg.xml", "gutenberg-sample.xml");
-    YAZ_CHECK(tl_query(zh, "selected", 1));
+    YAZ_CHECK(tl_query(zh, "oscar", 1));
 
     YAZ_CHECK_EQ(tl_fetch_first_compare(
                      zh, "zebra::snippet", yaz_oid_recsyn_xml,
                      "<record xmlns=\"http://www.indexdata.com/zebra/\">\n"
-                     "  <snippet name=\"any\" type=\"w\">etext/1338\n"
-                     "    Project Gutenberg\n"
-                     "    <s>Selected</s> Prose of Oscar Wilde</snippet>\n"
+                     "  <snippet name=\"any\" type=\"w\">"
+                     "Selected Prose of <s>Oscar</s> Wilde"
+                     "</snippet>\n"
+                     "  <snippet name=\"any\" type=\"w\">"
+                     "Wilde, <s>Oscar</s>, 1854-1900"
+                     "</snippet>\n"
                      "</record>"),
                  ZEBRA_OK);