+ yaz_log(YLOG_WARN, "No root for index XML record");
+ }
+}
+
+
+/* DOM filter style indexing */
+static int attr_content_xml(struct _xmlAttr *attr, const char *name,
+ xmlChar **dst_content)
+{
+ if (0 == XML_STRCMP(attr->name, name) && attr->children
+ && attr->children->type == XML_TEXT_NODE)
+ {
+ *dst_content = (attr->children->content);
+ return 1;
+ }
+ return 0;
+}
+
+/* DOM filter style indexing */
+/* #define ZEBRA_XSLT_NS "http://indexdata.com/zebra-2.0" */
+/* static const char *zebra_xslt_ns = ZEBRA_XSLT_NS; */
+
+/* DOM filter style indexing */
+#define ZEBRA_PI_NAME "zebra-2.0"
+static const char *zebra_pi_name = ZEBRA_PI_NAME;
+
+
+/* DOM filter style indexing */
+static void index_value_of(struct filter_info *tinfo,
+ struct recExtractCtrl *recctr,
+ xmlNodePtr node,
+ xmlChar * index_p)
+{
+ xmlChar *text = xmlNodeGetContent(node);
+
+ xmlChar *look = index_p;
+ xmlChar *bval;
+ xmlChar *eval;
+
+ xmlChar index[256];
+ xmlChar type[256];
+
+ /* 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';
+ }
+
+ printf("INDEX '%s:%s' '%s'\n", index, type, text);
+
+ if (*look && ' ' == *look && *(look+1)){
+ look++;
+ }
+ }
+
+ xmlFree(text);
+
+ /* //recWord->term_buf = (const char *)ptr->content; */
+ /* //recWord->term_len = XML_STRLEN(ptr->content); */
+ /* // if (type_str && *type_str) */
+ /* // recWord->index_type = *type_str; /\* type was given *\/ */
+ /* // recWord->index_name = name_str; */
+ /* // recWord->index_type = prev_type; /\* restore it again *\/ */
+}
+
+
+/* DOM filter style indexing */
+static void set_record_info(struct filter_info *tinfo,
+ struct recExtractCtrl *recctr,
+ xmlChar * id_p,
+ xmlChar * rank_p,
+ xmlChar * type_p)
+{
+ printf("RECORD id=%s rank=%s type=%s\n", id_p, rank_p, type_p);
+}
+
+
+/* DOM filter style indexing */
+static void process_xml_element_zebra_node(struct filter_info *tinfo,
+ struct recExtractCtrl *recctr,
+ xmlNodePtr node)
+{
+ if (node->type == XML_ELEMENT_NODE
+ && node->ns && 0 == XML_STRCMP(node->ns->href, zebra_xslt_ns)){
+
+ if (0 == XML_STRCMP(node->name, "index")){
+ xmlChar *index_p = 0;
+
+ struct _xmlAttr *attr;
+ for (attr = node->properties; attr; attr = attr->next){
+ if (attr_content_xml(attr, "name", &index_p)){
+ index_value_of(tinfo, recctr, node, index_p);
+ }
+ else
+ // printf("%s: dom filter: s% bad attribute %s",
+ // tinfo->fname, xmlGetNodePath(node)), nodeattr->name);
+ printf("dom filter: %s bad attribute @%s, "
+ "expected @name\n",
+ xmlGetNodePath(node), attr->name);
+ }
+ }
+ else if (0 == XML_STRCMP(node->name, "record")){
+ xmlChar *id_p = 0;
+ xmlChar *rank_p = 0;
+ xmlChar *type_p = 0;
+
+ struct _xmlAttr *attr;
+ for (attr = node->properties; attr; attr = attr->next){
+ if (attr_content_xml(attr, "id", &id_p))
+ ;
+ else if (attr_content_xml(attr, "rank", &rank_p))
+ ;
+ else if (attr_content_xml(attr, "type", &type_p))
+ ;
+ else
+ // printf("%s: dom filter: s% bad attribute %s",
+ // tinfo->fname, xmlGetNodePath(node)), nodeattr->name);
+ printf("dom filter: %s bad attribute @%s,"
+ " expected @id|@rank|@type\n",
+ xmlGetNodePath(node), attr->name);
+
+ if (type_p && 0 != strcmp("update", (const char *)type_p))
+ printf("dom filter: %s attribute @%s,"
+ " only implemented '@type=\"update\"\n",
+ xmlGetNodePath(node), attr->name);
+
+
+ }
+ set_record_info(tinfo, recctr, id_p, rank_p, type_p);
+ } else {
+ // printf("%s: dom filter: s% bad attribute %s",
+ // tinfo->fname, xmlGetNodePath(node)), nodeattr->name);
+ printf("dom filter: %s bad element <%s>,"
+ " expected <record>|<index> in namespace '%s'\n",
+ xmlGetNodePath(node), node->name, zebra_xslt_ns);
+
+ }