I have spent a couple hours learning some XML and hacked an XSL file to convert from a GnuCash Account file to a Gnumeric spreadsheet. It is very rough at this point. Downloaded it at http://www.neurosoft.org/gnucash/gnumeric_xsl , or get it from the attachment.
A couple of obvious (and major) problems: 1. Gnucash does not define its Namespaces properly. For XSL to work, you have to edit the Account file, and change <gnc-v2> to: <gnc-v2 xmlns:act="http://www.gnucash.org/act" xmlns:gnc="http://www.gnucash.org/gnc" xmlns:trn="http://www.gnucash.org/trn" xmlns:ts="http://www.gnucash.org/ts" xmlns:split="http://www.gnucash.org/split"> These are just bogus values. The Gnucash project needs to properly define the namespaces; this has been mentioned before on this list. 2. I haven't been able to properly connect the Account Name and the Account ID within the spreadsheet. This causes the transactions to be listed by the ID instead of by the name. --- To use with Apache Xalan, execute $ java org.apache.xalan.xslt.Process -in Accounts.gnucash -xsl gnumeric.xsl -out Accounts.gnumeric --- Suggestions/Criticism/etc welcome. I'm doing this for my own benefit, but I would like to know if this would be useful to the project. I'm curious if this might be better implemented as a SXSL (scheme XSL: http://okmij.org/ftp/Scheme/xml.html) thanks, Zach Garner p.s. I sent a similar message little while back, but it apparently didn't make it because the maintainer is behind. (that's OK though!)
<?xml version="1.0"?> <!-- - Copyright (c) 2002 Zach Garner. All rights reserved. - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. All advertising materials mentioning features or use of this software - must display the following acknowledgement: - This product includes software developed by the University of - California, Berkeley and its contributors. - 4. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - SUCH DAMAGE. --> <xsl:stylesheet version="1.0" xmlns:gnc="http://www.gnucash.org/gnc" xmlns:act="http://www.gnucash.org/act" xmlns:trn="http://www.gnucash.org/trn" xmlns:ts="http://www.gnucash.org/ts" xmlns:split="http://www.gnucash.org/split" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="/"> <gmr:Workbook xmlns:gmr="http://www.gnumeric.org/v10.dtd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.gnumeric.org/v8.xsd"> <gmr:Attributes> <gmr:Attribute> <gmr:name>WorkbookView::show_horizontal_scrollbar</gmr:name> <gmr:type>4</gmr:type> <gmr:value>TRUE</gmr:value> </gmr:Attribute> <gmr:Attribute> <gmr:name>WorkbookView::show_vertical_scrollbar</gmr:name> <gmr:type>4</gmr:type> <gmr:value>TRUE</gmr:value> </gmr:Attribute> <gmr:Attribute> <gmr:name>WorkbookView::show_notebook_tabs</gmr:name> <gmr:type>4</gmr:type> <gmr:value>TRUE</gmr:value> </gmr:Attribute> <gmr:Attribute> <gmr:name>WorkbookView::do_auto_completion</gmr:name> <gmr:type>4</gmr:type> <gmr:value>TRUE</gmr:value> </gmr:Attribute> </gmr:Attributes> <gmr:Summary> <gmr:Item> <gmr:name>application</gmr:name> <gmr:val-string>gnumeric</gmr:val-string> </gmr:Item> <gmr:Item> <gmr:name>author</gmr:name> <gmr:val-string>Zach Garner</gmr:val-string> </gmr:Item> </gmr:Summary> <gmr:SheetNameIndex> <gmr:SheetName>Sheet1</gmr:SheetName> </gmr:SheetNameIndex> <gmr:Names/> <gmr:Geometry Width="1166" Height="746"/> <gmr:Sheets> <gmr:Sheet DisplayFormulas="false" HideZero="false" HideGrid="false" HideColHeader="false" HideRowHeader="false" DisplayOutlines="true" OutlineSymbolsBelow="true" OutlineSymbolsRight="true"> <gmr:Name>Sheet1</gmr:Name> <gmr:MaxCol>1</gmr:MaxCol> <gmr:MaxRow>0</gmr:MaxRow> <gmr:Zoom>1.000000</gmr:Zoom> <gmr:Names/> <gmr:PrintInformation> <gmr:Margins> <gmr:top Points="28.3" PrefUnit="cm"/> <gmr:bottom Points="28.3" PrefUnit="cm"/> <gmr:left Points="28.3" PrefUnit="cm"/> <gmr:right Points="28.3" PrefUnit="cm"/> <gmr:header Points="14.2" PrefUnit="cm"/> <gmr:footer Points="14.2" PrefUnit="cm"/> </gmr:Margins> <gmr:Scale type="percentage" percentage="100"/> <gmr:vcenter value="0"/> <gmr:hcenter value="0"/> <gmr:grid value="0"/> <gmr:even_if_only_styles value="0"/> <gmr:monochrome value="0"/> <gmr:draft value="0"/> <gmr:titles value="0"/> <gmr:repeat_top value=""/> <gmr:repeat_left value=""/> <gmr:order>r_then_d</gmr:order> <gmr:orientation>landscape</gmr:orientation> <gmr:Header Left="" Middle="&[TAB]" Right=""/> <gmr:Footer Left="" Middle="Page &[PAGE]" Right=""/> <gmr:paper>A4</gmr:paper> </gmr:PrintInformation> <gmr:Styles> <gmr:StyleRegion startCol="0" startRow="0" endCol="0" endRow="65535"> <gmr:Style HAlign="1" VAlign="2" WrapText="0" Orient="1" Shade="0" Indent="0" Locked="1" Hidden="0" Fore="0:0:0" Back="FFFF:FFFF:FFFF" PatternColor="0:0:0" Format="m/d/yy"> <gmr:Font Unit="9" Bold="0" Italic="0" Underline="0" StrikeThrough="0">Helvetica</gmr:Font> <gmr:StyleBorder> <gmr:Top Style="0"/> <gmr:Bottom Style="0"/> <gmr:Left Style="0"/> <gmr:Right Style="0"/> <gmr:Diagonal Style="0"/> <gmr:Rev-Diagonal Style="0"/> </gmr:StyleBorder> </gmr:Style> </gmr:StyleRegion> <gmr:StyleRegion startCol="1" startRow="0" endCol="255" endRow="65535"> <gmr:Style HAlign="1" VAlign="2" WrapText="0" Orient="1" Shade="0" Indent="0" Locked="1" Hidden="0" Fore="0:0:0" Back="FFFF:FFFF:FFFF" PatternColor="0:0:0" Format="General"> <gmr:Font Unit="9" Bold="0" Italic="0" Underline="0" StrikeThrough="0">Helvetica</gmr:Font> <gmr:StyleBorder> <gmr:Top Style="0"/> <gmr:Bottom Style="0"/> <gmr:Left Style="0"/> <gmr:Right Style="0"/> <gmr:Diagonal Style="0"/> <gmr:Rev-Diagonal Style="0"/> </gmr:StyleBorder> </gmr:Style> </gmr:StyleRegion> </gmr:Styles> <gmr:Cols DefaultSizePts="48"> <gmr:ColInfo No="0" Unit="48" MarginA="2" MarginB="2" Count="2"/> </gmr:Cols> <gmr:Rows DefaultSizePts="12.8"> <gmr:RowInfo No="0" Unit="12.8" MarginA="1" MarginB="0"/> </gmr:Rows> <gmr:Selections CursorCol="1" CursorRow="7"> <gmr:Selection startCol="1" startRow="7" endCol="1" endRow="7"/> </gmr:Selections> <gmr:Cells> <xsl:apply-templates/> </gmr:Cells> <gmr:SheetLayout TopLeft="A1"/> <gmr:Solver TargetCol="-1" TargetRow="-1" ProblemType="1" Inputs=""/> </gmr:Sheet> </gmr:Sheets> <gmr:UIData SelectedTab="0"/> </gmr:Workbook> </xsl:template> <xsl:template match="gnc-v2"> <xsl:apply-templates/> </xsl:template> <xsl:template match="gnc:count-data"> </xsl:template> <!-- output comma delimited account information --> <xsl:template match="gnc:account"> <gmr:Cell Col="5" ValueType="60"><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute><xsl:value-of select="act:name"/></gmr:Cell> <gmr:Cell Col="6" ValueType="60"><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute><xsl:value-of select="act:type"/></gmr:Cell> <gmr:Cell Col="7" ValueType="60"><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute><xsl:value-of select="act:id"/></gmr:Cell> </xsl:template> <xsl:template match="gnc:transaction"> <xsl:for-each select="trn:splits/trn:split"> <gmr:Cell Col="0" ><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute>=datevalue(left("<xsl:value-of select="../../trn:date-posted/ts:date"/>", 10))</gmr:Cell> <gmr:Cell Col="1" ValueType="60"><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute><xsl:value-of select="../../trn:description"/></gmr:Cell> <gmr:Cell Col="2"><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute>=<xsl:value-of select="split:value"/></gmr:Cell> <gmr:Cell Col="3" ValueType="60"><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute><xsl:value-of select="split:account"/></gmr:Cell> <gmr:Cell Col="4" ValueType="60"><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute> <xsl:value-of select="/gnc-v2/gnc:account[act:id=split:account]"/> </gmr:Cell> <!-- <gmr:Cell Col="4" ValueType="60"><xsl:attribute name="Row"><xsl:number level="any"/></xsl:attribute><xsl:for-each select="/gnc-v2/gnc:account"><xsl:if test="act:id=a"></xsl:if></xsl:for-each></gmr:Cell> --> </xsl:for-each> </xsl:template> </xsl:stylesheet>