Re: hello

Tony Graham <[email protected]> Wed, 06 Apr 2005 04:26:56 +0100
Newsgroups gmane.text.xml.xmlroff.general
Message-ID <[email protected]>
Welcome to the xmlroff-list, and thank you for your interest in
xmlroff.

Bruno Sadiez <[email protected]> writes:
> I'm currently working  on a project for a
> philanthropic organization. I need to write an
> invoicing application in C. I am not a professional
> developer. 
> What I need to do is fetch data from a database and
> issue PDF invoices.
> I'm using Daniel Veillard's Libxml2 library and I can
> issue XML data files with all the required billing
> details. I have written an XSL file with formating
> objects. 
> As this project is supposed to issue many thousand
> invoices at the end of each month, performance is a
> concern. I would like to be able to
> 		Load my XSLFO file only once
> 		Apply it to many thousand dynamically created XML
> data trees.
>
>
> 		my code goes:
>
> 		xmlDocPtr invoice_doc = NULL;
> 		(..... )
>
> 		invoice_doc = xmlNewDoc(BAD_CAST "1.0");
>  		invoice_root_node = xmlNewNode(NULL, BAD_CAST
> "invoice");
>  		xmlDocSetRootElement(invoice_doc,
> invoice_root_node);
>
> then I populate the tree with the required billing
> details.
>
> How is it possible to dynamically transform that
> memory tree into a PDF. I would like to avoid writing
> xml data files to disk.
>
> I hope I'm being clear.

Yes, you are.

The short answer is that you can do what you want.

The public interfaces for the libfo library work on filenames for the
XML input and the XSLT stylesheet (if any) so someone using the
library doesn't have to know or care about libxml2 or libxslt.

The public interfaces work on either strings or FoXmlDoc objects that
are really just GObject wrappers of libxml2.

The FoXSLTFormatter wrapper for libxslt currently requires a string
for the filename for the XSLT stylesheet, which is possibly
shortsighted of me.

You can, however, do the transformation yourself using libxslt and
then create a FoXmlDoc from the result of your transformation using
fo_xml_doc_set_xml_doc() from fo-xml-doc-private.h:

   FoXmlDoc result_tree = fo_xml_doc_new ();
   fo_xml_doc_set_xml_doc (result_tree, your_xml_doc_ptr);

You can then use your 'result_tree' with an FoXSLFormatter as in
xmlroff-libfo.c from the libfo-examples package.

The other thing to look at is using fo_libfo_init2() and supplying
your own malloc, etc. so that libfo and libxslt use the same heap.

You are trying something that AFAIK hasn't been tried before, so I'm
interested to know how you get on.  I do expect that you will find
that xmlroff has memory leaks, but if you can identify them, we can
look to fixing them.

Regards,


Tony.



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click