- index_cdata(tinfo, ctrl, ptr->children, recWord);
- if (ptr->type != XML_TEXT_NODE)
- continue;
- recWord->term_buf = (const char *)ptr->content;
- recWord->term_len = XML_STRLEN(ptr->content);
- (*ctrl->tokenAdd)(recWord);
+ 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)
+ {
+ const char *look = index_p;
+ const char *bval;
+ const char *eval;
+
+ xmlChar index[256];
+ xmlChar type[256];
+
+ /* assingning text to be indexed */
+ recword->term_buf = (const char *)text;
+ recword->term_len = text_len;
+
+ /* parsing all index name/type pairs */
+ /* may not start with ' ' or ':' */
+ while (*look && ' ' != *look && ':' != *look)
+ {
+ /* setting name and type to zero */
+ *index = '\0';
+ *type = '\0';
+
+ /* parsing one index name */
+ bval = look;
+ while (*look && ':' != *look && ' ' != *look)
+ {
+ look++;
+ }
+ eval = look;
+ strncpy((char *)index, (const char *)bval, eval - bval);
+ index[eval - bval] = '\0';
+
+
+ /* parsing one index type, if existing */
+ if (':' == *look)
+ {
+ look++;
+
+ bval = look;
+ while (*look && ' ' != *look)
+ {
+ look++;
+ }
+ eval = look;
+ strncpy((char *)type, (const char *)bval, eval - bval);
+ type[eval - bval] = '\0';
+ }
+
+ /* actually indexing the text given */
+
+ recword->index_name = (const char *)index;
+ if (type && *type)
+ recword->index_type = (const char *) type;
+
+ /* writing debug out */
+ if (extctr->flagShowRecords)
+ dom_log(YLOG_LOG, tinfo, 0,
+ "INDEX '%s:%s' '%s'",
+ index ? (const char *) index : "null",
+ type ? (const char *) type : "null",
+ text ? (const char *) text : "null");
+
+ (extctr->tokenAdd)(recword);
+
+ /* eat whitespaces */
+ if (*look && ' ' == *look)
+ {
+ look++;
+ }
+ }
+ }
+ xmlFree(text);