+ 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);
+
+ }
+ }
+}
+
+
+/* DOM filter style indexing */
+static void process_xml_pi_node(struct filter_info *tinfo,
+ struct recExtractCtrl *recctr,
+ xmlNodePtr node,
+ xmlChar **index_pp)
+{
+
+ /* printf("PI %s\n", xmlGetNodePath(node)); */
+
+ /* if right PI name, continue parsing PI */
+ if (0 == strcmp(zebra_pi_name, (const char *)node->name)){
+ 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){
+ printf ("ERROR %s: content '%s'; can not parse '%s'\n",
+ xmlGetNodePath(node), pi_p, look);
+ } else {
+ /* set_record_info(id, rank, type); */
+ set_record_info(tinfo, recctr, 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;
+
+ /* nor record, neither index */
+ } else {
+
+ printf ("ERROR %s: content '%s'; can not parse '%s'\n",
+ xmlGetNodePath(node), pi_p, look);
+ }
+ }
+}
+
+/* DOM filter style indexing */
+static void process_xml_element_node(struct filter_info *tinfo,
+ struct recExtractCtrl *recctr,
+ xmlNodePtr node)
+{
+ /* remember indexing instruction from PI to next element node */
+ xmlChar *index_p = 0;
+
+ /* printf("ELEM %s\n", xmlGetNodePath(node)); */
+
+ /* check if we are an element node in the special zebra namespace
+ and either set record data or index value-of node content*/
+ process_xml_element_zebra_node(tinfo, recctr, node);
+
+ /* loop through kid nodes */
+ for (node = node->children; node; node = node->next)
+ {
+ /* check and set PI record and index index instructions */
+ if (node->type == XML_PI_NODE){
+ process_xml_pi_node(tinfo, recctr, node, &index_p);
+ }
+ else if (node->type == XML_ELEMENT_NODE){
+ /* if there was a PI index instruction before this element */
+ if (index_p){
+ index_value_of(tinfo, recctr, node, index_p);
+ index_p = 0;
+ }
+ process_xml_element_node(tinfo, recctr, node);
+ }
+ else
+ continue;
+ }
+}
+
+
+/* DOM filter style indexing */
+static void extract_dom_doc_node(struct filter_info *tinfo,
+ struct recExtractCtrl *recctr,
+ xmlDocPtr doc)
+{
+ /* printf("DOC %s\n", xmlGetNodePath((xmlNodePtr)doc)); */
+
+ process_xml_element_node(tinfo, recctr, (xmlNodePtr)doc);
+}
+
+
+
+
+static int convert_extract_doc(struct filter_info *tinfo,
+ struct filter_input *input,
+ struct recExtractCtrl *p,
+ xmlDocPtr doc)
+
+{
+ /* RecWord recWord; */