I've written a simple XSLT transformation for the Gnucash XML file. It spits out an HTML file with a 4-column table, "Account Name", "Date Entered", "Number", "Descriptions", "Value". The "Value" column values are preceded by an '='. This makes it easy to import into OOo Calc, due to the way values are stored in our XML file.
To use: 1) Install saxon or xalan, if you don't have it. Or any other XML->XSLT processor, for that matter (e.g., msxsl on Windows). 2) Copy your Gnucash data file to <file>.xml somewhere. DO NOT WORK ON YOUR ORIGINAL FILE!! 3) In the <file>.xml, near the top, change <gnc:v2> to the text in SECTION A below. Save the file. 4) Run <file>.xml and the attached XSLT through the XSLT processor of your choice. I use saxan, e.g.: saxon -o finances.html finances.xml finances.xsl 5) Open the HTML in your browser for inspection, or in OpenOffice Calc for editing. I've limited the date range to date-entered in the year 2003. You can change that in the XSLT file. This stylesheet is more a reference than anything. It groups all the data by Account, not by transaction. That's easy enough to change, if you muck about with the for-each loops. Once you see how it works, it's possible to go in and rearrange stuff differently. Just don't use your main data file! Always use a copy to muck with. Enjoy, -- 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... //----------------SECTION A BEGIN------------------------- <gnc-v2 xmlns:cd="http://www.gnucash.org/XML/cd" xmlns:book="http://www.gnucash.org/XML/book" xmlns:gnc="http://www.gnucash.org/XML/gnc" xmlns:cmdty="http://www.gnucash.org/XML/cmdty" xmlns:trn="http://www.gnucash.org/XML/trn" xmlns:split="http://www.gnucash.org/XML/split" xmlns:act="http://www.gnucash.org/XML/act" xmlns:price="http://www.gnucash.org/XML/price" xmlns:ts="http://www.gnucash.org/XML/ts" xmlns:slot="http://www.gnucash.org/XML/kvpslot" xmlns:cust="http://www.gnucash.org/XML/cust" xmlns:addr="http://www.gnucash.org/XML/custaddr"> //----------------SECTION A END-------------------------
<?xml version="1.0"?> <!-- Copyright (C) 2003 Matt Vanecek License is hereby granted to freely copy, modify, or distribute this work under the terms of the GNU General Public License, as found at http://www.gnu.org/licenses/gpl.html. --> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gnc="http://www.gnucash.org/XML/gnc" xmlns:cmdty="http://www.gnucash.org/XML/cmdty" xmlns:price="http://www.gnucash.org/XML/price" xmlns:act="http://www.gnucash.org/XML/act" xmlns:trn="http://www.gnucash.org/XML/trn" xmlns:split="http://www.gnucash.org/XML/split" xmlns:ts="http://www.gnucash.org/XML/ts" xmlns:cust="http://www.gnucash.org/XML/cust"> <xsl:output method="html" indent="yes" encoding="ISO-8859-1"/> <xsl:template match="gnc-v2/gnc:book"> <html> <head><title>Finances File</title></head> <body> <table border="1"> <th>Account Name</th> <th>Date Entered</th> <th>Number</th> <th>Descriptions</th> <th>Value</th> <xsl:for-each select="gnc:account"> <xsl:sort select="act:name"/> <xsl:variable name="accountid"> <xsl:value-of select="act:id"/> </xsl:variable> <xsl:variable name="actname"> <xsl:value-of select="act:name"/> </xsl:variable> <xsl:for-each select="../gnc:transaction"> <xsl:sort select="trn:date-entered/ts:date"/> <xsl:sort select="trn:num"/> <!-- Change 2003 to a different year, or even to a year-mo form (e.g., 2003-06) to get different sets of transactions --> <xsl:if test="starts-with(trn:date-entered/ts:date, '2003') and $accountid = trn:splits/trn:split/split:account"> <tr> <td><xsl:value-of select="$actname"/></td> <td><xsl:value-of select="trn:date-entered/ts:date"/></td> <td><xsl:value-of select="trn:num"/></td> <td><xsl:value-of select="trn:description"/></td> <td>=<xsl:value-of select="trn:splits/trn:split/split:value"/></td> </tr> </xsl:if> </xsl:for-each> </xsl:for-each> </table> <HR size="5"/> </body> </html> </xsl:template> <!-- Root template - weed out the stuff we don't want --> <xsl:template match="text() | @*"> </xsl:template> </xsl:stylesheet>
_______________________________________________ gnucash-devel mailing list [EMAIL PROTECTED] http://www.gnucash.org/cgi-bin/mailman/listinfo/gnucash-devel