1 /* This file is part of the Zebra server.
2 Copyright (C) 1994-2011 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
28 #include <idzebra/data1.h>
31 void data1_remove_node (data1_handle dh, data1_node *n)
33 fprintf (stdout, "REMOVE tag %s \n", n->u.tag.tag);
34 /* n is first childen */
35 if(n->parent->child == n){
36 n->parent->child = n->next;
38 /* n is the only child */
40 n->parent->last_child = 0;
43 /* n is one of the following childrens */
47 /* need to find sibling before me */
48 before = n->parent->child;
49 while (before->next != n)
50 before = before->next;
52 before->next = n->next;
54 /* n is last child of many */
55 if ( n->parent->last_child == n){
56 n->parent->last_child = before;
59 /* break pointers to root, parent and following siblings */
65 void data1_remove_idzebra_subtree (data1_handle dh, data1_node *n)
74 if (!strcmp(n->u.tag.tag, "idzebra")){
75 if (n->u.tag.attributes){
76 data1_xattr *xattr = n->u.tag.attributes;
78 for (; xattr; xattr = xattr->next){
79 if (!strcmp(xattr->name, "xmlns")
80 & !strcmp(xattr->value,
81 "http://www.indexdata.dk/zebra/"))
82 data1_remove_node (dh, n);
93 case DATA1N_preprocess:
102 data1_remove_idzebra_subtree (dh, n->child);
104 data1_remove_idzebra_subtree (dh, n->next);
108 if (n->parent && n->parent->last_child != n)
109 fprintf(out, "%*sWARNING: last_child=%p != %p\n", level, "",
110 n->parent->last_child, n);
121 * c-file-style: "Stroustrup"
122 * indent-tabs-mode: nil
124 * vim: shiftwidth=4 tabstop=8 expandtab