- const char *id_str = 0;
- const char *rank_str = 0;
- struct _xmlAttr *attr;
- for (attr = ptr->properties; attr; attr = attr->next)
- {
- if (attr_content(attr, "type", &type_str))
- ;
- else if (attr_content(attr, "id", &id_str))
- ;
- else if (attr_content(attr, "rank", &rank_str))
- ;
- else
- yaz_log(YLOG_WARN, "%s: dom filter: bad attribute %s"
- " for <record>",
- tinfo->fname, attr->name);
- }
- if (id_str)
- sscanf(id_str, "%255s", ctrl->match_criteria);
-
- if (rank_str)
- ctrl->staticrank = atozint(rank_str);
- ptr = ptr->children;
+ xmlChar *pi_p = node->content;
+ xmlChar *look = pi_p;
+
+ xmlChar *bval;
+ xmlChar *eval;
+
+ /* parsing PI record instructions */
+ if (0 == strncmp((const char *)look, "record", 6))
+ {
+ xmlChar id[256];
+ xmlChar rank[256];
+ xmlChar type[256];
+
+ *id = '\0';
+ *rank = '\0';
+ *type = '\0';
+
+ look += 6;
+
+ /* eat whitespace */
+ while (*look && ' ' == *look && *(look+1))
+ look++;
+
+ /* parse possible id */
+ if (*look && 0 == strncmp((const char *)look, "id=", 3))
+ {
+ look += 3;
+ bval = look;
+ while (*look && ' ' != *look)
+ look++;
+ eval = look;
+ strncpy((char *)id, (const char *)bval, eval - bval);
+ id[eval - bval] = '\0';
+ }
+
+ /* eat whitespace */
+ while (*look && ' ' == *look && *(look+1))
+ look++;
+
+ /* parse possible rank */
+ if (*look && 0 == strncmp((const char *)look, "rank=", 5))
+ {
+ look += 6;
+ bval = look;
+ while (*look && ' ' != *look)
+ look++;
+ eval = look;
+ strncpy((char *)rank, (const char *)bval, eval - bval);
+ rank[eval - bval] = '\0';
+ }
+
+ /* eat whitespace */
+ while (*look && ' ' == *look && *(look+1))
+ look++;
+
+ if (look && '\0' != *look)
+ {
+ dom_log(YLOG_WARN, tinfo, node,
+ "content '%s', can not parse '%s'",
+ pi_p, look);
+ }
+ else
+ set_record_info(tinfo, extctr, id, rank, 0);
+
+ }
+ /* parsing index instruction */
+ else if (0 == strncmp((const char *)look, "index", 5))
+ {
+ look += 5;
+
+ /* eat whitespace */
+ while (*look && ' ' == *look && *(look+1))
+ look++;
+
+ /* export index instructions to outside */
+ *index_pp = look;
+ }
+ else
+ {
+ dom_log(YLOG_WARN, tinfo, node,
+ "content '%s', can not parse '%s'",
+ pi_p, look);
+ }