1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */
2 /* test-document.c
3  *
4  * Copyright (C) 2001 Paolo Casarini <paolo@casarini.org>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20 
21 #include <stdio.h>
22 #include <string.h>
23 #include <gdome.h>
24 
25 void
dot()26 dot() {
27 	printf(".");
28 	fflush(stdout);
29 }
30 
31 gboolean
test_document1(GdomeDocument * doc)32 test_document1 (GdomeDocument *doc) {
33 	GdomeElement *root, *el1, *el2;
34 	GdomeDocumentFragment *df;
35 	GdomeText *txt;
36 	GdomeCDATASection *cds;
37 	GdomeComment *cmt;
38 	GdomeProcessingInstruction *pi;
39 	GdomeAttr *attr1, *attr2;
40 	GdomeException exc = 0;
41 	GdomeDOMString *tstr1, *tstr2;
42 	GdomeDocument *tdoc;
43 	GdomeNode *ntmp;
44 	gboolean ret = TRUE;
45 
46 	/* Test Documet.documentElement */
47 	root = gdome_doc_documentElement (doc, &exc);
48 	if (root == NULL)
49 		fprintf (stderr, "\nDocument.documentElement, NULL"), ret = FALSE;
50 	else {
51 		tstr1 = gdome_el_tagName (root, &exc);
52 		if (strcmp(tstr1->str, "TEST"))
53 			fprintf (stderr, "\nDocument.documentElement, wrong"), ret = FALSE;
54 		gdome_str_unref (tstr1);
55 		/*gdome_el_unref (root);*/
56 	}
57 	dot();
58 
59 	/* Test Document.createElement */
60 	tstr1 = gdome_str_mkref ("EL1");
61 	el1 = gdome_doc_createElement (doc, tstr1, &exc);
62 	gdome_str_unref (tstr1);
63 	el1 = GDOME_EL(el1);
64 	if (el1 == NULL)
65 		fprintf (stderr, "\nDocument.createElement, NULL"), ret = FALSE;
66 	else if (gdome_el_nodeType (el1, &exc) != GDOME_ELEMENT_NODE)
67 		fprintf (stderr, "\nDocument.createElement, wrong nodeType"), ret = FALSE;
68 	else {
69     tdoc = gdome_el_ownerDocument (el1, &exc);
70 		if (tdoc != doc)
71 			fprintf (stderr, "\nDocument.createElement, wrong ownerDocument"), ret = FALSE;
72 		else {
73 			gdome_doc_unref (tdoc, &exc);
74       tstr1 = gdome_el_tagName (el1, &exc);
75 			if (strcmp(tstr1->str, "EL1"))
76 				fprintf (stderr, "\nDocument.createElement, wrong tagName"), ret = FALSE;
77 			gdome_str_unref(tstr1);
78 		}
79 	}
80   dot();
81 
82 	/* Test Document.createElementNS */
83 	tstr1 = gdome_str_mkref ("tns:EL2");
84 	tstr2 = gdome_str_mkref ("urn:test.tst");
85 	el2 = gdome_doc_createElementNS (doc, tstr2, tstr1, &exc);
86 	gdome_str_unref (tstr1);
87 	gdome_str_unref (tstr2);
88 	if (el2 == NULL)
89 		fprintf (stderr, "\nDocument.createElementNS, NULL"), ret = FALSE;
90 	else if (gdome_el_nodeType (el2, &exc) != GDOME_ELEMENT_NODE)
91 		fprintf (stderr, "\nDocument.createElement, wrong nodeType"), ret = FALSE;
92 	else {
93 		tdoc = gdome_el_ownerDocument (el2, &exc);
94 		if (tdoc != doc)
95 			fprintf (stderr, "\nDocument.createElementNS, wrong ownerElement"), ret = FALSE;
96 		else {
97 			gdome_doc_unref (tdoc, &exc);
98 			tstr1 = gdome_el_tagName (el2, &exc);
99 			if (strcmp(tstr1->str, "tns:EL2"))
100 				fprintf (stderr, "\nDocument.createElement, wrong tagName"), ret = FALSE;
101 			gdome_str_unref (tstr1);
102 			tstr1 = gdome_el_localName (el2, &exc);
103 			if (strcmp(tstr1->str, "EL2"))
104 				fprintf (stderr, "\nDocument.createElement, wrong localName"), ret = FALSE;
105 			gdome_str_unref (tstr1);
106 			tstr1 = gdome_el_namespaceURI (el2, &exc);
107 			if (strcmp(tstr1->str, "urn:test.tst"))
108 				fprintf (stderr, "\nDocument.createElement, wrong namespaceURI"), ret = FALSE;
109 			gdome_str_unref(tstr1);
110 		}
111 	}
112 	dot();
113 
114   /* Test Document.createDocumentFragment */
115   df = gdome_doc_createDocumentFragment (doc, &exc);
116 	df = GDOME_DF(df);
117 	if (df == NULL)
118 		fprintf (stderr, "\nDocument.createDocumentFragment, NULL"), ret = FALSE;
119 	else if (gdome_df_nodeType (df, &exc) != GDOME_DOCUMENT_FRAGMENT_NODE)
120 		fprintf (stderr, "\nDocument.createDocumentFragment, wrong nodeType"), ret = FALSE;
121 	else {
122 		tdoc = gdome_df_ownerDocument (df, &exc);
123 		if (tdoc != doc)
124 			fprintf (stderr, "\nDocument.createDocumentFragment, wrong ownerDocument"), ret = FALSE;
125 		else {
126 			gdome_doc_unref (tdoc, &exc);
127 			tstr1 = gdome_df_nodeName (df, &exc);
128 			if (strcmp(tstr1->str, "#document-fragment"))
129 				fprintf (stderr, "\nDocument.createDocumentFragment, wrong nodeName"), ret = FALSE;
130 			gdome_str_unref (tstr1);
131 		}
132 	}
133 
134 	gdome_df_unref (df, &exc);
135 	dot();
136 
137   /* Test Document.createTextNode */
138 	tstr1 = gdome_str_mkref ("<Test>Text Test</Test>");
139 	txt = gdome_doc_createTextNode (doc, tstr1, &exc);
140 	gdome_str_unref (tstr1);
141 /*	txt = GDOME_T(txt);*/
142 	if (txt == NULL)
143 		fprintf (stderr, "\nDocument.createTextNode, NULL"), ret = FALSE;
144 	else if (gdome_t_nodeType (txt, &exc) != GDOME_TEXT_NODE)
145 		fprintf (stderr, "\nDocument.createTextNode, wrong nodeType"), ret = FALSE;
146 	else {
147 		tdoc = gdome_t_ownerDocument (txt, &exc);
148 		if (tdoc != doc)
149 			fprintf (stderr, "\nDocument.createTextNode, wrong ownerDocument"), ret = FALSE;
150 		else {
151 			gdome_doc_unref (tdoc, &exc);
152 			tstr1 = gdome_t_nodeName (txt, &exc);
153 			if (strcmp(tstr1->str, "#text"))
154 				fprintf (stderr, "\nDocument.createTextNode, wrong nodeName"), ret = FALSE;
155 			gdome_str_unref (tstr1);
156 			tstr1 = gdome_t_nodeValue (txt, &exc);
157 			if (strcmp(tstr1->str, "<Test>Text Test</Test>"))
158 				fprintf (stderr, "\nDocument.createTextNode, wrong nodeValue"), ret = FALSE;
159 			gdome_str_unref(tstr1);
160 		}
161 	}
162 	dot();
163 
164   /* Test Document.createCDATASection */
165 	tstr1 = gdome_str_mkref ("<Test>Text Test</Test>");
166 	cds = gdome_doc_createCDATASection (doc, tstr1, &exc);
167 	gdome_str_unref (tstr1);
168 	cds = GDOME_CDS(cds);
169 	if (cds == NULL)
170 		fprintf (stderr, "\nDocument.createCDATASection, NULL"), ret = FALSE;
171 	else if (gdome_cds_nodeType (cds, &exc) != GDOME_CDATA_SECTION_NODE)
172 		fprintf (stderr, "\nDocument.createCDATASection, wrong nodeType"), ret = FALSE;
173 	else {
174 		tdoc = gdome_cds_ownerDocument (cds, &exc);
175 		if (tdoc != doc)
176 			fprintf (stderr, "\nDocument.createCDATASection, wrong ownerDocument"), ret = FALSE;
177 		else {
178 			gdome_doc_unref (tdoc, &exc);
179 			tstr1 = gdome_cds_nodeName (cds, &exc);
180 			if (strcmp(tstr1->str, "#cdata-section"))
181 				fprintf (stderr, "\nDocument.createCDATASection, wrong nodeName"), ret = FALSE;
182 			gdome_str_unref (tstr1);
183 			tstr1 = gdome_cds_nodeValue (cds, &exc);
184 			if (strcmp(tstr1->str, "<Test>Text Test</Test>"))
185 				fprintf (stderr, "\nDocument.createCDATASection, wrong nodeValue"), ret = FALSE;
186 			gdome_str_unref(tstr1);
187 		}
188 	}
189 	dot();
190 
191   /* Test Document.createComment */
192 	tstr1 = gdome_str_mkref ("dududu dadada");
193 	cmt = gdome_doc_createComment (doc, tstr1, &exc);
194 	gdome_str_unref (tstr1);
195 	cmt = GDOME_C(cmt);
196 	if (cmt == NULL)
197 		fprintf (stderr, "\nDocument.createComment, NULL"), ret = FALSE;
198 	else if (gdome_c_nodeType (cmt, &exc) != GDOME_COMMENT_NODE)
199 		fprintf (stderr, "\nDocument.createComment, wrong nodeType"), ret = FALSE;
200 	else {
201 		tdoc = gdome_c_ownerDocument (cmt, &exc);
202 		if (tdoc != doc)
203 			fprintf (stderr, "\nDocument.createComment, wrong ownerDocument"), ret = FALSE;
204 		else {
205 			gdome_doc_unref (tdoc, &exc);
206 			tstr1 = gdome_c_nodeName (cmt, &exc);
207 			if (strcmp(tstr1->str, "#comment"))
208 				fprintf (stderr, "\nDocument.createComment, wrong nodeName"), ret = FALSE;
209 			gdome_str_unref (tstr1);
210 			tstr1 = gdome_c_nodeValue (cmt, &exc);
211 			if (strcmp(tstr1->str, "dududu dadada"))
212 				fprintf (stderr, "\nDocument.createComment, wrong nodeValue"), ret = FALSE;
213 			gdome_str_unref(tstr1);
214 		}
215 	}
216 	dot();
217 
218   /* Test Document.createProcessingInstruction */
219 	tstr1 = gdome_str_mkref ("sqlprocessor");
220 	tstr2 = gdome_str_mkref ("SELECT * FROM blah");
221 	pi = gdome_doc_createProcessingInstruction (doc, tstr1, tstr2, &exc);
222 	gdome_str_unref (tstr1);
223 	gdome_str_unref (tstr2);
224 	pi = GDOME_PI(pi);
225 	if (pi == NULL)
226 		fprintf (stderr, "\nDocument.createProcessingInstruction, NULL"), ret = FALSE;
227 	else if (gdome_pi_nodeType (pi, &exc) != GDOME_PROCESSING_INSTRUCTION_NODE)
228 		fprintf (stderr, "\nDocument.createProcessingInstruction, wrong nodeType"), ret = FALSE;
229 	else {
230 		tdoc = gdome_pi_ownerDocument (pi, &exc);
231 		if (tdoc != doc)
232 			fprintf (stderr, "\nDocument.createProcessingInstruction, wrong ownerDocument"), ret = FALSE;
233 		else {
234 			gdome_doc_unref (tdoc, &exc);
235 			tstr1 = gdome_pi_nodeName (pi, &exc);
236 			if (strcmp(tstr1->str, "sqlprocessor"))
237 				fprintf (stderr, "\nDocument.createProcessingInstruction, wrong nodeName"), ret = FALSE;
238 			gdome_str_unref (tstr1);
239 			tstr1 = gdome_pi_nodeValue (pi, &exc);
240 			if (strcmp(tstr1->str, "SELECT * FROM blah"))
241 				fprintf (stderr, "\nDocument.createProcessingInstruction, wrong nodeValue"), ret = FALSE;
242 			gdome_str_unref(tstr1);
243 		}
244 	}
245 	dot();
246 
247   /* Test Document.createAttribute */
248 	tstr1 = gdome_str_mkref ("ATTR1");
249 	attr1 = gdome_doc_createAttribute (doc, tstr1, &exc);
250 	gdome_str_unref(tstr1);
251 	attr1 = GDOME_A(attr1);
252 	if (attr1 == NULL)
253 		fprintf (stderr, "\nDocument.createAttribute, NULL"), ret = FALSE;
254 	else if (gdome_a_nodeType (attr1, &exc) != GDOME_ATTRIBUTE_NODE)
255 		fprintf (stderr, "\nDocument.createAttribute, wrong nodeType"), ret = FALSE;
256 	else {
257 		tdoc = gdome_a_ownerDocument (attr1, &exc);
258 		if (tdoc != doc)
259 			fprintf (stderr, "\nDocument.createAttribute, wrong ownerDocument"), ret = FALSE;
260 		else {
261 			gdome_doc_unref (tdoc, &exc);
262 			tstr1 = gdome_a_name (attr1, &exc);
263 			if (strcmp(tstr1->str, "ATTR1"))
264 				fprintf (stderr, "\nDocument.createAttribute, wrong name"), ret = FALSE;
265 			gdome_str_unref (tstr1);
266 			tstr1 = gdome_a_value (attr1, &exc);
267 			if (strcmp(tstr1->str, ""))
268 				fprintf (stderr, "\nDocument.createAttribute, wrong value"), ret = FALSE;
269 			gdome_str_unref(tstr1);
270 		}
271 	}
272 	dot();
273 
274   /* Test Document.createAttributeNS */
275 	tstr1 = gdome_str_mkref ("tns:ATTR2");
276 	tstr2 = gdome_str_mkref ("urn:test.tst");
277 	attr2 = gdome_doc_createAttributeNS (doc, tstr2, tstr1, &exc);
278 	gdome_str_unref (tstr1);
279 	gdome_str_unref (tstr2);
280 	if (attr1 == NULL)
281 		fprintf (stderr, "\nDocument.createAttributeNS, NULL"), ret = FALSE;
282 	else if (gdome_a_nodeType (attr2, &exc) != GDOME_ATTRIBUTE_NODE)
283 		fprintf (stderr, "\nDocument.createAttributeNS, wrong nodeType"), ret = FALSE;
284 	else {
285 		tdoc = gdome_a_ownerDocument (attr2, &exc);
286 		if (tdoc != doc)
287 			fprintf (stderr, "\nDocument.createAttributeNS, wrong ownerDocument"), ret = FALSE;
288 		else {
289 			gdome_doc_unref (tdoc, &exc);
290 			tstr1 = gdome_a_name (attr2, &exc);
291 			if (strcmp(tstr1->str, "tns:ATTR2"))
292 				fprintf (stderr, "\nDocument.createAttributeNS, wrong name"), ret = FALSE;
293 			gdome_str_unref (tstr1);
294 			tstr1 = gdome_a_localName (attr2, &exc);
295 			if (strcmp(tstr1->str, "ATTR2"))
296 				fprintf (stderr, "\nDocument.createAttributeNS, wrong localName"), ret = FALSE;
297 			gdome_str_unref (tstr1);
298 			tstr1 = gdome_a_namespaceURI (attr2, &exc);
299 			if (strcmp(tstr1->str, "urn:test.tst"))
300 				fprintf (stderr, "\nDocument.createAttributeNS, wrong namespaceURI"), ret = FALSE;
301 			gdome_str_unref (tstr1);
302 			tstr1 = gdome_a_value (attr2, &exc);
303 			if (strcmp(tstr1->str, ""))
304 				fprintf (stderr, "\nDocument.createAttributeNS, wrong value"), ret = FALSE;
305 			gdome_str_unref(tstr1);
306 		}
307 	}
308 	dot();
309 
310 
311 	/* Now I build a simple tree with the nodes created */
312 	ntmp = (GdomeNode *)gdome_el_setAttributeNode (root, attr1, &exc);
313 	gdome_n_unref (ntmp, &exc);
314 	gdome_a_unref (attr1, &exc);
315 	ntmp = (GdomeNode *)gdome_el_setAttributeNode (el1, attr2, &exc);
316 	gdome_n_unref (ntmp, &exc);
317   gdome_a_unref (attr2, &exc);
318 	ntmp = (GdomeNode *)gdome_el_appendChild (root,GDOME_N(el1), &exc);
319 	gdome_n_unref (ntmp, &exc);
320   gdome_el_unref (el1, &exc);
321 	ntmp = (GdomeNode *)gdome_el_appendChild (root,GDOME_N(pi), &exc);
322 	gdome_n_unref (ntmp, &exc);
323 	gdome_pi_unref (pi, &exc);
324 	ntmp = (GdomeNode *)gdome_el_appendChild (el2,GDOME_N(txt), &exc);
325 	gdome_n_unref (ntmp, &exc);
326 	gdome_t_unref (txt, &exc);
327 	ntmp = (GdomeNode *)gdome_el_appendChild (el2,GDOME_N(cds), &exc);
328 	gdome_n_unref (ntmp, &exc);
329 	gdome_cds_unref (cds, &exc);
330 	ntmp = (GdomeNode *)gdome_el_appendChild (el2,GDOME_N(cmt), &exc);
331 	gdome_n_unref (ntmp, &exc);
332 	gdome_c_unref (cmt, &exc);
333 	ntmp = (GdomeNode *)gdome_el_appendChild (root,GDOME_N(el2), &exc);
334 	gdome_n_unref (ntmp, &exc);
335 	gdome_el_unref (el2, &exc);
336 	gdome_el_unref (root, &exc);
337 	dot();
338 
339 	printf ("test_document1\n");
340 	return ret;
341 }
342 
343 gboolean
test_document2(GdomeDocument * doc)344 test_document2 (GdomeDocument *doc) {
345 	GdomeElement *els[9], *root;
346 	GdomeNode *tel;
347 	GdomeNodeList *nl;
348 	GdomeException exc = 0;
349 	GdomeDOMString *tstr1;
350 	gboolean ret = TRUE;
351 	int i;
352 
353 	/* Test Document.getElementById*/
354 	for(i=0; i<9; i++) {
355 		tstr1 = gdome_str_mkref_own(g_strdup_printf("%d",i));
356 		els[i] = gdome_doc_getElementById(doc, tstr1, &exc);
357 		if(els[i] == NULL)
358 			fprintf (stderr, "\nDocument.getElementById(\"%s\"), NULL",tstr1->str), ret = FALSE;
359 		gdome_str_unref(tstr1);
360 	}
361 	dot();
362 
363   /* Test Document.getElementByTagName */
364 	tstr1 = gdome_str_mkref("NODE");
365 	nl = gdome_doc_getElementsByTagName(doc, tstr1, &exc);
366 	if(nl == NULL)
367 		fprintf (stderr, "\nDocument.getElementByTagName(\"%s\"), NULL",tstr1->str), ret = FALSE;
368 	if(gdome_nl_length(nl, &exc) != 9)
369 		fprintf (stderr, "\nDocument.getElementByTagName(\"%s\"), wrong length",tstr1->str), ret = FALSE;
370 	for(i=0; i<9; i++) {
371 		tel = gdome_nl_item(nl, (unsigned long)i, &exc);
372 		if (tel != (GdomeNode *)els[i])
373 			fprintf (stderr, "\nDocument.getElementByTagName(\"%s\"), wrong %d-th item",tstr1->str,i), ret = FALSE;
374 		if (tel != NULL)
375 			gdome_n_unref (tel, &exc);
376 	}
377 	gdome_str_unref(tstr1);
378 	dot();
379 
380 	/* Is NodeList live? */
381 	root = gdome_doc_documentElement (doc, &exc);
382 	tel = gdome_el_removeChild (root, (GdomeNode *)els[3], &exc);
383 	gdome_el_unref (els[5], &exc);
384 	gdome_el_unref (els[4], &exc);
385 	gdome_el_unref (els[3], &exc);
386 	gdome_n_unref (tel, &exc);
387 	gdome_el_unref (root, &exc);
388 	tel = gdome_nl_item(nl, 3L, &exc);
389 	if(tel != (GdomeNode *)els[6])
390 		fprintf (stderr, "\nNODELIST IS NOT LIVE!!"), ret = FALSE;
391 	gdome_n_unref (tel, &exc);
392 	gdome_nl_unref (nl, &exc);
393 	dot();
394 
395 	gdome_el_unref (els[0], &exc);
396 	gdome_el_unref (els[1], &exc);
397 	gdome_el_unref (els[2], &exc);
398 	gdome_el_unref (els[6], &exc);
399 	gdome_el_unref (els[7], &exc);
400 	gdome_el_unref (els[8], &exc);
401 
402 	printf ("test_document2\n");
403 	return ret;
404 }
405 
406 gboolean
test_document3(GdomeDocument * doc)407 test_document3 (GdomeDocument *doc) {
408 	GdomeElement *els[4], *root;
409 	GdomeNode *tel;
410 	GdomeNodeList *nl;
411 	GdomeException exc = 0;
412 	GdomeDOMString *tstr1, *tstr2;
413 	gboolean ret = TRUE;
414 	int i;
415 
416 	/* Test Document.getElementById*/
417 	for(i=1; i<9; i+=2) {
418 		tstr1 = gdome_str_mkref_own(g_strdup_printf("%d",i));
419 		els[i/2] = gdome_doc_getElementById(doc, tstr1, &exc);
420 		if(els[i/2] == NULL)
421 			fprintf (stderr, "\nDocument.getElementById(\"%s\"), NULL",tstr1->str), ret = FALSE;
422 		gdome_str_unref(tstr1);
423 	}
424 	dot();
425 
426   /* Test Document.getElementByTagNameNS */
427 	tstr1 = gdome_str_mkref("NODE");
428 	tstr2 = gdome_str_mkref("urn:test.tst");
429 	nl = gdome_doc_getElementsByTagNameNS(doc, tstr2, tstr1, &exc);
430 	if(nl == NULL)
431 		fprintf (stderr, "\nDocument.getElementByTagNameNS(\"%s\",\"%s\"), NULL",tstr2->str,tstr1->str), ret = FALSE;
432 	if(gdome_nl_length(nl, &exc) != 4)
433 		fprintf (stderr, "\nDocument.getElementByTagNameNS(\"%s\",\"%s\"), wrong length",tstr2->str,tstr1->str), ret = FALSE;
434 	for(i=0; i<4; i++) {
435 		tel = gdome_nl_item(nl, (unsigned long)i, &exc);
436 		if (tel != (GdomeNode *)els[i])
437 			fprintf (stderr, "\nDocument.getElementByTagName(\"%s\",\"%s\"), wrong %d-th item",tstr2->str,tstr1->str,i), ret = FALSE;
438 		if (tel != NULL)
439 			gdome_n_unref (tel, &exc);
440 	}
441 	gdome_str_unref(tstr1);
442 	gdome_str_unref(tstr2);
443 	dot();
444 
445 	/* Is NodeList live? */
446 	root = gdome_doc_documentElement (doc, &exc);
447   tel = gdome_el_removeChild (root, (GdomeNode *)els[1], &exc);
448   gdome_el_unref (els[2], &exc);
449   gdome_el_unref (els[1], &exc);
450 	gdome_n_unref (tel, &exc);
451 	gdome_el_unref (root, &exc);
452 	tel = gdome_nl_item(nl, 1L, &exc);
453 	if(tel != (GdomeNode *)els[3])
454 		fprintf (stderr, "\nNODELIST IS NOT LIVE!!"), ret = FALSE;
455 	gdome_n_unref (tel, &exc);
456 	gdome_nl_unref (nl, &exc);
457 	dot();
458 
459   gdome_el_unref (els[0], &exc);
460   gdome_el_unref (els[3], &exc);
461 
462 	printf ("test_document3\n");
463 	return ret;
464 }
465 
466 int
main(int argc,char ** argv)467 main (int argc, char **argv)
468 {
469 	GdomeDOMImplementation *domImpl = NULL;
470 	GdomeDocument *domdoc = NULL;
471 	GdomeDOMString *str = NULL;
472 	GdomeException exc = 0;
473 	gboolean ret;
474 
475 	domImpl = gdome_di_mkref();
476 	str = gdome_str_mkref ("TEST");
477 	domdoc = gdome_di_createDocument (domImpl, NULL, str, NULL, &exc);
478 	gdome_str_unref (str);
479 
480 	ret = test_document1(domdoc);
481 	gdome_di_saveDocToFile(domImpl, domdoc, LOCALDIR"/test-document1.xml", GDOME_SAVE_STANDARD, &exc);
482 	gdome_doc_unref(domdoc, &exc);
483 
484 	domdoc = gdome_di_createDocFromURI(domImpl, LOCALDIR"/test-document2.xml", GDOME_LOAD_PARSING, &exc);
485 	if (domdoc == NULL) {
486 		fprintf (stderr, "DOImplementation.createDocFromURI: failed\n   test-document2.xml not found\n");
487 		return -1;
488 	}
489 	ret = test_document2(domdoc);
490 	gdome_doc_unref (domdoc, &exc);
491 
492 	domdoc = gdome_di_createDocFromURI(domImpl, LOCALDIR"/test-document3.xml", GDOME_LOAD_PARSING, &exc);
493 	if (domdoc == NULL) {
494 		fprintf (stderr, "DOImplementation.createDocFromURI: failed\n   test-document3.xml not found\n");
495 		return -1;
496 	}
497 	ret = test_document3(domdoc);
498 	gdome_doc_unref (domdoc, &exc);
499 
500 	if(ret)
501 		return 0;
502 	else
503 		return -1;
504 }
505