Creating Gnucash invoices with XML/XSLT

Derek Atkins warlord at MIT.EDU
Mon Apr 5 10:16:08 EDT 2004


This is probably more appropriate for gnucash-devel, so I've forwarded
it there.

Keep in mind that XML as a gnucash data format is deprecated, so do not
depend on your data being stored in XML.  Even so, modifying your XML file
out-of-band is an unsupported operation.

The documentation section you reference really talks about moving data OUT
of gnucash, not INTO gnucash.

Honestly, what really should happen is a CSV importer that allows you to
import business objects.  We've already got the code to read a CSV file,
but no code to DO anything with it.  If someone wanted to write a CSV
importer it would:

a) be greatly appreciated by many people,
b) solve most of these import problems,
c) be gladly accepted into the sources.

I dont know how we could ship an xslt; we could put one into CVS, and
probably even into the source tarball, but I have no clue where one
would install it.  And with the XML file going away I see little point
in distributing it in the long term.


Neil Williams <linux at> writes:

> From the Help file:
> A.5. Converting XML GnuCash File
> You will now have a file in the desired output format. An enterprising 
> individual could go so far as to write a stylesheet to transform the Gnucash 
> data file to an OpenOffice spreadsheet (or vice-versa, for that matter). Such 
> things as QIF ought to be a little less work.
> The interesting part from my point of view is the vice-versa. I'm used to 
> writing XSLT, although I've not done much with command-line XSLT clients in 
> Linux so far, and I'm sure I can obtain the necessary data from existing data 
> files in use by KOrganizer / pilot-link(expenses) to feed into an XSLT 
> stylesheet.
> What I would like to do is:
> 1. Collate data from a Palm Pilot and/or KOrganizer into a bespoke XML file - 
> this part I'll do myself.
> 2. Use XSLT to transform the XML into a Gnucash compatible format. (Or even 
> write the data straight into the final format.)
> 3. Import the completed invoice directly into Gnucash, ready for posting.
>  (or maybe already posted).
> 4. This would be run, at most, once each day and would only import one invoice 
> at a time - each invoice accounting for a complete day's work.
> My reasoning is that my business work relies on valid data in the calendar and 
> expenses databases of the Palm, sync'ed to Kontact (KOrganizer and 
> addressbook) or to a stand-alone expenses file using pilot-link. I don't want 
> to have to re-type all that data again to generate the invoice within 
> Gnucash.
> I have a client number in the Palm that already matches the job Billing ID.
> I have data in addressbook that matches the customer name in Gnucash and can 
> be easily crafted to pattern match to the customer ID if necessary.
> I have the date, the rate, the account names are predictable and various 
> expense types can be handled.
> I can code for a reliable post date and description, should it be possible to 
> import an invoice as posted (or post immediately on import using data 
> provided).
> I have 4 customers and between 2 and 30 jobs for each (most of which repeat at 
> various times). Each can have different rates and all have different hours. 
> Some have no expenses, some have 3 separate expense claims. No invoice runs 
> over 7 days, all invoices will be one-per-job as with current Gnucash 
> invoices and the average invoice consists of 1-6 items.
> Before I start work on the XML, I want to be clear on whether the data can be 
> imported into Gnucash and whether I can expect the import to include all 
> necessary data and tie in with older, manual, invoices.
> The final XSLT / XML spec. will be free software and could be included in 
> future Gnucash releases, if appropriate.
> -- 
> Neil Williams
> =============
> _______________________________________________
> gnucash-user mailing list
> gnucash-user at

       Derek Atkins, SB '93 MIT EE, SM '95 MIT Media Laboratory
       Member, MIT Student Information Processing Board  (SIPB)
       URL:    PP-ASEL-IA     N1NWH
       warlord at MIT.EDU                        PGP key available

More information about the gnucash-devel mailing list