[gdome] Namespace - Saving to a File
- From: Chetan Raj <hichetu gmail com>
- To: gdome gnome org
- Subject: [gdome] Namespace - Saving to a File
- Date: Thu, 28 Apr 2005 22:18:44 +0530
Hello All,
When I create a document with a namespace and then save the document to a file, then the namespace was not saved.
Ex:
GdomeException exc = NULL;
GdomeDOMImplementation *domimpl = gdome_di_mkref ();
GdomeDOMString* ns = gdome_str_mkref("
http://www.w3.org/2000/svg");
GdomeDOMString* ln = gdome_str_mkref("nm:chet");
GdomeDocument *doc = gdome_di_createDocument(domimpl,ns ,ln , NULL,&exc);
gdome_di_saveDocToFile (domimpl, doc, "test.xml", GDOME_SAVE_STANDARD, &exc);
gdome_str_unref (ns);
gdome_str_unref (ln);
For the above code, the test.xml saved was this...
<?xml version="1.0"?>
<nm:chet/>
When I debugged, I found that libxml xmlNode has two xmlns pointers
xmlNs
*ns; /* pointer to the
associated namespace */
xmlNs
*nsDef; /* namespace definitions on this node */
In
xmlNewNode function, we were poulating only ns and not nsDef. (
file tree.c line n.o: 2139 ver: libxml2-2.6.11 )
cur->ns = ns;
and in
xmlNodeDumpOutputInternal function we were checking for nsDef to save
the namespace data!! ( file xmlsave.c, line n.o 743 ver:
libxml2-2.6.11 )
if (cur->nsDef)
xmlNsListDumpOutput(buf, cur->nsDef);
When I modified tree.c in xmlNewNode function as shown
cur->ns = ns;
cur->nsDef = ns; // Added this line to make namespace save to file work. Before this Namespaces were not saving to a file.
Then we were successfully able to save the Namespaces to the file. and the output we got is
<?xml version="1.0"?>
<nm:chet xmlns:nm="http://www.w3.org/2000/svg"/
>
Is the fix I gave correct? Why do we have two xmlNs(ns and nsDef) pointers?
When will this fix be rolled into future releases of libxml?
If you have any other suggesions to use and save namespaces, please reply to me.
Thanks in advance for any help,
Chetan Raj
[Date Prev][Date Next] [Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]