Re: [gdome]DTD loading



> > * I've had some problems deep cloning document fragments and calling getOwner
> >    on the same. I'm not sure if this is a the library or the PERL wrapper 
> >    interface.
> 
> given that all the bindings to Gdome2 are quite simple and, as far as I
> know, most of them are created automatically, I would suspect the
> problem is in Gdome2. An equivalent C program raising the problem would
> be a great help.
> 
> Regards,
> luca

OK. I've written my first C/DOM program and I still get the problem. It's
allegedly an Exception 0 (zero) which was not very helpful.

I attach the program. Hopefully it's not something weird and local to my
machine or other horrors.

I *really* want to get my code using gdome as I've been
running some experiments and gdome could potentially save users of my software
up to a GIG of RAM. (no kidding!) The problem with PERL is that it does reference
counting which means every time you read a reference you mementarily change the
reference count, thus modifying it, thus causing a copy-on-write of the memory
if the program is forked (which it is as it's running as part of apache).

This problem goes away with using GDOME and the RAM usage also goes down by 
75% to store XML because C is so much more efficient, so it's an all round win
if I can get it working.

A bit of a plug for the project: It's GPL software and officially part of GNU,
currently in use by a number of universities at an experimental level with many
more in earlier stages of development (plus other sites including one of the 
NASA labs). ie. Helping me get this working will really benefit people.</plug></shameless>


> 
> _______________________________________________
> gdome mailing list
> gdome gnome org
> http://mail.gnome.org/mailman/listinfo/gdome

-- 
    Christopher Gutteridge -- cjg ecs soton ac uk -- +44 (0)23 8059 4833

                              ,___O<
 _____________________________(___)________________________________________
|                                   |                                      |
| Now Playing: "Fire in Cairo"      | "They say I'm deluded, demented,     |
| from Boys Don't Cry - The Cure    | deranged; but guess what I say?" SO  |
|                                   | BE IT! - from "Pump up the Volume"   |
|___________________________________|______________________________________|

#include <libgdome/gdome.h>
#include <stdio.h>


int main (int argc, char **argv) {
	GdomeDOMImplementation *domimpl;
	GdomeDocument *doc;
	GdomeException exc;
	GdomeNode *result;
	GdomeDOMString *name;

	GdomeDocumentFragment *f;
	GdomeDocumentFragment *f2;
	GdomeElement *e;

	/* First I get a DOMImplementation reference */
	domimpl = gdome_di_mkref ();

	/* I create a new document with TEST as root element */
	name = gdome_str_mkref ("TEST");
	doc = gdome_di_createDocument(domimpl, NULL, name, NULL, &exc);
	if (doc == NULL) {
		fprintf (stderr, "DOMImplementation.createDocument: failed\n\tException #%d\n", exc);
		return 1;
	}
	gdome_str_unref (name);


	/* I create a Doc Fragment*/
	f = gdome_doc_createDocumentFragment(doc, &exc);
	if (f == NULL) {
		fprintf (stderr, "Document.createDocumentFragment: NULL\n\tException #%d\n", exc);
		return 1;
	}

	/* I create a new element called FOO */
	name = gdome_str_mkref ("FOO");
	e = gdome_doc_createElement (doc, name, &exc);
	if (e == NULL) {
		fprintf (stderr, "Document.createElement: NULL\n\tException #%d\n", exc);
		return 1;
	}
	gdome_str_unref (name);

	/* I append the FOO element to the childs list of the root element */
	result = gdome_df_appendChild(f, (GdomeNode *)e, &exc);
	if (result != (GdomeNode *)e) {
		fprintf (stderr, "Element.appendChild: failed\n\tException #%d\n", exc);
		return 1;
	}
	gdome_el_unref(e, &exc);

	/* I deep clone the fragment */
	/* nb. I still get an exception for a non-deep-clone too */

	f2 = (GdomeDocumentFragment*)gdome_df_cloneNode( f, 1, &exc);
	if (f2 == NULL) {
		fprintf (stderr, "DocumentFragment.cloneNode: failed\n\tException #%d\n", exc);
		return 1;
	}

	return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]