1 /* This file is part of the Zebra server.
2 Copyright (C) 1995-2008 Index Data
4 Zebra is free software; you can redistribute it and/or modify it under
5 the terms of the GNU General Public License as published by the Free
6 Software Foundation; either version 2, or (at your option) any later
9 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
10 WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <idzebra/data1.h>
28 void data1_remove_node (data1_handle dh, data1_node *n)
30 fprintf (stdout, "REMOVE tag %s \n", n->u.tag.tag);
31 /* n is first childen */
32 if(n->parent->child == n){
33 n->parent->child = n->next;
35 /* n is the only child */
37 n->parent->last_child = 0;
40 /* n is one of the following childrens */
44 /* need to find sibling before me */
45 before = n->parent->child;
46 while (before->next != n)
47 before = before->next;
49 before->next = n->next;
51 /* n is last child of many */
52 if ( n->parent->last_child == n){
53 n->parent->last_child = before;
56 /* break pointers to root, parent and following siblings */
62 void data1_remove_idzebra_subtree (data1_handle dh, data1_node *n)
71 if (!strcmp(n->u.tag.tag, "idzebra")){
72 if (n->u.tag.attributes){
73 data1_xattr *xattr = n->u.tag.attributes;
75 for (; xattr; xattr = xattr->next){
76 if (!strcmp(xattr->name, "xmlns")
77 & !strcmp(xattr->value,
78 "http://www.indexdata.dk/zebra/"))
79 data1_remove_node (dh, n);
90 case DATA1N_preprocess:
99 data1_remove_idzebra_subtree (dh, n->child);
101 data1_remove_idzebra_subtree (dh, n->next);
105 if (n->parent && n->parent->last_child != n)
106 fprintf(out, "%*sWARNING: last_child=%p != %p\n", level, "",
107 n->parent->last_child, n);
118 * indent-tabs-mode: nil
120 * vim: shiftwidth=4 tabstop=8 expandtab