What changes to FoXmlDoc?
Tony Graham <[email protected]> Tue, 11 Apr 2006 20:30:20 +0100
| Newsgroups | gmane.text.xml.xmlroff.general |
|---|---|
| Message-ID | <[email protected]> |
I am looking at modifying FoXmlDoc (in libfo/fo-xml-doc.[ch]) so it's also
possible to create an FoXmlDoc from a string.
The question then becomes how to change it.
The present process for creating an FoXmlDoc from a filename is long-winded:
xml_doc = fo_xml_doc_new ();
fo_xml_doc_set_filename (xml_doc,
xml_file);
fo_xml_doc_parse (xml_doc,
libfo_context,
&error);
if (error != NULL)
{
g_critical ("%s:: %s",
g_quark_to_string (error->domain),
error->message);
g_error_free (error);
exit (1);
}
That's partly because in the GObject world, everything has a _new() function,
so the filename is set after the FoXmlDoc is created.
Creating an FoXmlDoc from a buffer would really be a wrapper on xmlReadMemory:
xmlDocPtr xmlReadMemory (const char * buffer,
int size,
const char * URL,
const char * encoding,
int options)
Where 'options' would be extracted from settings in an FoLibfoContext and the
rest would be set explicitly.
The short form of my question is, is it better to:
- Make separate 'constructors':
fo_xml_doc_new_from_filename (...)
fo_xml_doc_new_from_memory (...)
- Make separate subtypes:
fo_xml_doc_memory_new ()
fo_xml_doc_file_new ()
that each have their own _set() functions for their disparate parameters
- Parse on 'construction', such that the fo_xml_doc_parse() function is no
longer required
- Do something completely different?
Regards,
Tony.
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642