After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 680887 - [contribution] RELAX NG schema for 2.4.11 XML file format
[contribution] RELAX NG schema for 2.4.11 XML file format
Status: RESOLVED FIXED
Product: GnuCash
Classification: Other
Component: Backend - XML
2.4.x
Other All
: Normal enhancement
: ---
Assigned To: Christian Stimming
Geert Janssens
Depends on:
Blocks:
 
 
Reported: 2012-07-31 09:24 UTC by Baptiste Carvello
Modified: 2018-06-29 23:09 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Updated RELAX NG schema for 2.4.11 (20.09 KB, patch)
2012-07-31 09:24 UTC, Baptiste Carvello
committed Details | Review
schema for the development version (20.15 KB, text/plain)
2012-08-20 10:38 UTC, Baptiste Carvello
  Details
schema for the stable version (20.11 KB, text/plain)
2012-08-20 10:42 UTC, Baptiste Carvello
  Details

Description Baptiste Carvello 2012-07-31 09:24:53 UTC
Created attachment 219954 [details] [review]
Updated RELAX NG schema for 2.4.11

Hi,

while I know GnuCash cannot commit to a constant XML schema, it is sometimes useful to be able to validate the files produced by a given version (I for one have such a need for tax reporting purposes). In these cases, the non-normative RELAX NG schema at 'src/doc/xml/gnucash-v2.rnc' is handy. However, it has not been updated since 2006, and, while the GnuCash format is in practice quite stable, most current files no more validate.

Here is an updated schema to match the format produced by version 2.4.11. I based my work directly on the source code (in directories 'src/backend/xml' and 'src/engine'). In order to make future updating easier, I wrote down the appropriate reference for each part of the schema in comments.

This schema has been tested with my own GnuCash files, the ones in directory 'src/backend/xml/test/test-files/xml2' and a few others from the web. They all validate. However, these files mostly use the base features (commodities, accounts and transactions), so that less common features stay untested.

Cheers,
Baptiste
Comment 1 Yawar Amin 2012-08-04 14:13:12 UTC
Thanks for the contribution. I'm categorising this as XML Backend.
Comment 2 Geert Janssens 2012-08-05 13:58:03 UTC
Comment on attachment 219954 [details] [review]
Updated RELAX NG schema for 2.4.11

Thank you for your contribution. I have committed it in the development branch already and intend to commit it in the stable series as well, but there are currently some network issues.

Just out of curiosity: which tool do you use to test the validation of your gnucash files ? I'd like to try this as well with mine (I am using the business features a lot, so my data files can be a good test case for the schema as well).
Comment 3 Baptiste Carvello 2012-08-06 07:20:56 UTC
To answer Geert's tool question:

until now, I used a 2-step process: 1) convert the schema to XML syntax (.rng) using trang [1]. 2) validate with xmllint from libxml2 (any other XML validator will do, for example, the python-lxml bindings work too).

However, I just found out I can do it in one step with jing (same homepage as trang). Also, I won't miss xmllint's error reporting, which is rather confusing.

So the old way was:
trang gnucash-v2.rnc gnucash-v2.rng
xmllint --relaxng gnucash-v2.rng --noout test.gnucash

And the new way (less tested, but probably better) would be:
jing -c gnucash-v2.rnc test.gnucash
echo $?   (just to check, jing is silent on success)

If you have any questions with validation errors with your files, just ask me. Most probably you will find some cases where the schema is too constrained, as I've tried to be quite strict.

[1] http://code.google.com/p/jing-trang/
Comment 4 Geert Janssens 2012-08-18 09:19:35 UTC
Thanks for the information. jing is packaged for Fedora, so I could easily install and test it.

The schema didn't give any errors on a business file I use with GnuCash 2.4.11. So nice work !

The development series introduces a new element in the schema, which is not in your rng file yet:
test.xac:258073:18: error: element "invoice:slots" not allowed anywhere; expected the element end-tag or element "invoice:billto" or "invoice:charge-amt"

If you want to fix this, I will gladly add an updated rng file for the development series.

By the way, I have added a small note in the wiki to document the way to validate a gnucash xml file based on your information:
http://wiki.gnucash.org/wiki/GnuCash_XML_format#Validation
Comment 5 Baptiste Carvello 2012-08-20 10:38:23 UTC
Created attachment 221810 [details]
schema for the development version
Comment 6 Baptiste Carvello 2012-08-20 10:42:00 UTC
Created attachment 221811 [details]
schema for the stable version
Comment 7 Baptiste Carvello 2012-08-20 10:51:45 UTC
Hello,

indeed, the format has changed. The element type "invoice:slots", which previously had code only for parsing, but not for writing, is now exported. As a side note: similar unused "slots" element types (with code for parsing, probably for forward-compatibility) exist for other business objects. So similar format changes could happen in the future.

I have attached an updated schema for the development trunk (as of revision 22330). While doing this, I got aware of a small bug in my 2.4.11 schema, so I updated it too.

Cheers,
Baptiste
Comment 8 Geert Janssens 2012-11-03 09:25:19 UTC
Sorry for the long silence.

I have just committed your updated rng schemas to the proper branches.

I have also added a README file in the xml directory to explain how the relax ng schema can be used, based on your explanation in comment 3. This will only appear in the next stable release though.

Thanks a lot for your contributions !
Comment 9 John Ralls 2017-09-24 22:46:50 UTC
Reassign version to 2.4.x so that individual 2.4 versions can be retired.
Comment 10 John Ralls 2018-06-29 23:09:54 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=680887. Please update any external references or bookmarks.