namespace in the XML gnc-v2 tag proposal

Derek Atkins warlord at MIT.EDU
Sun Aug 10 20:26:52 CDT 2003

FYI, I have verified that this is not a backwards-compatible change.
If this patch were committed, then files output with this patch
applied would not be readable without this patch, which would be a
major data compatibility issue.

So I am not going to commit this patch.

I will, however, commit the one part of it that allows the reading
of the file-with-namespace to the 1.8 branch..  This will let future
versions read the XML file once we add the namespaces.

See bug #88078 for more information.


Matthew Vanecek <mevanecek at> writes:

> In the file backend, there exists a write_namespace_decl() function that
> is #ifdef-ed out, as well as some calls to it that place the appropriate
> declarations in the tag.  I've taken the liberty of enabling that
> function, and of modifying the write_namespace_decl() calls to include
> (hopefully) all the namespaces that can exist in the file.  I also
> modified the file version check to look at "<gnc-v2" instead of
> "<gnc-v2>".
> The benefits of this move may not be immediately visible to all.  First
> off, the change allows the file to work either with or without the
> decls, although saving the file will of course include the decls.
> Now, the benefit comes when the file is parsed by an XSLT parser.  The
> two XSLT parsers on Linux that I've tried are Saxon and Xalan, and both
> fail due to the namespaces not being declared.  Given the availability
> of XSLT parsers, coupled with the desire to export the XML file to
> different formats, it seems only natural to include the namespace
> declarations within the top element below root.
> What are the benefits of XSLT?  Well, let me tell you...XSLT provides an
> easy and rapid way to successfully transform a well-formed XML document
> into a variety of other formats without programatically changing Gnucash
> (other than the namespace decls, of course ;)  I was mucking about with
> a question by someone to see if there was a way to get a list of
> Customers out of the file.  Well, with XSLT, there is.  I'm able to pull
> a list of customers by name with no effort on my part--simply run the
> file and stylesheet through the parser, and voila! you have your list. 
> In my case (with my one customer), I set up HTML as the output style and
> got this (yes, it's raw html).
> <html xmlns:cust=""
> xmlns:gnc="">
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
> <title>Finances File</title>
> </head>
> <body>
> <h1>Customers</h1>
> <p>My Widgets</p>
> </body>
> </html>
> The point is, much could be done with XSLT to provide the hotly desired
> export capabilities without affecting the internals of Gnucash one
> single solitary bit.  Heck, someone could write a stylesheet that
> transforms the Gnucash file to an OO spreadsheet, or worse, to an Excel
> spreadsheet (the doc spec is only what, 100 pages? =P)!! but it depends
> on having the well-formed XML (which, for the XSLT parser means the
> namespaces are declared *shrug*).
> Anyhow, the attached patch accomplishes the namespace part.  It would
> make life easier/safer for XSLT writers, because then they wouldn't have
> to edit the Gnucash XML file by hand to add the declarations...
> The attached patch is against HEAD, but it applied cleanly (with an
> offset) to 1.8.x CVS, too.
> Thanks,
> -- 
> Matthew Vanecek
> perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
> ********************************************************************************
> For 93 million miles, there is nothing between the sun and my shadow except me.
> I'm always getting in the way of something...
> _______________________________________________
> gnucash-devel mailing list
> gnucash-devel 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-patches mailing list