| 1 |
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ |
| 2 |
/* gdome-xml-nnm.c |
| 3 |
* |
| 4 |
* Copyright (C) 1999 Raph Levien <[email protected]> |
| 5 |
* Copyright (C) 2000 Mathieu Lacage <[email protected]> |
| 6 |
* Copyright (C) 2000 Anders Carlsson <[email protected]> |
| 7 |
* Copyright (C) 2001 Paolo Casarini <[email protected]> |
| 8 |
* |
| 9 |
* This library is free software; you can redistribute it and/or |
| 10 |
* modify it under the terms of the GNU Lesser General Public |
| 11 |
* License as published by the Free Software Foundation; either |
| 12 |
* version 2.1 of the License, or (at your option) any later version. |
| 13 |
* |
| 14 |
* This library is distributed in the hope that it will be useful, |
| 15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 |
* Lesser General Public License for more details. |
| 18 |
* |
| 19 |
* You should have received a copy of the GNU Lesser General Public |
| 20 |
* License along with this library; if not, write to the Free Software |
| 21 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 |
*/ |
| 23 |
|
| 24 |
#ifdef HAVE_CONFIG_H |
| 25 |
# include <config.h> |
| 26 |
#endif |
| 27 |
#include <glib.h> |
| 28 |
#include <string.h> |
| 29 |
#include "gdome.h" |
| 30 |
#include "gdome-events.h" |
| 31 |
#include "gdome-refdebug.h" |
| 32 |
#include "gdome-treegc.h" |
| 33 |
#include <libxml/tree.h> |
| 34 |
#include <libxml/parser.h> |
| 35 |
#include <libxml/xmlmemory.h> |
| 36 |
#include <libxml/hash.h> |
| 37 |
#include "gdome-xml-util.h" |
| 38 |
#include "gdome-xml-attribute.h" |
| 39 |
#include "gdome-xml-document.h" |
| 40 |
#include "gdome-xml-element.h" |
| 41 |
#include "gdome-xml-str.h" |
| 42 |
#include "gdome-evt-event.h" |
| 43 |
#include "gdome-evt-mevent.h" |
| 44 |
#include "gdome-xml-nnodem.h" |
| 45 |
#include "gdome-xml-xmlutil.h" |
| 46 |
|
| 47 |
typedef struct _nodeIterator nodeIterator; |
| 48 |
struct _nodeIterator { |
| 49 |
gulong cur; |
| 50 |
gulong index; |
| 51 |
xmlNode *node; |
| 52 |
}; |
| 53 |
|
| 54 |
const GdomeNamedNodeMapVtab gdome_xml_nnm_vtab = { |
| 55 |
gdome_xml_nnm_ref, |
| 56 |
gdome_xml_nnm_unref, |
| 57 |
gdome_xml_nnm_query_interface, |
| 58 |
gdome_xml_nnm_getNamedItem, |
| 59 |
gdome_xml_nnm_setNamedItem, |
| 60 |
gdome_xml_nnm_removeNamedItem, |
| 61 |
gdome_xml_nnm_item, |
| 62 |
gdome_xml_nnm_length, |
| 63 |
gdome_xml_nnm_getNamedItemNS, |
| 64 |
gdome_xml_nnm_setNamedItemNS, |
| 65 |
gdome_xml_nnm_removeNamedItemNS |
| 66 |
}; |
| 67 |
|
| 68 |
void |
| 69 |
itemHashScanner (void *payload, void *data, xmlChar *name) { |
| 70 |
nodeIterator *priv = (nodeIterator *)data; |
| 71 |
|
| 72 |
if(priv->cur < priv->index) |
| 73 |
priv->cur++; |
| 74 |
else if(priv->node == NULL) |
| 75 |
priv->node = (xmlNode *)payload; |
| 76 |
} |
| 77 |
|
| 78 |
/** |
| 79 |
* gdome_xml_nnm_mkref: |
| 80 |
* @doc: the Document owner ref |
| 81 |
* @elem: the Element owner ref, can be %NULL |
| 82 |
* @data: the pointer to the structure to export as NamedNodeMap |
| 83 |
* @data2: extra data, used for getAttributes |
| 84 |
* @readonly: %TRUE if the GdomeNamedNodeMap is readonly |
| 85 |
* @type: the type of the @data structure passed |
| 86 |
* |
| 87 |
* Construct the NamedNodeMap Object. |
| 88 |
* Returns: a pointer to the GdomeNamedNodeMap Object. |
| 89 |
*/ |
| 90 |
GdomeNamedNodeMap * |
| 91 |
gdome_xml_nnm_mkref (GdomeDocument *doc, GdomeElement *elem, void *data, void *data2, GdomeAccessType accessType, GdomeNodeType type) { |
| 92 |
Gdome_xml_NamedNodeMap *result = NULL; |
| 93 |
GdomeException exc; |
| 94 |
|
| 95 |
if (doc == NULL) |
| 96 |
return NULL; |
| 97 |
|
| 98 |
result = g_new (Gdome_xml_NamedNodeMap, 1); |
| 99 |
memset(result, 0, sizeof(Gdome_xml_NamedNodeMap)); |
| 100 |
#ifdef DEBUG_REFCNT |
| 101 |
gdome_refdbg_addRef ((void *)result, GDOME_REFDBG_NAMEDNODEMAP); |
| 102 |
#endif |
| 103 |
result->refcnt = 1; |
| 104 |
result->vtab = &gdome_xml_nnm_vtab; |
| 105 |
|
| 106 |
result->doc = doc; |
| 107 |
if (elem != NULL) |
| 108 |
gdome_xml_n_ref ((GdomeNode *)elem, &exc); |
| 109 |
result->elem = elem; |
| 110 |
if(type == GDOME_ENTITY_NODE || type == GDOME_NOTATION_NODE) |
| 111 |
result->data.ht = (xmlHashTable *)data; |
| 112 |
else if(type == GDOME_ATTRIBUTE_NODE) { |
| 113 |
result->data.lst = (xmlNode *)data; |
| 114 |
result->ns = (xmlNs *)data2; |
| 115 |
} else { |
| 116 |
g_free(result); |
| 117 |
return NULL; |
| 118 |
} |
| 119 |
|
| 120 |
result->accessType = accessType; |
| 121 |
result->type = type; |
| 122 |
|
| 123 |
return (GdomeNamedNodeMap *) result; |
| 124 |
} |
| 125 |
|
| 126 |
/** |
| 127 |
* gdome_xml_nnm_ref: |
| 128 |
* @self: NodeList Object ref |
| 129 |
* @exc: Exception Object ref |
| 130 |
* |
| 131 |
* Increase the reference count of the specified NamedNodeMap. |
| 132 |
*/ |
| 133 |
void |
| 134 |
gdome_xml_nnm_ref (GdomeNamedNodeMap *self, GdomeException *exc) { |
| 135 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 136 |
|
| 137 |
g_return_if_fail (self != NULL); |
| 138 |
g_return_if_fail (exc != NULL); |
| 139 |
|
| 140 |
priv->refcnt++; |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* gdome_xml_nnm_unref: |
| 145 |
* @self: NodeList Object ref |
| 146 |
* @exc: Exception Object ref |
| 147 |
* |
| 148 |
* Decrease the reference count of the specified NamedNodeMap. Free the |
| 149 |
* NamedNodeMap structure if the specified NamedNodeMap will have zero |
| 150 |
* reference. |
| 151 |
*/ |
| 152 |
void |
| 153 |
gdome_xml_nnm_unref (GdomeNamedNodeMap *self, GdomeException *exc) { |
| 154 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 155 |
|
| 156 |
g_return_if_fail (self != NULL); |
| 157 |
g_return_if_fail (exc != NULL); |
| 158 |
|
| 159 |
priv->refcnt--; |
| 160 |
|
| 161 |
if (priv->refcnt == 0) { |
| 162 |
gdome_xml_n_unref ((GdomeNode *)priv->doc, exc); |
| 163 |
if (priv->elem != NULL) |
| 164 |
gdome_xml_n_unref ((GdomeNode *)priv->elem, exc); |
| 165 |
|
| 166 |
#ifdef DEBUG_REFCNT |
| 167 |
gdome_refdbg_delRef ((void *)self, GDOME_REFDBG_NAMEDNODEMAP); |
| 168 |
#endif |
| 169 |
g_free (self); |
| 170 |
} |
| 171 |
} |
| 172 |
|
| 173 |
/** |
| 174 |
* gdome_xml_nnm_query_interface: |
| 175 |
* @self: NamedNodeMap Object ref |
| 176 |
* @interface: interface needed |
| 177 |
* @exc: Exception Object ref |
| 178 |
* |
| 179 |
* Returns: a reference to this object that implements the @interface needed, |
| 180 |
* or %NULL if the @interface is not supported by this Object. |
| 181 |
*/ |
| 182 |
gpointer |
| 183 |
gdome_xml_nnm_query_interface (GdomeNamedNodeMap *self, const char *interface, GdomeException *exc) |
| 184 |
{ |
| 185 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 186 |
|
| 187 |
g_return_val_if_fail (priv != NULL, NULL); |
| 188 |
g_return_val_if_fail (interface != NULL, NULL); |
| 189 |
g_return_val_if_fail (exc != NULL, NULL); |
| 190 |
|
| 191 |
if (!strcmp (interface, "NamedNodeMap")) { |
| 192 |
priv->refcnt++; |
| 193 |
return self; |
| 194 |
} |
| 195 |
else |
| 196 |
return NULL; |
| 197 |
} |
| 198 |
|
| 199 |
/** |
| 200 |
* gdome_xml_nnm_length: |
| 201 |
* @self: NamedNodeMap Objects ref |
| 202 |
* @exc: Exception Object ref |
| 203 |
* |
| 204 |
* Returns: the number of nodes in this map. The range of valid child node |
| 205 |
* indices is 0 to length-1 inclusive. |
| 206 |
*/ |
| 207 |
gulong |
| 208 |
gdome_xml_nnm_length (GdomeNamedNodeMap *self, GdomeException *exc) { |
| 209 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 210 |
xmlHashTable *ht; |
| 211 |
xmlNode *n; |
| 212 |
xmlNs *ns; |
| 213 |
long result = 0L; |
| 214 |
|
| 215 |
g_return_val_if_fail (priv != NULL, 0L); |
| 216 |
g_return_val_if_fail (exc != NULL, 0L); |
| 217 |
|
| 218 |
/* HashTable */ |
| 219 |
if (priv->type == GDOME_ENTITY_NODE || priv->type == GDOME_NOTATION_NODE) { |
| 220 |
ht = priv->data.ht; |
| 221 |
|
| 222 |
if((result = xmlHashSize(ht)) == -1) |
| 223 |
return 0L; |
| 224 |
} |
| 225 |
/* List */ |
| 226 |
else if (priv->type == GDOME_ATTRIBUTE_NODE) { |
| 227 |
for(n = priv->data.lst; n != NULL; n = n->next, result++); |
| 228 |
for(ns = priv->ns; ns != NULL; ns = ns->next, result++); |
| 229 |
} |
| 230 |
|
| 231 |
return result; |
| 232 |
} |
| 233 |
|
| 234 |
/** |
| 235 |
* gdome_xml_nnm_getNamedItem: |
| 236 |
* @self: NamedNodeMap Objects ref |
| 237 |
* @name: The nodeName of the node to retrieve. |
| 238 |
* @exc: Exception Object ref |
| 239 |
* |
| 240 |
* Retrieves a node specified by name. |
| 241 |
* Returns: a Node (of any type) with the specified nodeName, or %NULL if it |
| 242 |
* does not identify any node in this map. |
| 243 |
*/ |
| 244 |
GdomeNode * |
| 245 |
gdome_xml_nnm_getNamedItem (GdomeNamedNodeMap *self, GdomeDOMString *name, GdomeException *exc) { |
| 246 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 247 |
xmlHashTable *ht = NULL; |
| 248 |
xmlNode *n = NULL; |
| 249 |
xmlNs *ns = NULL; |
| 250 |
gchar **strs = NULL; |
| 251 |
|
| 252 |
g_return_val_if_fail (priv != NULL, NULL); |
| 253 |
g_return_val_if_fail (name != NULL, NULL); |
| 254 |
g_return_val_if_fail (exc != NULL, NULL); |
| 255 |
|
| 256 |
/* HashTable */ |
| 257 |
if (priv->type == GDOME_ENTITY_NODE || priv->type == GDOME_NOTATION_NODE) { |
| 258 |
ht = priv->data.ht; |
| 259 |
|
| 260 |
n = (xmlNode*) xmlHashLookup (ht, (xmlChar *) name->str); |
| 261 |
} |
| 262 |
/* List */ |
| 263 |
else if (priv->type == GDOME_ATTRIBUTE_NODE) { |
| 264 |
strs = g_strsplit((gchar *)name->str, ":", 0); |
| 265 |
if (xmlStrEqual(strs[0], "xmlns")) { |
| 266 |
n = ((Gdome_xml_Element *)priv->elem)->n; |
| 267 |
ns = gdome_xmlGetNsDecl(n, |
| 268 |
(xmlChar *)strs[1]); |
| 269 |
g_strfreev(strs); |
| 270 |
if (ns != NULL) { |
| 271 |
return (GdomeNode *) gdome_xml_a_mkref_ns (n, ns); |
| 272 |
} else { |
| 273 |
return NULL; |
| 274 |
} |
| 275 |
} |
| 276 |
g_strfreev(strs); |
| 277 |
n = (xmlNode *)gdome_xmlGetAttr(((Gdome_xml_Element *)priv->elem)->n, |
| 278 |
(xmlChar *)name->str); |
| 279 |
} |
| 280 |
if(n != NULL) |
| 281 |
return (GdomeNode *) gdome_xml_n_mkref (n); |
| 282 |
else |
| 283 |
return NULL; |
| 284 |
} |
| 285 |
|
| 286 |
/** |
| 287 |
* gdome_xml_nnm_getNamedItemNS: |
| 288 |
* @self: NamedNodeMap Objects ref |
| 289 |
* @namespaceURI: The namespace URI of the node to retrieve. |
| 290 |
* @localName: The local name of the node to retrieve. |
| 291 |
* @exc: Exception Object ref |
| 292 |
* |
| 293 |
* Retrieves a node specified by local name and namespace URI. |
| 294 |
* Returns: a Node (of any type) with the specified local name and namespace |
| 295 |
* URI, or %NULL if they do not identify any node in this map. |
| 296 |
*/ |
| 297 |
GdomeNode * |
| 298 |
gdome_xml_nnm_getNamedItemNS (GdomeNamedNodeMap *self, GdomeDOMString *namespaceURI, GdomeDOMString *localName, GdomeException *exc) { |
| 299 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 300 |
xmlHashTable *ht = NULL; |
| 301 |
xmlNode *n = NULL; |
| 302 |
xmlNs *ns = NULL; |
| 303 |
|
| 304 |
g_return_val_if_fail (priv != NULL, NULL); |
| 305 |
g_return_val_if_fail (localName != NULL, NULL); |
| 306 |
g_return_val_if_fail (exc != NULL, NULL); |
| 307 |
|
| 308 |
if (namespaceURI == NULL) |
| 309 |
return gdome_xml_nnm_getNamedItem (self, localName, exc); |
| 310 |
|
| 311 |
/* HashTable */ |
| 312 |
if (priv->type == GDOME_ENTITY_NODE || priv->type == GDOME_NOTATION_NODE) { |
| 313 |
ht = priv->data.ht; |
| 314 |
|
| 315 |
n = (xmlNode*) xmlHashLookup2 (ht, (xmlChar *) localName->str, |
| 316 |
(xmlChar *) namespaceURI->str); |
| 317 |
} |
| 318 |
/* List */ |
| 319 |
else if (priv->type == GDOME_ATTRIBUTE_NODE) { |
| 320 |
if (xmlStrEqual(namespaceURI->str, GDOME_XMLNS_NAMESPACE)) { |
| 321 |
n = ((Gdome_xml_Element *)priv->elem)->n; |
| 322 |
ns = gdome_xmlGetNsDecl(n, |
| 323 |
(xmlChar *)localName->str); |
| 324 |
if (ns != NULL) |
| 325 |
return (GdomeNode *) gdome_xml_a_mkref_ns (n, ns); |
| 326 |
else |
| 327 |
return NULL; |
| 328 |
} else { |
| 329 |
n = (xmlNode *)gdome_xmlGetNsAttr(((Gdome_xml_Element *)priv->elem)->n, |
| 330 |
(xmlChar *)namespaceURI->str, |
| 331 |
(xmlChar *)localName->str); |
| 332 |
} |
| 333 |
} |
| 334 |
|
| 335 |
if(n != NULL) |
| 336 |
return (GdomeNode *) gdome_xml_n_mkref (n); |
| 337 |
else |
| 338 |
return NULL; |
| 339 |
} |
| 340 |
|
| 341 |
/** |
| 342 |
* gdome_xml_nnm_item: |
| 343 |
* @self: NamedNodeMap Objects ref |
| 344 |
* @index: Index into this map. |
| 345 |
* @exc: Exception Object ref |
| 346 |
* |
| 347 |
* Returns: the indexth item in the map. If index is greater than or equal to |
| 348 |
* the number of nodes in this map, this returns %NULL. |
| 349 |
*/ |
| 350 |
GdomeNode * |
| 351 |
gdome_xml_nnm_item (GdomeNamedNodeMap *self, gulong index, GdomeException *exc) { |
| 352 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 353 |
xmlNode *n = NULL; |
| 354 |
xmlNs *ns = NULL; |
| 355 |
xmlHashTable *ht; |
| 356 |
nodeIterator *iter; |
| 357 |
gulong cur; |
| 358 |
|
| 359 |
g_return_val_if_fail (priv != NULL, NULL); |
| 360 |
g_return_val_if_fail (exc != NULL, NULL); |
| 361 |
|
| 362 |
/* HashTable */ |
| 363 |
if (priv->type == GDOME_ENTITY_NODE || priv->type == GDOME_NOTATION_NODE) { |
| 364 |
ht = priv->data.ht; |
| 365 |
iter = g_new(nodeIterator, 1); |
| 366 |
|
| 367 |
iter->cur = 0L; |
| 368 |
iter->index = index; |
| 369 |
iter->node = NULL; |
| 370 |
xmlHashScan(ht, itemHashScanner, iter); |
| 371 |
n = iter->node; |
| 372 |
|
| 373 |
g_free(iter); |
| 374 |
} |
| 375 |
/* List */ |
| 376 |
else if (priv->type == GDOME_ATTRIBUTE_NODE) { |
| 377 |
for(n = priv->data.lst, cur = 0; |
| 378 |
n != NULL && cur < index; |
| 379 |
cur++, n = n->next); |
| 380 |
if (n == NULL) { |
| 381 |
for (ns = priv->ns; |
| 382 |
ns != NULL && cur < index; |
| 383 |
cur++, ns = ns->next); |
| 384 |
return gdome_xml_a_mkref_ns (((Gdome_xml_Element *)priv->elem)->n, ns); |
| 385 |
} |
| 386 |
} |
| 387 |
|
| 388 |
return gdome_xml_n_mkref (n); |
| 389 |
} |
| 390 |
|
| 391 |
/** |
| 392 |
* gdome_xml_nnm_removeNamedItem: |
| 393 |
* @self: NamedNodeMap Objects ref |
| 394 |
* @name: The nodeName of the node to remove. |
| 395 |
* @exc: Exception Object ref |
| 396 |
* |
| 397 |
* Removes a node specified by name. When this map contains the attributes |
| 398 |
* attached to an element, if the removed attribute is known to have a default |
| 399 |
* value, an attribute immediately appears containing the default value as |
| 400 |
* well as the corresponding namespace URI, local name, and prefix when applicable. |
| 401 |
* |
| 402 |
* %GDOME_NOT_FOUND_ERR: Raised if there is no node named @name in this map. |
| 403 |
* %GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. |
| 404 |
* Returns: the node removed from this map if a node with such a name exists. |
| 405 |
*/ |
| 406 |
GdomeNode * |
| 407 |
gdome_xml_nnm_removeNamedItem (GdomeNamedNodeMap *self, GdomeDOMString *name, GdomeException *exc) { |
| 408 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 409 |
GdomeNode *ret = NULL; |
| 410 |
|
| 411 |
g_return_val_if_fail (priv != NULL, NULL); |
| 412 |
g_return_val_if_fail (name != NULL, NULL); |
| 413 |
g_return_val_if_fail (exc != NULL, NULL); |
| 414 |
|
| 415 |
if (priv->accessType == GDOME_READONLY_NODE) { |
| 416 |
*exc = GDOME_NO_MODIFICATION_ALLOWED_ERR; |
| 417 |
return NULL; |
| 418 |
} |
| 419 |
|
| 420 |
/* Hash Table */ |
| 421 |
if (priv->type == GDOME_ENTITY_NODE || priv->type == GDOME_NOTATION_NODE) { |
| 422 |
xmlHashTable *ht = priv->data.ht; |
| 423 |
|
| 424 |
if((ret = gdome_xml_nnm_getNamedItem(self, name, exc)) != NULL) { |
| 425 |
xmlHashRemoveEntry(ht, name->str, NULL); |
| 426 |
return ret; |
| 427 |
} |
| 428 |
} |
| 429 |
/* List */ |
| 430 |
else if (priv->type == GDOME_ATTRIBUTE_NODE) { |
| 431 |
GdomeNode *parent = gdome_xml_n_mkref (((Gdome_xml_Element *)priv->elem)->n); |
| 432 |
Gdome_xml_Node *parent_priv = (Gdome_xml_Node *)parent; |
| 433 |
xmlChar *defaultvalue = NULL; |
| 434 |
GdomeNode *defaultattr = NULL; |
| 435 |
GdomeMutationEvent *mev; |
| 436 |
GdomeDOMString *attrName; |
| 437 |
gchar **strs = NULL; |
| 438 |
|
| 439 |
strs = g_strsplit((gchar *)name->str, ":", 0); |
| 440 |
|
| 441 |
if (xmlStrEqual(strs[0], "xmlns")) { |
| 442 |
xmlNs *ns = gdome_xmlUnlinkNsDecl(parent_priv->n, strs[1]); |
| 443 |
/* ns is no longer in libxml tree, need to add it back so that it will |
| 444 |
get freed when libxml doc tree is freed */ |
| 445 |
gdome_xmlSetOldNs(parent_priv->n->doc, ns); |
| 446 |
ret = gdome_xml_a_mkref_ns (parent_priv->n, ns); |
| 447 |
} else |
| 448 |
ret = gdome_xml_n_mkref ((xmlNode *)gdome_xmlUnlinkAttr(parent_priv->n, |
| 449 |
name->str)); |
| 450 |
|
| 451 |
if(ret != NULL) { |
| 452 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 453 |
/* Fire DOMAttrModified */ |
| 454 |
mev = gdome_evt_mevnt_mkref (); |
| 455 |
attrName = gdome_xml_n_nodeName (ret, exc); |
| 456 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 457 |
TRUE, FALSE, ret, |
| 458 |
NULL, NULL, attrName, GDOME_REMOVAL, exc); |
| 459 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 460 |
gdome_xml_str_unref (attrName); |
| 461 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 462 |
} |
| 463 |
|
| 464 |
/* resync structure */ |
| 465 |
priv->data.lst = (xmlNode *)gdome_xmlGetAttrList(parent_priv->n); |
| 466 |
|
| 467 |
/* check for a default value and eventually insert it */ |
| 468 |
defaultvalue = xmlGetProp(parent_priv->n, name->str); |
| 469 |
if(defaultvalue != NULL) { |
| 470 |
defaultattr = gdome_xml_n_mkref ((xmlNode *)xmlNewProp(parent_priv->n, |
| 471 |
name->str, |
| 472 |
defaultvalue)); |
| 473 |
xmlFree(defaultvalue); |
| 474 |
|
| 475 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 476 |
/* Fire DOMAttrModified */ |
| 477 |
if (defaultattr != NULL) { |
| 478 |
mev = gdome_evt_mevnt_mkref (); |
| 479 |
attrName = gdome_xml_n_nodeName (defaultattr, exc); |
| 480 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 481 |
TRUE, FALSE, defaultattr, |
| 482 |
NULL, NULL, attrName, GDOME_ADDITION, exc); |
| 483 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 484 |
gdome_xml_str_unref (attrName); |
| 485 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 486 |
gdome_xml_n_unref (defaultattr, exc); |
| 487 |
} |
| 488 |
} |
| 489 |
} |
| 490 |
|
| 491 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_SUBTREE_MODIFIED_EVENT_TYPE)) { |
| 492 |
/* Fire DOMSubtreeModified */ |
| 493 |
mev = gdome_evt_mevnt_mkref (); |
| 494 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_SUBTREE_MODIFIED_EVENT_TYPE, |
| 495 |
TRUE, FALSE, NULL, |
| 496 |
NULL, NULL, NULL, 0, exc); |
| 497 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 498 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 499 |
} |
| 500 |
|
| 501 |
/* Check for ID removal */ |
| 502 |
if (xmlIsID(parent_priv->n->doc, parent_priv->n, |
| 503 |
(xmlAttr *)((Gdome_xml_Node *)ret)->n)) |
| 504 |
xmlRemoveID(parent_priv->n->doc, (xmlAttr *)((Gdome_xml_Node *)ret)->n); |
| 505 |
} |
| 506 |
gdome_xml_n_unref (parent, exc); |
| 507 |
g_strfreev(strs); |
| 508 |
return ret; |
| 509 |
} |
| 510 |
|
| 511 |
*exc = GDOME_NOT_FOUND_ERR; |
| 512 |
return NULL; |
| 513 |
} |
| 514 |
|
| 515 |
/** |
| 516 |
* gdome_xml_nnm_removeNamedItemNS: |
| 517 |
* @self: NamedNodeMap Objects ref |
| 518 |
* @namespaceURI: The namespace URI of the node to remove. |
| 519 |
* @localName: The local name of the node to remove. |
| 520 |
* @exc: Exception Object ref |
| 521 |
* |
| 522 |
* Removes a node specified by local name and namespace URI. When this map |
| 523 |
* contains the attributes attached to an element, if the removed attribute |
| 524 |
* is known to have a default value, an attribute immediately appears |
| 525 |
* containing the default value as well as the corresponding namespace URI, |
| 526 |
* local name, and prefix when applicable. |
| 527 |
* |
| 528 |
* %GDOME_NOT_FOUND_ERR: Raised if there is no node named @name in this map. |
| 529 |
* %GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. |
| 530 |
* Returns: the node removed from this map if a node with such a local name and |
| 531 |
* namespace URI exists. |
| 532 |
*/ |
| 533 |
GdomeNode * |
| 534 |
gdome_xml_nnm_removeNamedItemNS (GdomeNamedNodeMap *self, GdomeDOMString *namespaceURI, GdomeDOMString *localName, GdomeException *exc) { |
| 535 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 536 |
GdomeNode *ret = NULL; |
| 537 |
|
| 538 |
g_return_val_if_fail (priv != NULL, NULL); |
| 539 |
g_return_val_if_fail (localName != NULL, NULL); |
| 540 |
g_return_val_if_fail (exc != NULL, NULL); |
| 541 |
|
| 542 |
if (namespaceURI == NULL) |
| 543 |
return gdome_xml_nnm_removeNamedItem (self, localName, exc); |
| 544 |
|
| 545 |
if (priv->accessType == GDOME_READONLY_NODE) { |
| 546 |
*exc = GDOME_NO_MODIFICATION_ALLOWED_ERR; |
| 547 |
return NULL; |
| 548 |
} |
| 549 |
|
| 550 |
/* Hash Table */ |
| 551 |
if (priv->type == GDOME_ENTITY_NODE || priv->type == GDOME_NOTATION_NODE) { |
| 552 |
xmlHashTable *ht = priv->data.ht; |
| 553 |
|
| 554 |
if((ret = gdome_xml_nnm_getNamedItemNS(self, namespaceURI, localName, exc)) != NULL) { |
| 555 |
xmlHashRemoveEntry2(ht, namespaceURI->str, localName->str, NULL); |
| 556 |
return ret; |
| 557 |
} |
| 558 |
} |
| 559 |
/* List */ |
| 560 |
else if (priv->type == GDOME_ATTRIBUTE_NODE) { |
| 561 |
GdomeNode *parent = gdome_xml_n_mkref (((Gdome_xml_Element *)priv->elem)->n); |
| 562 |
Gdome_xml_Node *parent_priv = (Gdome_xml_Node *)parent; |
| 563 |
xmlChar *defaultvalue = NULL; |
| 564 |
GdomeNode *defaultattr = NULL; |
| 565 |
GdomeMutationEvent *mev; |
| 566 |
GdomeDOMString *attrName; |
| 567 |
|
| 568 |
if (xmlStrEqual(namespaceURI->str, GDOME_XMLNS_NAMESPACE)) |
| 569 |
ret = gdome_xml_a_mkref_ns (parent_priv->n, |
| 570 |
(xmlNs *)gdome_xmlUnlinkNsDecl(parent_priv->n, |
| 571 |
localName->str)); |
| 572 |
else |
| 573 |
ret = gdome_xml_n_mkref ((xmlNode *)gdome_xmlUnlinkNsAttr(parent_priv->n, |
| 574 |
namespaceURI->str, |
| 575 |
localName->str)); |
| 576 |
if(ret != NULL) { |
| 577 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 578 |
/* Fire DOMAttrModified */ |
| 579 |
mev = gdome_evt_mevnt_mkref (); |
| 580 |
attrName = gdome_xml_n_nodeName (ret, exc); |
| 581 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 582 |
TRUE, FALSE, ret, |
| 583 |
NULL, NULL, attrName, GDOME_REMOVAL, exc); |
| 584 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 585 |
gdome_xml_str_unref (attrName); |
| 586 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 587 |
} |
| 588 |
|
| 589 |
/* resync structure */ |
| 590 |
priv->data.lst = (xmlNode *)gdome_xmlGetAttrList(parent_priv->n); |
| 591 |
|
| 592 |
/* check for a default value and eventually insert it */ |
| 593 |
defaultvalue = xmlGetNsProp(parent_priv->n, localName->str, namespaceURI->str); |
| 594 |
if(defaultvalue != NULL) { |
| 595 |
defaultattr = gdome_xml_n_mkref ((xmlNode *)xmlNewNsProp(parent_priv->n, |
| 596 |
gdome_xmlGetNs (((Gdome_xml_Node *)ret)->n), |
| 597 |
localName->str, |
| 598 |
defaultvalue)); |
| 599 |
xmlFree(defaultvalue); |
| 600 |
|
| 601 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 602 |
/* Fire DOMAttrModified */ |
| 603 |
if (defaultattr != NULL) { |
| 604 |
mev = gdome_evt_mevnt_mkref (); |
| 605 |
attrName = gdome_xml_n_nodeName (defaultattr, exc); |
| 606 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 607 |
TRUE, FALSE, defaultattr, |
| 608 |
NULL, NULL, attrName, GDOME_ADDITION, exc); |
| 609 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 610 |
gdome_xml_str_unref (attrName); |
| 611 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 612 |
gdome_xml_n_unref (defaultattr, exc); |
| 613 |
} |
| 614 |
} |
| 615 |
} |
| 616 |
|
| 617 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 618 |
/* Fire DOMSubtreeModified */ |
| 619 |
mev = gdome_evt_mevnt_mkref (); |
| 620 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 621 |
TRUE, FALSE, NULL, |
| 622 |
NULL, NULL, NULL, 0, exc); |
| 623 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 624 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 625 |
} |
| 626 |
|
| 627 |
/* Check for ID removal */ |
| 628 |
if (xmlIsID(parent_priv->n->doc, parent_priv->n, |
| 629 |
(xmlAttr *)((Gdome_xml_Node*)ret)->n)) |
| 630 |
xmlRemoveID(parent_priv->n->doc, (xmlAttr *)((Gdome_xml_Node *)ret)->n); |
| 631 |
|
| 632 |
} |
| 633 |
gdome_xml_n_unref (parent, exc); |
| 634 |
return ret; |
| 635 |
} |
| 636 |
|
| 637 |
*exc = GDOME_NOT_FOUND_ERR; |
| 638 |
return NULL; |
| 639 |
} |
| 640 |
|
| 641 |
/** |
| 642 |
* gdome_xml_nnm_setNamedItem: |
| 643 |
* @self: NamedNodeMap Objects ref |
| 644 |
* @arg: a node to store in this map. |
| 645 |
* @exc: Exception Object ref |
| 646 |
* |
| 647 |
* Adds a node using its nodeName attribute. If a node with that name is |
| 648 |
* already present in this map, it is replaced by the new one. |
| 649 |
* |
| 650 |
* %GDOME_WRONG_DOCUMENT_ERR: Raised if @arg was created from a different |
| 651 |
* document than the one that created this map. |
| 652 |
* %GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. |
| 653 |
* %GDOME_INUSE_ATTRIBUTE_ERR: Raised if arg is an Attr that is already an |
| 654 |
* attribute of another Element object. The DOM user must explicitly clone |
| 655 |
* Attr nodes to re-use them in other elements. |
| 656 |
* Returns: if the new Node replaces an existing node, the replaced Node is |
| 657 |
* returned, otherwise %NULL is returned. |
| 658 |
* %GDOME_HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node |
| 659 |
* doesn't belong in this NamedNodeMap. Examples would include trying to |
| 660 |
* insert something other than an Attr node into an Element's map of |
| 661 |
* attributes, or a non-Entity node into the DocumentType's map of Entities. |
| 662 |
*/ |
| 663 |
GdomeNode * |
| 664 |
gdome_xml_nnm_setNamedItem (GdomeNamedNodeMap *self, GdomeNode *arg, GdomeException *exc) { |
| 665 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 666 |
xmlNode *newn = NULL; |
| 667 |
|
| 668 |
g_return_val_if_fail (priv != NULL, NULL); |
| 669 |
g_return_val_if_fail (arg != NULL, NULL); |
| 670 |
g_return_val_if_fail (GDOME_XML_IS_N (arg), NULL); |
| 671 |
g_return_val_if_fail (exc != NULL, NULL); |
| 672 |
|
| 673 |
if (((Gdome_xml_Document *)priv->doc)->n != ((Gdome_xml_Node*)arg)->n->doc) { |
| 674 |
*exc = GDOME_WRONG_DOCUMENT_ERR; |
| 675 |
return NULL; |
| 676 |
} |
| 677 |
if (priv->accessType == GDOME_READONLY_NODE) { |
| 678 |
*exc = GDOME_NO_MODIFICATION_ALLOWED_ERR; |
| 679 |
return NULL; |
| 680 |
} |
| 681 |
if (priv->type != gdome_xml_n_nodeType (arg, exc)) { |
| 682 |
*exc = GDOME_HIERARCHY_REQUEST_ERR; |
| 683 |
return NULL; |
| 684 |
} |
| 685 |
|
| 686 |
newn = ((Gdome_xml_Node*)arg)->n; |
| 687 |
|
| 688 |
/* Hash Table */ |
| 689 |
if(priv->type == GDOME_ENTITY_NODE || priv->type == GDOME_NOTATION_NODE) { |
| 690 |
xmlHashTable *ht = priv->data.ht; |
| 691 |
xmlNode *ret = NULL; |
| 692 |
|
| 693 |
if((ret = xmlHashLookup(ht, gdome_xmlGetName(newn))) != NULL) { |
| 694 |
xmlHashUpdateEntry(ht, gdome_xmlGetName(newn), newn, NULL); |
| 695 |
return (GdomeNode *) gdome_xml_n_mkref(ret); |
| 696 |
} else { |
| 697 |
xmlHashAddEntry(ht, gdome_xmlGetName(newn), newn); |
| 698 |
return NULL; |
| 699 |
} |
| 700 |
} |
| 701 |
/* List */ |
| 702 |
else if (priv->type == GDOME_ATTRIBUTE_NODE) { |
| 703 |
GdomeNode *parent = gdome_xml_n_mkref (((Gdome_xml_Element *)priv->elem)->n); |
| 704 |
Gdome_xml_Node *parent_priv = (Gdome_xml_Node *)parent; |
| 705 |
GdomeNode *ret = NULL; |
| 706 |
GdomeMutationEvent *mev; |
| 707 |
GdomeDOMString *attrName; |
| 708 |
|
| 709 |
if(newn->prev || newn->next || |
| 710 |
(gdome_xmlGetParent(newn) && gdome_xmlGetParent(newn) != parent_priv->n)) { |
| 711 |
*exc = GDOME_INUSE_ATTRIBUTE_ERR; |
| 712 |
gdome_xml_n_unref (parent, exc); |
| 713 |
return NULL; |
| 714 |
} |
| 715 |
|
| 716 |
ret = gdome_xml_n_mkref ((xmlNode *)gdome_xmlUnlinkAttr(parent_priv->n, |
| 717 |
gdome_xmlGetName(newn))); |
| 718 |
if (ret != NULL) { |
| 719 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 720 |
/* Fire DOMAttrModified */ |
| 721 |
mev = gdome_evt_mevnt_mkref (); |
| 722 |
attrName = gdome_xml_n_nodeName (ret, exc); |
| 723 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 724 |
TRUE, FALSE, ret, |
| 725 |
NULL, NULL, attrName, GDOME_REMOVAL, exc); |
| 726 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 727 |
gdome_xml_str_unref (attrName); |
| 728 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
gdome_xmlLinkAttr(parent_priv->n, (xmlAttr *)newn); |
| 733 |
|
| 734 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 735 |
/* Fire DOMAttrModified */ |
| 736 |
mev = gdome_evt_mevnt_mkref (); |
| 737 |
gdome_xml_n_ref (arg, exc); |
| 738 |
attrName = gdome_xml_n_nodeName (arg, exc); |
| 739 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 740 |
TRUE, FALSE, arg, |
| 741 |
NULL, NULL, attrName, GDOME_ADDITION, exc); |
| 742 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 743 |
gdome_xml_str_unref (attrName); |
| 744 |
gdome_xml_n_unref (arg, exc); |
| 745 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 746 |
} |
| 747 |
|
| 748 |
/* resync structure */ |
| 749 |
priv->data.lst = (xmlNode *)gdome_xmlGetAttrList(parent_priv->n); |
| 750 |
|
| 751 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_SUBTREE_MODIFIED_EVENT_TYPE)) { |
| 752 |
/* Fire DOMSubtreeModified */ |
| 753 |
mev = gdome_evt_mevnt_mkref (); |
| 754 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_SUBTREE_MODIFIED_EVENT_TYPE, |
| 755 |
TRUE, FALSE, NULL, |
| 756 |
NULL, NULL, NULL, 0, exc); |
| 757 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 758 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 759 |
} |
| 760 |
|
| 761 |
gdome_xml_n_unref (parent, exc); |
| 762 |
return ret; |
| 763 |
} |
| 764 |
return NULL; |
| 765 |
} |
| 766 |
|
| 767 |
/** |
| 768 |
* gdome_xml_nnm_setNamedItemNS: |
| 769 |
* @self: NamedNodeMap Objects ref |
| 770 |
* @arg: a node to store in this map. The node will later be accessible |
| 771 |
* using the value of its namespaceURI and localName attributes. |
| 772 |
* @exc: Exception Object ref |
| 773 |
* |
| 774 |
* Adds a node using its namespaceURI and localName. If a node with that |
| 775 |
* namespace URI and that local name is already present in this map, it is |
| 776 |
* replaced by the new one |
| 777 |
* |
| 778 |
* %GDOME_WRONG_DOCUMENT_ERR: Raised if @arg was created from a different |
| 779 |
* document than the one that created this map. |
| 780 |
* %GDOME_NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly. |
| 781 |
* %GDOME_INUSE_ATTRIBUTE_ERR: Raised if @arg is an Attr that is already an |
| 782 |
* attribute of another Element object. The DOM user must explicitly clone |
| 783 |
* Attr nodes to re-use them in other elements. |
| 784 |
* Returns: If the new Node replaces an existing node the replaced Node is |
| 785 |
* returned, otherwise null is returned. |
| 786 |
* %GDOME_HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node |
| 787 |
* doesn't belong in this NamedNodeMap. Examples would include trying to |
| 788 |
* insert something other than an Attr node into an Element's map of |
| 789 |
* attributes, or a non-Entity node into the DocumentType's map of Entities. |
| 790 |
*/ |
| 791 |
GdomeNode * |
| 792 |
gdome_xml_nnm_setNamedItemNS (GdomeNamedNodeMap *self, GdomeNode *arg, GdomeException *exc) { |
| 793 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 794 |
xmlNode *newn = NULL; |
| 795 |
|
| 796 |
g_return_val_if_fail (priv != NULL, NULL); |
| 797 |
g_return_val_if_fail (arg != NULL, NULL); |
| 798 |
g_return_val_if_fail (GDOME_XML_IS_N (arg), NULL); |
| 799 |
g_return_val_if_fail (exc != NULL, NULL); |
| 800 |
|
| 801 |
if (((Gdome_xml_Document *)priv->doc)->n != ((Gdome_xml_Node*)arg)->n->doc) { |
| 802 |
*exc = GDOME_WRONG_DOCUMENT_ERR; |
| 803 |
return NULL; |
| 804 |
} |
| 805 |
if (priv->accessType == GDOME_READONLY_NODE) { |
| 806 |
*exc = GDOME_NO_MODIFICATION_ALLOWED_ERR; |
| 807 |
return NULL; |
| 808 |
} |
| 809 |
if (priv->type != gdome_xml_n_nodeType (arg, exc)) { |
| 810 |
*exc = GDOME_HIERARCHY_REQUEST_ERR; |
| 811 |
return NULL; |
| 812 |
} |
| 813 |
|
| 814 |
newn = ((Gdome_xml_Node*)arg)->n; |
| 815 |
|
| 816 |
/* Hash Table */ |
| 817 |
if(priv->type == GDOME_ENTITY_NODE || priv->type == GDOME_NOTATION_NODE) { |
| 818 |
xmlHashTable *ht = priv->data.ht; |
| 819 |
xmlNode *ret = NULL; |
| 820 |
|
| 821 |
if((ret = xmlHashLookup2(ht, gdome_xmlGetName(newn), gdome_xmlGetNsURI(newn))) != NULL) { |
| 822 |
xmlHashUpdateEntry2(ht, gdome_xmlGetName(newn), gdome_xmlGetNsURI(newn), newn, NULL); |
| 823 |
return (GdomeNode *) gdome_xml_n_mkref(ret); |
| 824 |
} else { |
| 825 |
xmlHashAddEntry2(ht, gdome_xmlGetName(newn), gdome_xmlGetNsURI(newn), newn); |
| 826 |
return NULL; |
| 827 |
} |
| 828 |
|
| 829 |
} |
| 830 |
/* List */ |
| 831 |
else if (priv->type == GDOME_ATTRIBUTE_NODE) { |
| 832 |
GdomeNode *parent = gdome_xml_n_mkref (((Gdome_xml_Element *)priv->elem)->n); |
| 833 |
Gdome_xml_Node *parent_priv = (Gdome_xml_Node *)parent; |
| 834 |
GdomeNode *ret = NULL; |
| 835 |
GdomeMutationEvent *mev; |
| 836 |
GdomeDOMString *attrName; |
| 837 |
|
| 838 |
if(newn->prev || newn->next || |
| 839 |
(gdome_xmlGetParent(newn) && gdome_xmlGetParent(newn) != parent_priv->n)) { |
| 840 |
*exc = GDOME_INUSE_ATTRIBUTE_ERR; |
| 841 |
gdome_xml_n_unref (parent, exc); |
| 842 |
return NULL; |
| 843 |
} |
| 844 |
|
| 845 |
ret = gdome_xml_n_mkref ((xmlNode *)gdome_xmlUnlinkNsAttr(parent_priv->n, |
| 846 |
gdome_xmlGetNsURI(newn), |
| 847 |
gdome_xmlGetName(newn))); |
| 848 |
if (ret != NULL) { |
| 849 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 850 |
/* Fire DOMAttrModified */ |
| 851 |
mev = gdome_evt_mevnt_mkref (); |
| 852 |
attrName = gdome_xml_n_nodeName (ret, exc); |
| 853 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 854 |
TRUE, FALSE, ret, |
| 855 |
NULL, NULL, attrName, GDOME_REMOVAL, exc); |
| 856 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 857 |
gdome_xml_str_unref (attrName); |
| 858 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 859 |
} |
| 860 |
} |
| 861 |
|
| 862 |
gdome_xmlLinkAttr(parent_priv->n, (xmlAttr *)newn); |
| 863 |
|
| 864 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_ATTR_MODIFIED_EVENT_TYPE)) { |
| 865 |
/* Fire DOMAttrModified */ |
| 866 |
mev = gdome_evt_mevnt_mkref (); |
| 867 |
gdome_xml_n_ref (arg, exc); |
| 868 |
attrName = gdome_xml_n_nodeName (arg, exc); |
| 869 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_ATTR_MODIFIED_EVENT_TYPE, |
| 870 |
TRUE, FALSE, arg, |
| 871 |
NULL, NULL, attrName, GDOME_ADDITION, exc); |
| 872 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 873 |
gdome_xml_str_unref (attrName); |
| 874 |
gdome_xml_n_unref (arg, exc); |
| 875 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 876 |
} |
| 877 |
|
| 878 |
/* resync structure */ |
| 879 |
priv->data.lst = (xmlNode *)gdome_xmlGetAttrList(parent_priv->n); |
| 880 |
|
| 881 |
if (gdome_xml_nnm_eventEnabledByCode (self, DOM_SUBTREE_MODIFIED_EVENT_TYPE)) { |
| 882 |
/* Fire DOMSubtreeModified */ |
| 883 |
mev = gdome_evt_mevnt_mkref (); |
| 884 |
gdome_evt_mevnt_initMutationEventByCode (mev, DOM_SUBTREE_MODIFIED_EVENT_TYPE, |
| 885 |
TRUE, FALSE, NULL, |
| 886 |
NULL, NULL, NULL, 0, exc); |
| 887 |
gdome_xml_n_dispatchEvent (parent, (GdomeEvent *)mev, exc); |
| 888 |
gdome_evt_mevnt_unref ((GdomeEvent *)mev, exc); |
| 889 |
} |
| 890 |
|
| 891 |
gdome_xml_n_unref (parent, exc); |
| 892 |
return ret; |
| 893 |
} |
| 894 |
return NULL; |
| 895 |
} |
| 896 |
|
| 897 |
GdomeBoolean |
| 898 |
gdome_xml_nnm_eventEnabledByCode (GdomeNamedNodeMap *self, guint32 code) |
| 899 |
{ |
| 900 |
Gdome_xml_NamedNodeMap *priv = (Gdome_xml_NamedNodeMap *)self; |
| 901 |
|
| 902 |
g_return_val_if_fail (priv != NULL, FALSE); |
| 903 |
|
| 904 |
return gdome_xml_doc_eventEnabledByCode (priv->doc, code); |
| 905 |
} |