Difference between revisions of "GnuCash XML format"

From GnuCash
Jump to: navigation, search
(Updating content to remove outdated information on the transition from version 1.8 to 1.9)
(Move category to top; update links;)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
[[Category:XML]]
 
This article collects some notes about the XML file format of GnuCash. It is descriptive, and neither normative nor authoritative.  
 
This article collects some notes about the XML file format of GnuCash. It is descriptive, and neither normative nor authoritative.  
  
 
Beginning with version 1.6, the primary GnuCash storage mechanism is an XML file. The file is optionally compressed with gzip, which is a preference that is set at <u>E</u>dit→Preferences→General→Use file compression.
 
Beginning with version 1.6, the primary GnuCash storage mechanism is an XML file. The file is optionally compressed with gzip, which is a preference that is set at <u>E</u>dit→Preferences→General→Use file compression.
  
There is a non-normative RELAX NG schema for the XML file format ([https://github.com/Gnucash/gnucash/blob/maint/libgnucash/doc/xml/gnucash-v2.rnc gnucash-v2.rnc]). There are also DTD schema definitions, but these are outdated and do not define the current format correctly ([https://github.com/Gnucash/gnucash/tree/maint/libgnucash/doc/xml libgnucash/doc/xml]).
+
[{{URL:git}}gnucash/blob/stable/libgnucash/backend/xml/DTD/gnucash-v2.rnc gnucash-v2.rnc] is a non-normative RELAX NG schema for the XML file format. There are also DTD schema definitions in [{{URL:git}}gnucash/tree/stable/libgnucash/backend/xml/DTD libgnucash/doc/xml], but these are outdated and do not define the current format correctly.
  
 
Many elements in the XML file are identified by Globally Unique Identifiers (GUID). GnuCash includes its own GUID implementation.
 
Many elements in the XML file are identified by Globally Unique Identifiers (GUID). GnuCash includes its own GUID implementation.
Line 15: Line 16:
 
The RELAX NG schema file mentioned above can be used to validate an uncompressed GnuCash XML data file. This requires that you:
 
The RELAX NG schema file mentioned above can be used to validate an uncompressed GnuCash XML data file. This requires that you:
 
* save your GnuCash data file in uncompressed format
 
* save your GnuCash data file in uncompressed format
* use an XML validator--e.g., [https://github.com/relaxng/jing-trang Jing], which will be used in this example.
+
* use an XML validator--e.g., [{{URL:GH}}relaxng/jing-trang Jing], which will be used in this example.
  
 
As stated above, the GnuCash data file is by default stored using gzip compression. You must first save your data file in an uncompressed state. The easiest way to do this is to change the storage preference and save your file. (Remember to reset the preference afterwards).
 
As stated above, the GnuCash data file is by default stored using gzip compression. You must first save your data file in an uncompressed state. The easiest way to do this is to change the storage preference and save your file. (Remember to reset the preference afterwards).
  
 
Then download jing and run the following command
 
Then download jing and run the following command
  jing -c path-to-gnucash-v2.rnc path-to-your-datafile.gnucash
+
<Syntaxhighlight lang="sh">
 
+
jing -c path-to-gnucash-v2.rnc path-to-your-datafile.gnucash
 +
</Syntaxhighlight>
 
jing will report any validation errors it finds.
 
jing will report any validation errors it finds.
  
 
;Note:The validation should not be considered authoritative, as the schema is not updated or tested very often. So validation errors can just as easily be due to errors in the schema than due to errors in the data file.
 
;Note:The validation should not be considered authoritative, as the schema is not updated or tested very often. So validation errors can just as easily be due to errors in the schema than due to errors in the data file.
  
''Based on information provided by Baptiste Carvello in [https://bugzilla.gnome.org/show_bug.cgi?id=680887 bug 680887].''
+
''Based on information provided by Baptiste Carvello in [{{URL:Bugs}}show_bug.cgi?id=680887 bug 680887].''
  
 
==External links==
 
==External links==
* http://gnucashtoqif.sourceforge.net/ - GnuCash XML &rarr; [[Wikipedia:QIF|QIF]] conversion tool
+
* https://gnucashtoqif.us/ - GnuCash XML &rarr; [{{URL:wp}}QIF QIF] conversion tool
** [http://gnucashtoqif.sourceforge.net/#mozTocId164261 notes about file format]
+
*: [https://gnucashtoqif.us/#mozTocId164261 Notes about file format]
* [http://web.archive.org/web/20070219085556/http://edseek.com/archives/2005/08/18/gnucash-export-to-gnumeric-and-csv/ GnuCash export to Gnumeric and CSV], using [[Wikipedia:XSL Transformations|XSLT]] -- NOTE: With GnuCash 3.2, users can export to CSV directly from the program.
+
* [{{URL:WA}}20070219085556/http://edseek.com/archives/2005/08/18/gnucash-export-to-gnumeric-and-csv/ GnuCash export to Gnumeric and CSV], using [{{URL:wp}}XSLT XSLT] -- '''Note:''' With '''GnuCash 3.2''', users can export to CSV directly from the program.

Latest revision as of 22:16, 8 October 2024

This article collects some notes about the XML file format of GnuCash. It is descriptive, and neither normative nor authoritative.

Beginning with version 1.6, the primary GnuCash storage mechanism is an XML file. The file is optionally compressed with gzip, which is a preference that is set at Edit→Preferences→General→Use file compression.

gnucash-v2.rnc is a non-normative RELAX NG schema for the XML file format. There are also DTD schema definitions in libgnucash/doc/xml, but these are outdated and do not define the current format correctly.

Many elements in the XML file are identified by Globally Unique Identifiers (GUID). GnuCash includes its own GUID implementation.

Character encoding

With GnuCash 1.9.0, GnuCash writes the XML document using UTF-8 encoding and includes the appropriate encoding declaration in the opening XML text declaration.

Validation

The RELAX NG schema file mentioned above can be used to validate an uncompressed GnuCash XML data file. This requires that you:

  • save your GnuCash data file in uncompressed format
  • use an XML validator--e.g., Jing, which will be used in this example.

As stated above, the GnuCash data file is by default stored using gzip compression. You must first save your data file in an uncompressed state. The easiest way to do this is to change the storage preference and save your file. (Remember to reset the preference afterwards).

Then download jing and run the following command

jing -c path-to-gnucash-v2.rnc path-to-your-datafile.gnucash

jing will report any validation errors it finds.

Note
The validation should not be considered authoritative, as the schema is not updated or tested very often. So validation errors can just as easily be due to errors in the schema than due to errors in the data file.

Based on information provided by Baptiste Carvello in bug 680887.

External links