Re: [gdome]gdome_doc_importNode leaves the imported node with no document
- From: Paolo Casarini <casarini CS UniBO IT>
- To: rob <mailingLists pangolin org uk>
- Cc: gdome <gdome gnome org>
- Subject: Re: [gdome]gdome_doc_importNode leaves the imported node with no document
- Date: Wed, 11 Apr 2001 19:53:10 +0200 (CEST)
Hi rob,
thanks to use gdome2 library. The current release is a beta test release
and so it's very usefull your work.
On Wed, 11 Apr 2001, rob wrote:
> when I use gdome_doc_importNode the node doesn't seem to be imported
> properly. Its document is set to NULL. Therefore trying to insert the
> returned node with gdome_n_insertBefore fails with a WRONG_DOCUMENT_ERR (no
> 4).
You're right, it's a bug. I attached a patch to resolve it. You can use it
or you can also wait the next release (I think it will be ready for
tomorrow)
> Here is what I'm doing in case it is my mistake(I'm setting the document
> manually as after importing it is NULL). It is the deserialization and
> insertion of a node copied from the clipboard.
With the patch I sent, you have not to do this. Now the
gdome_doc_importNode should work fine.
> btw is writing my own import function that doesn't copy the node as simple
> as changing the document element in all the nodes?
It's not so simple. To copy/cut/paste nodes between two Document you have
to use the gdome_doc_importNode API.
> gdome_xml_n_get_xmlNode(pastedDn)->doc =
This API is deprecated.
I leave it because I know that gdome2 is not perfect and so you can make
some works around to resolve some of its bugs.
Thanx
Paolo
--
Paolo Casarini - casarini cs unibo it
--- gdome2/libgdome/gdomecore/gdome-xml-document.c Fri Mar 23 23:57:54 2001
+++ gdome2.work/libgdome/gdomecore/gdome-xml-document.c Wed Apr 11 19:16:27 2001
@@ -671,17 +670,16 @@
gdome_xml_doc_importNode (GdomeDocument *self, GdomeNode *importedNode, GdomeBoolean deep, GdomeException *exc) {
Gdome_xml_Document *priv = (Gdome_xml_Document *)self;
Gdome_xml_Node *priv_node = (Gdome_xml_Node *)importedNode;
-
+ xmlNode *ret = NULL;
g_return_val_if_fail (priv != NULL, NULL);
g_return_val_if_fail (GDOME_XML_IS_DOC (priv), NULL);
g_return_val_if_fail (importedNode != NULL, NULL);
g_return_val_if_fail (exc != NULL, NULL);
-
switch (gdome_n_nodeType (importedNode, exc)) {
case XML_ATTRIBUTE_NODE:
- return gdome_xml_n_mkref (xmlCopyNode (priv_node->n, TRUE));
+ ret = xmlCopyNode (priv_node->n, TRUE);
case XML_DOCUMENT_FRAG_NODE:
case XML_ELEMENT_NODE:
case XML_ENTITY_NODE:
@@ -691,9 +689,14 @@
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_COMMENT_NODE:
- return gdome_xml_n_mkref (xmlCopyNode (priv_node->n, deep));
+ ret = xmlCopyNode (priv_node->n, deep);
default:
*exc = GDOME_NOT_SUPPORTED_ERR;
- return NULL;
}
+
+ if (ret != NULL) {
+ gdome_xmlSetOwner (ret, priv->n);
+ return gdome_xml_n_mkref (ret);
+ } else
+ return NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]