r19361 - gnucash/trunk/src - Merge the xml parsers of business objects into the main xml backend module.

Christian Stimming cstim at code.gnucash.org
Tue Jul 13 05:55:47 EDT 2010


Author: cstim
Date: 2010-07-13 05:55:46 -0400 (Tue, 13 Jul 2010)
New Revision: 19361
Trac: http://svn.gnucash.org/trac/changeset/19361

Added:
   gnucash/trunk/src/backend/xml/gnc-address-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-address-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-bill-term-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-bill-term-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-customer-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-customer-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-employee-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-employee-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-entry-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-entry-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-invoice-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-invoice-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-job-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-job-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-order-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-order-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-owner-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-owner-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-tax-table-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-tax-table-xml-v2.h
   gnucash/trunk/src/backend/xml/gnc-vendor-xml-v2.c
   gnucash/trunk/src/backend/xml/gnc-vendor-xml-v2.h
   gnucash/trunk/src/backend/xml/xml-helpers.h
Removed:
   gnucash/trunk/src/business/business-core/CMakeLists.txt
   gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.c
   gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.h
   gnucash/trunk/src/business/business-core/xml/xml-helpers.h
Modified:
   gnucash/trunk/src/backend/xml/CMakeLists.txt
   gnucash/trunk/src/backend/xml/Makefile.am
   gnucash/trunk/src/backend/xml/gnc-backend-xml.c
   gnucash/trunk/src/business/business-core/xml/Makefile.am
Log:
Merge the xml parsers of business objects into the main xml backend module.

Modified: gnucash/trunk/src/backend/xml/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/backend/xml/CMakeLists.txt	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/backend/xml/CMakeLists.txt	2010-07-13 09:55:46 UTC (rev 19361)
@@ -23,15 +23,26 @@
 
 SET (libgnc_backend_xml_SOURCES
   gnc-account-xml-v2.c 
+  gnc-address-xml-v2.c
+  gnc-bill-term-xml-v2.c
   gnc-book-xml-v2.c 
   gnc-budget-xml-v2.c 
   gnc-commodity-xml-v2.c 
+  gnc-customer-xml-v2.c
+  gnc-employee-xml-v2.c
+  gnc-entry-xml-v2.c
   gnc-freqspec-xml-v2.c 
+  gnc-invoice-xml-v2.c
+  gnc-job-xml-v2.c
   gnc-lot-xml-v2.c 
+  gnc-order-xml-v2.c
+  gnc-owner-xml-v2.c
   gnc-pricedb-xml-v2.c 
   gnc-recurrence-xml-v2.c 
   gnc-schedxaction-xml-v2.c 
+  gnc-tax-table-xml-v2.c
   gnc-transaction-xml-v2.c 
+  gnc-vendor-xml-v2.c
   io-example-account.c 
   io-gncxml-gen.c 
   io-gncxml-v1.c 

Modified: gnucash/trunk/src/backend/xml/Makefile.am
===================================================================
--- gnucash/trunk/src/backend/xml/Makefile.am	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/backend/xml/Makefile.am	2010-07-13 09:55:46 UTC (rev 19361)
@@ -20,15 +20,26 @@
 
 libgnc_backend_xml_utils_la_SOURCES = \
   gnc-account-xml-v2.c \
+  gnc-address-xml-v2.c \
+  gnc-bill-term-xml-v2.c \
   gnc-book-xml-v2.c \
   gnc-budget-xml-v2.c \
   gnc-commodity-xml-v2.c \
+  gnc-customer-xml-v2.c \
+  gnc-employee-xml-v2.c \
+  gnc-entry-xml-v2.c \
   gnc-freqspec-xml-v2.c \
+  gnc-invoice-xml-v2.c \
+  gnc-job-xml-v2.c \
   gnc-lot-xml-v2.c \
+  gnc-order-xml-v2.c \
+  gnc-owner-xml-v2.c \
   gnc-pricedb-xml-v2.c \
   gnc-recurrence-xml-v2.c \
   gnc-schedxaction-xml-v2.c \
+  gnc-tax-table-xml-v2.c \
   gnc-transaction-xml-v2.c \
+  gnc-vendor-xml-v2.c \
   io-example-account.c \
   io-gncxml-gen.c \
   io-gncxml-v1.c \
@@ -47,18 +58,30 @@
 noinst_HEADERS = \
   gnc-backend-xml.h \
   gnc-xml.h \
+  gnc-address-xml-v2.h \
+  gnc-bill-term-xml-v2.h \
+  gnc-customer-xml-v2.h \
+  gnc-employee-xml-v2.h \
+  gnc-entry-xml-v2.h \
+  gnc-invoice-xml-v2.h \
+  gnc-job-xml-v2.h \
+  gnc-order-xml-v2.h \
+  gnc-owner-xml-v2.h \
+  gnc-tax-table-xml-v2.h \
+  gnc-vendor-xml-v2.h \
   gnc-xml-helper.h \
   io-example-account.h \
   io-gncxml-gen.h \
+  io-gncxml-v2.h \
   io-gncxml.h \
-  io-gncxml-v2.h \
   io-utils.h \
   sixtp-dom-generators.h \
   sixtp-dom-parsers.h \
-  sixtp.h \
   sixtp-parsers.h \
   sixtp-stack.h \
-  sixtp-utils.h
+  sixtp-utils.h \
+  sixtp.h \
+  xml-helpers.h
 
 libgnc_backend_xml_utils_la_LIBADD = \
    ${GLIB_LIBS} \

Copied: gnucash/trunk/src/backend/xml/gnc-address-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-address-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-address-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,239 @@
+/********************************************************************\
+ * gnc-address-xml-v2.c -- address xml i/o implementation           *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gnc-address-xml-v2.h"
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *address_version_string = "2.0.0";
+
+/* ids */
+#define addr_name_string	"addr:name"
+#define addr_addr1_string	"addr:addr1"
+#define addr_addr2_string	"addr:addr2"
+#define addr_addr3_string	"addr:addr3"
+#define addr_addr4_string	"addr:addr4"
+#define addr_phone_string	"addr:phone"
+#define addr_fax_string		"addr:fax"
+#define addr_email_string	"addr:email"
+#define addr_slots_string	"addr:slots"
+
+static void
+maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
+{
+    if (str && strlen(str) > 0)
+        xmlAddChild (ptr, text_to_dom_tree (tag, str));
+}
+
+xmlNodePtr
+gnc_address_to_dom_tree (const char *tag, GncAddress *addr)
+{
+    xmlNodePtr ret;
+
+    ret = xmlNewNode(NULL, BAD_CAST tag);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST address_version_string);
+
+    maybe_add_string (ret, addr_name_string, gncAddressGetName (addr));
+
+    maybe_add_string (ret, addr_addr1_string, gncAddressGetAddr1 (addr));
+    maybe_add_string (ret, addr_addr2_string, gncAddressGetAddr2 (addr));
+    maybe_add_string (ret, addr_addr3_string, gncAddressGetAddr3 (addr));
+    maybe_add_string (ret, addr_addr4_string, gncAddressGetAddr4 (addr));
+
+    maybe_add_string (ret, addr_phone_string, gncAddressGetPhone (addr));
+    maybe_add_string (ret, addr_fax_string, gncAddressGetFax (addr));
+    maybe_add_string (ret, addr_email_string, gncAddressGetEmail (addr));
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct address_pdata
+{
+    GncAddress *address;
+};
+
+static gboolean
+set_string(xmlNodePtr node, GncAddress* addr,
+           void (*func)(GncAddress *addr, const char *txt))
+{
+    gchar* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    func(addr, txt);
+
+    g_free(txt);
+
+    return TRUE;
+}
+
+static gboolean
+address_name_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    struct address_pdata *pdata = addr_pdata;
+
+    return set_string(node, pdata->address, gncAddressSetName);
+}
+
+static gboolean
+address_addr1_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    struct address_pdata *pdata = addr_pdata;
+
+    return set_string(node, pdata->address, gncAddressSetAddr1);
+}
+
+static gboolean
+address_addr2_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    struct address_pdata *pdata = addr_pdata;
+
+    return set_string(node, pdata->address, gncAddressSetAddr2);
+}
+
+static gboolean
+address_addr3_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    struct address_pdata *pdata = addr_pdata;
+
+    return set_string(node, pdata->address, gncAddressSetAddr3);
+}
+
+static gboolean
+address_addr4_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    struct address_pdata *pdata = addr_pdata;
+
+    return set_string(node, pdata->address, gncAddressSetAddr4);
+}
+
+static gboolean
+address_phone_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    struct address_pdata *pdata = addr_pdata;
+
+    return set_string(node, pdata->address, gncAddressSetPhone);
+}
+
+static gboolean
+address_fax_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    struct address_pdata *pdata = addr_pdata;
+
+    return set_string(node, pdata->address, gncAddressSetFax);
+}
+
+static gboolean
+address_email_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    struct address_pdata *pdata = addr_pdata;
+
+    return set_string(node, pdata->address, gncAddressSetEmail);
+}
+
+static gboolean
+address_slots_handler (xmlNodePtr node, gpointer addr_pdata)
+{
+    return TRUE;
+}
+
+static struct dom_tree_handler address_handlers_v2[] =
+{
+    { addr_name_string, address_name_handler, 0, 0 },
+    { addr_addr1_string, address_addr1_handler, 0, 0 },
+    { addr_addr2_string, address_addr2_handler, 0, 0 },
+    { addr_addr3_string, address_addr3_handler, 0, 0 },
+    { addr_addr4_string, address_addr4_handler, 0, 0 },
+    { addr_phone_string, address_phone_handler, 0, 0 },
+    { addr_fax_string, address_fax_handler, 0, 0 },
+    { addr_email_string, address_email_handler, 0, 0 },
+    { addr_slots_string, address_slots_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+gboolean
+gnc_dom_tree_to_address (xmlNodePtr node, GncAddress *address)
+{
+    struct address_pdata addr_pdata;
+    gboolean successful;
+
+    addr_pdata.address = address;
+
+    successful = dom_tree_generic_parse (node, address_handlers_v2,
+                                         &addr_pdata);
+
+    if (!successful)
+    {
+        PERR ("failed to parse address tree");
+    }
+
+    return successful;
+}
+
+static gboolean
+address_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "addr");
+}
+
+void
+gnc_address_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        "gnc:Address",
+        NULL,			/* parser_create */
+        NULL,			/* add_item */
+        NULL,			/* get_count */
+        NULL,			/* write */
+        NULL,			/* scrub */
+        address_ns,
+    };
+
+    qof_object_register_backend ("gnc:Address",
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-address-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-address-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-address-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,32 @@
+/* gnc-address-xml-v2.h -- Address XML header
+ *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_ADDRESS_XML_V2_H
+#define GNC_ADDRESS_XML_V2_H
+
+#include "gncAddress.h"
+
+gboolean   gnc_dom_tree_to_address (xmlNodePtr node, GncAddress *address);
+xmlNodePtr gnc_address_to_dom_tree (const char *tag, GncAddress *addr);
+void gnc_address_xml_initialize (void);
+
+#endif /* GNC_ADDRESS_XML_V2_H */

Modified: gnucash/trunk/src/backend/xml/gnc-backend-xml.c
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-backend-xml.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/backend/xml/gnc-backend-xml.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -76,6 +76,18 @@
 #include "gnc-backend-xml.h"
 #include "gnc-gconf-utils.h"
 
+#include "gnc-address-xml-v2.h"
+#include "gnc-bill-term-xml-v2.h"
+#include "gnc-customer-xml-v2.h"
+#include "gnc-employee-xml-v2.h"
+#include "gnc-entry-xml-v2.h"
+#include "gnc-invoice-xml-v2.h"
+#include "gnc-job-xml-v2.h"
+#include "gnc-order-xml-v2.h"
+#include "gnc-owner-xml-v2.h"
+#include "gnc-tax-table-xml-v2.h"
+#include "gnc-vendor-xml-v2.h"
+
 #ifndef HAVE_STRPTIME
 # include "strptime.h"
 #endif
@@ -1217,6 +1229,23 @@
 }
 
 static void
+business_core_xml_init(void)
+{
+    /* Initialize our pointers into the backend subsystem */
+    gnc_address_xml_initialize ();
+    gnc_billterm_xml_initialize ();
+    gnc_customer_xml_initialize ();
+    gnc_employee_xml_initialize ();
+    gnc_entry_xml_initialize ();
+    gnc_invoice_xml_initialize ();
+    gnc_job_xml_initialize ();
+    gnc_order_xml_initialize ();
+    gnc_owner_xml_initialize ();
+    gnc_taxtable_xml_initialize ();
+    gnc_vendor_xml_initialize ();
+}
+
+static void
 gnc_provider_free (QofBackendProvider *prov)
 {
     prov->provider_name = NULL;
@@ -1253,6 +1282,9 @@
     prov->provider_free = gnc_provider_free;
     prov->check_data_type = gnc_determine_file_type;
     qof_backend_register_provider (prov);
+
+    /* And the business objects */
+    business_core_xml_init();
 }
 
 /* ========================== END OF FILE ===================== */

Copied: gnucash/trunk/src/backend/xml/gnc-bill-term-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-bill-term-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-bill-term-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,792 @@
+/********************************************************************\
+ * gnc-bill-term-xml-v2.c -- billing term xml i/o implementation    *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncBillTermP.h"
+#include "gncInvoice.h"
+#include "gnc-bill-term-xml-v2.h"
+#include "qof.h"
+
+#include "xml-helpers.h"
+
+#define _GNC_MOD_NAME	GNC_ID_BILLTERM
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *billterm_version_string = "2.0.0";
+
+/* ids */
+#define gnc_billterm_string "gnc:GncBillTerm"
+#define billterm_guid_string "billterm:guid"
+#define billterm_name_string "billterm:name"
+#define billterm_desc_string "billterm:desc"
+#define billterm_refcount_string "billterm:refcount"
+#define billterm_invisible_string "billterm:invisible"
+#define billterm_parent_string "billterm:parent"
+#define billterm_child_string "billterm:child"
+#define billterm_slots_string "billterm:slots"
+
+#define gnc_daystype_string "billterm:days"
+#define days_duedays_string "bt-days:due-days"
+#define days_discdays_string "bt-days:disc-days"
+#define days_discount_string "bt-days:discount"
+
+#define gnc_proximotype_string "billterm:proximo"
+#define prox_dueday_string "bt-prox:due-day"
+#define prox_discday_string "bt-prox:disc-day"
+#define prox_discount_string "bt-prox:discount"
+#define prox_cutoff_string "bt-prox:cutoff-day"
+
+static xmlNodePtr
+billterm_dom_tree_create (GncBillTerm *term)
+{
+    xmlNodePtr ret, data, kvpnode;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_billterm_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST billterm_version_string);
+
+    maybe_add_guid(ret, billterm_guid_string, QOF_INSTANCE(term));
+    xmlAddChild(ret, text_to_dom_tree (billterm_name_string,
+                                       gncBillTermGetName (term)));
+    xmlAddChild(ret, text_to_dom_tree (billterm_desc_string,
+                                       gncBillTermGetDescription (term)));
+
+    xmlAddChild(ret, int_to_dom_tree (billterm_refcount_string,
+                                      gncBillTermGetRefcount (term)));
+    xmlAddChild(ret, int_to_dom_tree (billterm_invisible_string,
+                                      gncBillTermGetInvisible (term)));
+
+    kvpnode = kvp_frame_to_dom_tree (billterm_slots_string,
+                                     qof_instance_get_slots (QOF_INSTANCE(term)));
+    if (kvpnode) xmlAddChild (ret, kvpnode);
+
+
+    /* We should not be our own child */
+    if (gncBillTermGetChild(term) != term)
+        maybe_add_guid(ret, billterm_child_string,
+                       QOF_INSTANCE(gncBillTermGetChild (term)));
+
+    maybe_add_guid(ret, billterm_parent_string,
+                   QOF_INSTANCE(gncBillTermGetParent (term)));
+
+    switch (gncBillTermGetType (term))
+    {
+    case GNC_TERM_TYPE_DAYS:
+        data = xmlNewChild (ret, NULL, BAD_CAST gnc_daystype_string, NULL);
+        maybe_add_int (data, days_duedays_string, gncBillTermGetDueDays (term));
+        maybe_add_int (data, days_discdays_string,
+                       gncBillTermGetDiscountDays (term));
+        maybe_add_numeric (data, days_discount_string,
+                           gncBillTermGetDiscount (term));
+        break;
+
+    case GNC_TERM_TYPE_PROXIMO:
+        data = xmlNewChild (ret, NULL, BAD_CAST gnc_proximotype_string, NULL);
+        maybe_add_int (data, prox_dueday_string, gncBillTermGetDueDays (term));
+        maybe_add_int (data, prox_discday_string,
+                       gncBillTermGetDiscountDays (term));
+        maybe_add_numeric (data, prox_discount_string,
+                           gncBillTermGetDiscount (term));
+        maybe_add_int (data, prox_cutoff_string, gncBillTermGetCutoff (term));
+        break;
+    }
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct billterm_pdata
+{
+    GncBillTerm *term;
+    QofBook *book;
+};
+
+static gboolean
+set_int (xmlNodePtr node, GncBillTerm *term,
+         void (*func)(GncBillTerm *, gint))
+{
+    gint64 val;
+    dom_tree_to_integer (node, &val);
+    func (term, val);
+    return TRUE;
+}
+
+static gboolean
+set_numeric (xmlNodePtr node, GncBillTerm *term,
+             void (*func)(GncBillTerm *, gnc_numeric))
+{
+    gnc_numeric* num = dom_tree_to_gnc_numeric (node);
+    g_return_val_if_fail (num, FALSE);
+
+    func (term, *num);
+    g_free (num);
+    return TRUE;
+}
+
+/***********************************************************************/
+
+static gboolean
+days_duedays_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_int (node, pdata->term, gncBillTermSetDueDays);
+}
+
+static gboolean
+days_discdays_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_int (node, pdata->term, gncBillTermSetDiscountDays);
+}
+
+static gboolean
+days_discount_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_numeric (node, pdata->term, gncBillTermSetDiscount);
+}
+
+static struct dom_tree_handler days_data_handlers_v2[] =
+{
+    { days_duedays_string, days_duedays_handler, 0, 0 },
+    { days_discdays_string, days_discdays_handler, 0, 0 },
+    { days_discount_string, days_discount_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static gboolean
+dom_tree_to_days_data (xmlNodePtr node, struct billterm_pdata *pdata)
+{
+    gboolean successful;
+
+    successful = dom_tree_generic_parse (node, days_data_handlers_v2, pdata);
+
+    if (!successful)
+        PERR ("failed to parse billing term days data");
+
+    return successful;
+}
+
+/***********************************************************************/
+
+static gboolean
+prox_dueday_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_int (node, pdata->term, gncBillTermSetDueDays);
+}
+
+static gboolean
+prox_discday_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_int (node, pdata->term, gncBillTermSetDiscountDays);
+}
+
+static gboolean
+prox_discount_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_numeric (node, pdata->term, gncBillTermSetDiscount);
+}
+
+static gboolean
+prox_cutoff_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_int (node, pdata->term, gncBillTermSetCutoff);
+}
+
+static struct dom_tree_handler prox_data_handlers_v2[] =
+{
+    { prox_dueday_string, prox_dueday_handler, 0, 0 },
+    { prox_discday_string, prox_discday_handler, 0, 0 },
+    { prox_discount_string, prox_discount_handler, 0, 0 },
+    { prox_cutoff_string, prox_cutoff_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static gboolean
+dom_tree_to_prox_data (xmlNodePtr node, struct billterm_pdata *pdata)
+{
+    gboolean successful;
+
+    successful = dom_tree_generic_parse (node, prox_data_handlers_v2, pdata);
+
+    if (!successful)
+        PERR ("failed to parse billing term prox data");
+
+    return successful;
+}
+
+/***********************************************************************/
+
+static gboolean
+set_parent_child (xmlNodePtr node, struct billterm_pdata *pdata,
+                  void (*func)(GncBillTerm *, GncBillTerm *))
+{
+    GncGUID *guid;
+    GncBillTerm *term;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    term = gncBillTermLookup (pdata->book, guid);
+    if (!term)
+    {
+        term = gncBillTermCreate (pdata->book);
+        gncBillTermBeginEdit (term);
+        gncBillTermSetGUID (term, guid);
+        gncBillTermCommitEdit (term);
+    }
+    g_free (guid);
+    g_return_val_if_fail (term, FALSE);
+    func (pdata->term, term);
+
+    return TRUE;
+}
+
+static gboolean
+set_string (xmlNodePtr node, GncBillTerm *term,
+            void (*func)(GncBillTerm *, const char *))
+{
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+    func (term, txt);
+    g_free(txt);
+    return TRUE;
+}
+
+static gboolean
+billterm_guid_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    GncGUID *guid;
+    GncBillTerm *term;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    term = gncBillTermLookup (pdata->book, guid);
+    if (term)
+    {
+        gncBillTermDestroy (pdata->term);
+        pdata->term = term;
+        gncBillTermBeginEdit (term);
+    }
+    else
+    {
+        gncBillTermSetGUID(pdata->term, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+billterm_name_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_string (node, pdata->term, gncBillTermSetName);
+}
+
+static gboolean
+billterm_desc_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_string (node, pdata->term, gncBillTermSetDescription);
+}
+
+static gboolean
+billterm_refcount_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    gint64 val;
+
+    dom_tree_to_integer(node, &val);
+    gncBillTermSetRefcount (pdata->term, val);
+    return TRUE;
+}
+
+static gboolean
+billterm_invisible_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    gint64 val;
+
+    dom_tree_to_integer(node, &val);
+    if (val)
+        gncBillTermMakeInvisible (pdata->term);
+    return TRUE;
+}
+
+static gboolean
+billterm_parent_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_parent_child (node, pdata, gncBillTermSetParent);
+}
+
+static gboolean
+billterm_child_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return set_parent_child (node, pdata, gncBillTermSetChild);
+}
+
+static gboolean
+billterm_days_data_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+
+    g_return_val_if_fail (node, FALSE);
+    g_return_val_if_fail (gncBillTermGetType (pdata->term) == 0, FALSE);
+
+    gncBillTermSetType (pdata->term, GNC_TERM_TYPE_DAYS);
+    return dom_tree_to_days_data (node, pdata);
+}
+
+static gboolean
+billterm_prox_data_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+
+    g_return_val_if_fail (node, FALSE);
+    g_return_val_if_fail (gncBillTermGetType (pdata->term) == 0, FALSE);
+
+    gncBillTermSetType (pdata->term, GNC_TERM_TYPE_PROXIMO);
+    return dom_tree_to_prox_data (node, pdata);
+}
+
+static gboolean
+billterm_slots_handler (xmlNodePtr node, gpointer billterm_pdata)
+{
+    struct billterm_pdata *pdata = billterm_pdata;
+    return dom_tree_to_kvp_frame_given (node,
+                                        qof_instance_get_slots (QOF_INSTANCE(pdata->term)));
+}
+
+static struct dom_tree_handler billterm_handlers_v2[] =
+{
+    { billterm_guid_string, billterm_guid_handler, 1, 0 },
+    { billterm_name_string, billterm_name_handler, 1, 0 },
+    { billterm_desc_string, billterm_desc_handler, 1, 0 },
+    { billterm_refcount_string, billterm_refcount_handler, 1, 0 },
+    { billterm_invisible_string, billterm_invisible_handler, 1, 0 },
+    { billterm_parent_string, billterm_parent_handler, 0, 0 },
+    { billterm_child_string, billterm_child_handler, 0, 0 },
+    { billterm_slots_string, billterm_slots_handler, 0, 0 },
+    { gnc_daystype_string, billterm_days_data_handler, 0, 0 },
+    { gnc_proximotype_string, billterm_prox_data_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncBillTerm*
+dom_tree_to_billterm (xmlNodePtr node, QofBook *book)
+{
+    struct billterm_pdata billterm_pdata;
+    gboolean successful;
+
+    billterm_pdata.term = gncBillTermCreate (book);
+    billterm_pdata.book = book;
+    gncBillTermBeginEdit (billterm_pdata.term);
+
+    successful = dom_tree_generic_parse (node, billterm_handlers_v2,
+                                         &billterm_pdata);
+
+    if (successful)
+    {
+        gncBillTermCommitEdit (billterm_pdata.term);
+    }
+    else
+    {
+        PERR ("failed to parse billing term tree");
+        gncBillTermDestroy (billterm_pdata.term);
+        billterm_pdata.term = NULL;
+    }
+
+    return billterm_pdata.term;
+}
+
+static gboolean
+gnc_billterm_end_handler(gpointer data_for_children,
+                         GSList* data_from_children, GSList* sibling_data,
+                         gpointer parent_data, gpointer global_data,
+                         gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncBillTerm *term;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    term = dom_tree_to_billterm (tree, book);
+    if (term != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, term);
+    }
+
+    xmlFreeNode(tree);
+
+    return term != NULL;
+}
+
+static sixtp *
+billterm_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_billterm_end_handler, NULL, NULL);
+}
+
+static void
+do_count (QofInstance *term_p, gpointer count_p)
+{
+    int *count = count_p;
+    (*count)++;
+}
+
+static int
+billterm_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_billterm (QofInstance *term_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncBillTerm *term = (GncBillTerm *) term_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+
+    node = billterm_dom_tree_create (term);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+billterm_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_billterm, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+static gboolean
+billterm_is_grandchild (GncBillTerm *term)
+{
+    return (gncBillTermGetParent(gncBillTermGetParent(term)) != NULL);
+}
+
+static GncBillTerm *
+billterm_find_senior (GncBillTerm *term)
+{
+    GncBillTerm *temp, *parent, *gp = NULL;
+
+    temp = term;
+    do
+    {
+        /* See if "temp" is a grandchild */
+        parent = gncBillTermGetParent(temp);
+        if (!parent)
+            break;
+        gp = gncBillTermGetParent(parent);
+        if (!gp)
+            break;
+
+        /* Yep, this is a grandchild.  Move up one generation and try again */
+        temp = parent;
+    }
+    while (TRUE);
+
+    /* Ok, at this point temp points to the most senior child and parent
+     * should point to the top billterm (and gp should be NULL).  If
+     * parent is NULL then we are the most senior child (and have no
+     * children), so do nothing.  If temp == term then there is no
+     * grandparent, so do nothing.
+     *
+     * Do something if parent != NULL && temp != term
+     */
+    g_assert (gp == NULL);
+
+    /* return the most senior term */
+    return temp;
+}
+
+/* build a list of bill terms that are grandchildren or bogus (empty entry list). */
+static void
+billterm_scrub_cb (QofInstance *term_p, gpointer list_p)
+{
+    GncBillTerm *term = GNC_BILLTERM(term_p);
+    GList **list = list_p;
+
+    if (billterm_is_grandchild(term))
+    {
+        *list = g_list_prepend(*list, term);
+
+    }
+    else if (!gncBillTermGetType(term))
+    {
+        GncBillTerm *t = gncBillTermGetParent(term);
+        if (t)
+        {
+            /* Fix up the broken "copy" function */
+            PWARN("Fixing broken child billterm: %s",
+                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))));
+
+            gncBillTermBeginEdit(term);
+            gncBillTermSetType(term, gncBillTermGetType(t));
+            gncBillTermSetDueDays (term, gncBillTermGetDueDays(t));
+            gncBillTermSetDiscountDays (term, gncBillTermGetDiscountDays(t));
+            gncBillTermSetDiscount (term, gncBillTermGetDiscount(t));
+            gncBillTermSetCutoff (term, gncBillTermGetCutoff(t));
+            gncBillTermCommitEdit(term);
+
+        }
+        else
+        {
+            /* No parent?  Must be a standalone */
+            *list = g_list_prepend(*list, term);
+        }
+    }
+}
+
+/* for each invoice, check the bill terms.  If the bill terms are
+ * grandchildren, then fix them to point to the most senior child
+ */
+static void
+billterm_scrub_invoices (QofInstance * invoice_p, gpointer ht_p)
+{
+    GHashTable *ht = ht_p;
+    GncInvoice *invoice = GNC_INVOICE(invoice_p);
+    GncBillTerm *term, *new_bt;
+    gint32 count;
+
+    term = gncInvoiceGetTerms(invoice);
+    if (term)
+    {
+        if (billterm_is_grandchild(term))
+        {
+            PWARN("Fixing i-billterm on invoice %s\n",
+                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(invoice))));
+            new_bt = billterm_find_senior(term);
+            gncInvoiceBeginEdit(invoice);
+            gncInvoiceSetTerms(invoice, new_bt);
+            gncInvoiceCommitEdit(invoice);
+            term = new_bt;
+        }
+        if (term)
+        {
+            count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
+            count++;
+            g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
+        }
+    }
+}
+
+static void
+billterm_scrub_cust (QofInstance * cust_p, gpointer ht_p)
+{
+    GHashTable *ht = ht_p;
+    GncCustomer *cust = GNC_CUSTOMER(cust_p);
+    GncBillTerm *term;
+    gint32 count;
+
+    term = gncCustomerGetTerms(cust);
+    if (term)
+    {
+        count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
+        count++;
+        g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
+        if (billterm_is_grandchild(term))
+            PWARN("customer %s has grandchild billterm %s\n",
+                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(cust))),
+                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))));
+    }
+}
+
+static void
+billterm_scrub_vendor (QofInstance * vendor_p, gpointer ht_p)
+{
+    GHashTable *ht = ht_p;
+    GncVendor *vendor = GNC_VENDOR(vendor_p);
+    GncBillTerm *term;
+    gint32 count;
+
+    term = gncVendorGetTerms(vendor);
+    if (term)
+    {
+        count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
+        count++;
+        g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
+        if (billterm_is_grandchild(term))
+            PWARN("vendor %s has grandchild billterm %s\n",
+                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(vendor))),
+                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))));
+    }
+}
+
+static void
+billterm_reset_refcount (gpointer key, gpointer value, gpointer notused)
+{
+    GncBillTerm *term = key;
+    gint32 count = GPOINTER_TO_INT(value);
+
+    if (count != gncBillTermGetRefcount(term) && !gncBillTermGetInvisible(term))
+    {
+        PWARN("Fixing refcount on billterm %s (%" G_GINT64_FORMAT " -> %d)\n",
+              guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))),
+              gncBillTermGetRefcount(term), count);
+        gncBillTermSetRefcount(term, count);
+    }
+}
+
+static void
+billterm_scrub (QofBook *book)
+{
+    GList *list = NULL;
+    GList *node;
+    GncBillTerm *parent, *term;
+    GHashTable *ht = g_hash_table_new(g_direct_hash, g_direct_equal);
+
+    DEBUG("scrubbing billterms...");
+    qof_object_foreach (GNC_ID_INVOICE,  book, billterm_scrub_invoices, ht);
+    qof_object_foreach (GNC_ID_CUSTOMER, book, billterm_scrub_cust, ht);
+    qof_object_foreach (GNC_ID_VENDOR,   book, billterm_scrub_vendor, ht);
+    qof_object_foreach (GNC_ID_BILLTERM, book, billterm_scrub_cb, &list);
+
+    /* destroy the list of "grandchildren" bill terms */
+    for (node = list; node; node = node->next)
+    {
+        term = node->data;
+
+        PWARN ("deleting grandchild billterm: %s\n",
+               guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))));
+
+        /* Make sure the parent has no children */
+        parent = gncBillTermGetParent(term);
+        gncBillTermSetChild(parent, NULL);
+
+        /* Destroy this bill term */
+        gncBillTermBeginEdit(term);
+        gncBillTermDestroy(term);
+    }
+
+    /* reset the refcounts as necessary */
+    g_hash_table_foreach(ht, billterm_reset_refcount, NULL);
+
+    g_list_free(list);
+    g_hash_table_destroy(ht);
+}
+
+static gboolean
+billterm_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return
+        gnc_xml2_write_namespace_decl(out, "billterm")
+        && gnc_xml2_write_namespace_decl(out, "bt-days")
+        && gnc_xml2_write_namespace_decl(out, "bt-prox");
+}
+
+void
+gnc_billterm_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_billterm_string,
+        billterm_sixtp_parser_create,
+        NULL,			/* add_item */
+        billterm_get_count,
+        billterm_write,
+        billterm_scrub,
+        billterm_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}
+
+GncBillTerm *
+gnc_billterm_xml_find_or_create(QofBook *book, GncGUID *guid)
+{
+    GncBillTerm *term;
+
+    g_return_val_if_fail(book, NULL);
+    g_return_val_if_fail(guid, NULL);
+    term = gncBillTermLookup(book, guid);
+    DEBUG("looking for billterm %s, found %p", guid_to_string(guid), term);
+    if (!term)
+    {
+        term = gncBillTermCreate(book);
+        gncBillTermBeginEdit(term);
+        gncBillTermSetGUID(term, guid);
+        gncBillTermCommitEdit(term);
+        DEBUG("Created term: %p", term);
+    }
+    else
+        gncBillTermDecRef(term);
+
+    return term;
+}

Copied: gnucash/trunk/src/backend/xml/gnc-bill-term-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-bill-term-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-bill-term-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,31 @@
+/*
+ * gnc-bill-term-xml-v2.h -- billing term xml i/o parser/unparsers
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_BILLTERM_XML_V2_H
+#define GNC_BILLTERM_XML_V2_H
+
+#include "gncBillTerm.h"
+void gnc_billterm_xml_initialize (void);
+GncBillTerm *gnc_billterm_xml_find_or_create(QofBook *book, GncGUID *guid);
+
+#endif /* GNC_BILLTERM_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-customer-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-customer-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-customer-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,545 @@
+/********************************************************************\
+ * gnc-customer-xml-v2.c -- customer xml i/o implementation         *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncBillTermP.h"
+#include "gncCustomerP.h"
+#include "gncTaxTableP.h"
+#include "gnc-customer-xml-v2.h"
+#include "gnc-address-xml-v2.h"
+#include "gnc-bill-term-xml-v2.h"
+
+#include "xml-helpers.h"
+
+#define _GNC_MOD_NAME	GNC_ID_CUSTOMER
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *customer_version_string = "2.0.0";
+
+/* ids */
+#define gnc_customer_string "gnc:GncCustomer"
+#define cust_name_string "cust:name"
+#define cust_guid_string "cust:guid"
+#define cust_id_string "cust:id"
+#define cust_addr_string "cust:addr"
+#define cust_shipaddr_string "cust:shipaddr"
+#define cust_notes_string "cust:notes"
+#define cust_terms_string "cust:terms"
+#define cust_taxincluded_string "cust:taxincluded"
+#define cust_active_string "cust:active"
+#define cust_discount_string "cust:discount"
+#define cust_credit_string "cust:credit"
+#define cust_currency_string "cust:currency"
+#define cust_taxtable_string "cust:taxtable"
+#define cust_taxtableoverride_string "cust:use-tt"
+#define cust_slots_string "cust:slots"
+
+static xmlNodePtr
+customer_dom_tree_create (GncCustomer *cust)
+{
+    xmlNodePtr ret, kvpnode;
+    gnc_numeric num;
+    GncBillTerm *term;
+    GncTaxTable *taxtable;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_customer_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST customer_version_string);
+
+    xmlAddChild(ret, guid_to_dom_tree(cust_guid_string,
+                                      qof_instance_get_guid(QOF_INSTANCE(cust))));
+
+    xmlAddChild(ret, text_to_dom_tree(cust_name_string,
+                                      gncCustomerGetName (cust)));
+
+    xmlAddChild(ret, text_to_dom_tree(cust_id_string,
+                                      gncCustomerGetID (cust)));
+
+    xmlAddChild(ret, gnc_address_to_dom_tree(cust_addr_string,
+                gncCustomerGetAddr (cust)));
+
+    xmlAddChild(ret, gnc_address_to_dom_tree(cust_shipaddr_string,
+                gncCustomerGetShipAddr (cust)));
+
+    maybe_add_string (ret, cust_notes_string, gncCustomerGetNotes (cust));
+
+    term = gncCustomerGetTerms (cust);
+    if (term)
+        xmlAddChild(ret, guid_to_dom_tree(cust_terms_string,
+                                          qof_instance_get_guid (QOF_INSTANCE(term))));
+
+    xmlAddChild(ret, text_to_dom_tree(cust_taxincluded_string,
+                                      gncTaxIncludedTypeToString (
+                                          gncCustomerGetTaxIncluded (cust))));
+
+    xmlAddChild(ret, int_to_dom_tree(cust_active_string,
+                                     gncCustomerGetActive (cust)));
+
+    num = gncCustomerGetDiscount (cust);
+    xmlAddChild(ret, gnc_numeric_to_dom_tree(cust_discount_string, &num));
+
+    num = gncCustomerGetCredit (cust);
+    xmlAddChild(ret, gnc_numeric_to_dom_tree(cust_credit_string, &num));
+
+    xmlAddChild
+    (ret,
+     commodity_ref_to_dom_tree(cust_currency_string,
+                               gncCustomerGetCurrency (cust)));
+
+    xmlAddChild (ret, int_to_dom_tree (cust_taxtableoverride_string,
+                                       gncCustomerGetTaxTableOverride (cust)));
+    taxtable = gncCustomerGetTaxTable (cust);
+    if (taxtable)
+        xmlAddChild (ret, guid_to_dom_tree (cust_taxtable_string,
+                                            qof_instance_get_guid(QOF_INSTANCE(taxtable))));
+
+    kvpnode = kvp_frame_to_dom_tree (cust_slots_string,
+                                     qof_instance_get_slots (QOF_INSTANCE(cust)));
+    if (kvpnode) xmlAddChild (ret, kvpnode);
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct customer_pdata
+{
+    GncCustomer *customer;
+    QofBook *book;
+};
+
+static gboolean
+set_string(xmlNodePtr node, GncCustomer* cust,
+           void (*func)(GncCustomer *cust, const char *txt))
+{
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    func(cust, txt);
+
+    g_free(txt);
+
+    return TRUE;
+}
+
+static gboolean
+set_boolean(xmlNodePtr node, GncCustomer* cust,
+            void (*func)(GncCustomer* cust, gboolean b))
+{
+    gint64 val;
+    gboolean ret;
+
+    ret = dom_tree_to_integer(node, &val);
+    if (ret)
+        func(cust, (gboolean)val);
+
+    return ret;
+}
+
+static gboolean
+customer_name_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+
+    return set_string(node, pdata->customer, gncCustomerSetName);
+}
+
+static gboolean
+customer_guid_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    GncGUID *guid;
+    GncCustomer *cust;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail(guid, FALSE);
+    cust = gncCustomerLookup (pdata->book, guid);
+    if (cust)
+    {
+        gncCustomerDestroy (pdata->customer);
+        pdata->customer = cust;
+        gncCustomerBeginEdit (cust);
+    }
+    else
+    {
+        gncCustomerSetGUID(pdata->customer, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+customer_id_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+
+    return set_string(node, pdata->customer, gncCustomerSetID);
+}
+
+static gboolean
+customer_notes_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+
+    return set_string(node, pdata->customer, gncCustomerSetNotes);
+}
+
+static gboolean
+customer_terms_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    GncGUID *guid;
+    GncBillTerm *term;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    term = gnc_billterm_xml_find_or_create(pdata->book, guid);
+    g_assert(term);
+    g_free (guid);
+    gncCustomerSetTerms (pdata->customer, term);
+
+    return TRUE;
+}
+
+static gboolean
+customer_addr_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+
+    return gnc_dom_tree_to_address (node, gncCustomerGetAddr(pdata->customer));
+}
+
+static gboolean
+customer_shipaddr_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+
+    return gnc_dom_tree_to_address (node,
+                                    gncCustomerGetShipAddr(pdata->customer));
+}
+
+
+static gboolean
+customer_taxincluded_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    GncTaxIncluded type;
+    char *str;
+    gboolean ret;
+
+    str = dom_tree_to_text (node);
+    g_return_val_if_fail (str, FALSE);
+
+    ret = gncTaxIncludedStringToType (str, &type);
+    g_free (str);
+
+    if (ret)
+        gncCustomerSetTaxIncluded(pdata->customer, type);
+
+    return ret;
+}
+
+static gboolean
+customer_active_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    return set_boolean (node, pdata->customer, gncCustomerSetActive);
+}
+
+static gboolean
+customer_discount_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    gnc_numeric *val;
+
+    val = dom_tree_to_gnc_numeric(node);
+    g_return_val_if_fail(val, FALSE);
+
+    gncCustomerSetDiscount(pdata->customer, *val);
+    g_free (val);
+
+    return TRUE;
+}
+
+static gboolean
+customer_credit_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    gnc_numeric *val;
+
+    val = dom_tree_to_gnc_numeric(node);
+    g_return_val_if_fail(val, FALSE);
+
+    gncCustomerSetCredit(pdata->customer, *val);
+    g_free (val);
+
+    return TRUE;
+}
+
+static gboolean
+customer_currency_handler (xmlNodePtr node, gpointer customer_pdata)
+{
+    struct customer_pdata *pdata = customer_pdata;
+    gnc_commodity *com;
+
+    com = dom_tree_to_commodity_ref(node, pdata->book);
+    g_return_val_if_fail (com, FALSE);
+
+    gncCustomerSetCurrency (pdata->customer, com);
+
+    return TRUE;
+}
+
+static gboolean
+customer_taxtable_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    GncGUID *guid;
+    GncTaxTable *taxtable;
+
+    guid = dom_tree_to_guid (node);
+    g_return_val_if_fail (guid, FALSE);
+    taxtable = gncTaxTableLookup (pdata->book, guid);
+    if (!taxtable)
+    {
+        taxtable = gncTaxTableCreate (pdata->book);
+        gncTaxTableBeginEdit (taxtable);
+        gncTaxTableSetGUID (taxtable, guid);
+        gncTaxTableCommitEdit (taxtable);
+    }
+    else
+        gncTaxTableDecRef (taxtable);
+
+    gncCustomerSetTaxTable (pdata->customer, taxtable);
+    g_free(guid);
+    return TRUE;
+}
+
+static gboolean
+customer_taxtableoverride_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    return set_boolean (node, pdata->customer, gncCustomerSetTaxTableOverride);
+}
+
+static gboolean
+customer_slots_handler (xmlNodePtr node, gpointer cust_pdata)
+{
+    struct customer_pdata *pdata = cust_pdata;
+    return dom_tree_to_kvp_frame_given (node,
+                                        qof_instance_get_slots (QOF_INSTANCE(pdata->customer)));
+}
+
+static struct dom_tree_handler customer_handlers_v2[] =
+{
+    { cust_name_string, customer_name_handler, 1, 0 },
+    { cust_guid_string, customer_guid_handler, 1, 0 },
+    { cust_id_string, customer_id_handler, 1, 0 },
+    { cust_addr_string, customer_addr_handler, 1, 0 },
+    { cust_shipaddr_string, customer_shipaddr_handler, 1, 0 },
+    { cust_notes_string, customer_notes_handler, 0, 0 },
+    { cust_terms_string, customer_terms_handler, 0, 0 },
+    { cust_taxincluded_string, customer_taxincluded_handler, 1, 0 },
+    { cust_active_string, customer_active_handler, 1, 0 },
+    { cust_discount_string, customer_discount_handler, 1, 0 },
+    { cust_credit_string, customer_credit_handler, 1, 0 },
+    { cust_currency_string, customer_currency_handler, 0, 0 }, /* XXX */
+    { "cust:commodity", customer_currency_handler, 0, 0 }, /* XXX */
+    { cust_taxtable_string, customer_taxtable_handler, 0, 0 },
+    { cust_taxtableoverride_string, customer_taxtableoverride_handler, 0, 0 },
+    { cust_slots_string, customer_slots_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncCustomer*
+dom_tree_to_customer (xmlNodePtr node, QofBook *book)
+{
+    struct customer_pdata cust_pdata;
+    gboolean successful;
+
+    cust_pdata.customer = gncCustomerCreate(book);
+    cust_pdata.book = book;
+    gncCustomerBeginEdit (cust_pdata.customer);
+
+    successful = dom_tree_generic_parse (node, customer_handlers_v2,
+                                         &cust_pdata);
+
+    if (successful)
+        gncCustomerCommitEdit (cust_pdata.customer);
+    else
+    {
+        PERR ("failed to parse customer tree");
+        gncCustomerDestroy (cust_pdata.customer);
+        cust_pdata.customer = NULL;
+    }
+
+    return cust_pdata.customer;
+}
+
+static gboolean
+gnc_customer_end_handler(gpointer data_for_children,
+                         GSList* data_from_children, GSList* sibling_data,
+                         gpointer parent_data, gpointer global_data,
+                         gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncCustomer *cust;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    cust = dom_tree_to_customer(tree, book);
+    if (cust != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, cust);
+    }
+
+    xmlFreeNode(tree);
+
+    return cust != NULL;
+}
+
+static sixtp *
+customer_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_customer_end_handler, NULL, NULL);
+}
+
+static gboolean
+customer_should_be_saved (GncCustomer *customer)
+{
+    const char *id;
+
+    /* make sure this is a valid customer before we save it -- should have an ID */
+    id = gncCustomerGetID (customer);
+    if (id == NULL || *id == '\0')
+        return FALSE;
+
+    return TRUE;
+}
+
+static void
+do_count (QofInstance * cust_p, gpointer count_p)
+{
+    int *count = count_p;
+    if (customer_should_be_saved ((GncCustomer *)cust_p))
+        (*count)++;
+}
+
+static int
+customer_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_customer (QofInstance * cust_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncCustomer *cust = (GncCustomer *) cust_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+    if (!customer_should_be_saved (cust))
+        return;
+
+    node = customer_dom_tree_create (cust);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+customer_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_customer, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+static gboolean
+customer_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "cust");
+}
+
+void
+gnc_customer_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_customer_string,
+        customer_sixtp_parser_create,
+        NULL,			/* add_item */
+        customer_get_count,
+        customer_write,
+        NULL,			/* scrub */
+        customer_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-customer-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-customer-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-customer-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,29 @@
+/*
+ * gnc-customer-xml-v2.h -- customer xml i/o parser/unparser
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_CUSTOMER_XML_V2_H
+#define GNC_CUSTOMER_XML_V2_H
+
+void gnc_customer_xml_initialize (void);
+
+#endif /* GNC_CUSTOMER_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-employee-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-employee-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-employee-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,468 @@
+/********************************************************************\
+ * gnc-employee-xml-v2.c -- employee xml i/o implementation         *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncEmployeeP.h"
+#include "gnc-employee-xml-v2.h"
+#include "gnc-address-xml-v2.h"
+
+#define _GNC_MOD_NAME	GNC_ID_EMPLOYEE
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *employee_version_string = "2.0.0";
+
+/* ids */
+#define gnc_employee_string "gnc:GncEmployee"
+#define employee_username_string "employee:username"
+#define employee_guid_string "employee:guid"
+#define employee_id_string "employee:id"
+#define employee_addr_string "employee:addr"
+#define employee_language_string "employee:language"
+#define employee_acl_string "employee:acl"
+#define employee_active_string "employee:active"
+#define employee_workday_string "employee:workday"
+#define employee_rate_string "employee:rate"
+#define employee_currency_string "employee:currency"
+#define employee_ccard_string "employee:ccard"
+#define employee_slots_string "employee:slots"
+
+static void
+maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
+{
+    if (str && strlen(str) > 0)
+        xmlAddChild (ptr, text_to_dom_tree (tag, str));
+}
+
+static xmlNodePtr
+employee_dom_tree_create (GncEmployee *employee)
+{
+    xmlNodePtr ret, kvpnode;
+    gnc_numeric num;
+    Account* ccard_acc;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_employee_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST employee_version_string);
+
+    xmlAddChild(ret, guid_to_dom_tree(employee_guid_string,
+                                      qof_instance_get_guid(QOF_INSTANCE (employee))));
+
+    xmlAddChild(ret, text_to_dom_tree(employee_username_string,
+                                      gncEmployeeGetUsername (employee)));
+
+    xmlAddChild(ret, text_to_dom_tree(employee_id_string,
+                                      gncEmployeeGetID (employee)));
+
+    xmlAddChild(ret, gnc_address_to_dom_tree(employee_addr_string,
+                gncEmployeeGetAddr (employee)));
+
+    maybe_add_string (ret, employee_language_string,
+                      gncEmployeeGetLanguage (employee));
+    maybe_add_string (ret, employee_acl_string, gncEmployeeGetAcl (employee));
+
+    xmlAddChild(ret, int_to_dom_tree(employee_active_string,
+                                     gncEmployeeGetActive (employee)));
+
+    num = gncEmployeeGetWorkday (employee);
+    xmlAddChild(ret, gnc_numeric_to_dom_tree (employee_workday_string, &num));
+
+    num = gncEmployeeGetRate (employee);
+    xmlAddChild(ret, gnc_numeric_to_dom_tree (employee_rate_string, &num));
+
+    xmlAddChild
+    (ret,
+     commodity_ref_to_dom_tree(employee_currency_string,
+                               gncEmployeeGetCurrency (employee)));
+
+    ccard_acc = gncEmployeeGetCCard (employee);
+    if (ccard_acc)
+        xmlAddChild(ret, guid_to_dom_tree(employee_ccard_string,
+                                          qof_instance_get_guid(QOF_INSTANCE(ccard_acc))));
+
+    kvpnode = kvp_frame_to_dom_tree (employee_slots_string,
+                                     qof_instance_get_slots (QOF_INSTANCE(employee)));
+    if (kvpnode) xmlAddChild (ret, kvpnode);
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct employee_pdata
+{
+    GncEmployee *employee;
+    QofBook *book;
+};
+
+static gboolean
+set_string(xmlNodePtr node, GncEmployee* employee,
+           void (*func)(GncEmployee *employee, const char *txt))
+{
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    func(employee, txt);
+
+    g_free(txt);
+
+    return TRUE;
+}
+
+static gboolean
+employee_username_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+
+    return set_string(node, pdata->employee, gncEmployeeSetUsername);
+}
+
+static gboolean
+employee_guid_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+    GncGUID *guid;
+    GncEmployee *employee;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail(guid, FALSE);
+
+    /* See if we've already created this one */
+    employee = gncEmployeeLookup (pdata->book, guid);
+    if (employee)
+    {
+        gncEmployeeDestroy (pdata->employee);
+        pdata->employee = employee;
+        gncEmployeeBeginEdit (employee);
+    }
+    else
+    {
+        gncEmployeeSetGUID(pdata->employee, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+employee_id_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+
+    return set_string(node, pdata->employee, gncEmployeeSetID);
+}
+
+static gboolean
+employee_language_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+
+    return set_string(node, pdata->employee, gncEmployeeSetLanguage);
+}
+
+static gboolean
+employee_acl_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+
+    return set_string(node, pdata->employee, gncEmployeeSetAcl);
+}
+
+static gboolean
+employee_addr_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+
+    return gnc_dom_tree_to_address (node, gncEmployeeGetAddr(pdata->employee));
+}
+
+static gboolean
+employee_active_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+    gint64 val;
+    gboolean ret;
+
+    ret = dom_tree_to_integer(node, &val);
+    if (ret)
+        gncEmployeeSetActive(pdata->employee, (gboolean)val);
+
+    return ret;
+}
+
+static gboolean
+employee_workday_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+    gnc_numeric *val;
+
+    val = dom_tree_to_gnc_numeric(node);
+    g_return_val_if_fail(val, FALSE);
+    gncEmployeeSetWorkday(pdata->employee, *val);
+    g_free(val);
+
+    return TRUE;
+}
+
+static gboolean
+employee_rate_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+    gnc_numeric *val;
+
+    val = dom_tree_to_gnc_numeric(node);
+    g_return_val_if_fail(val, FALSE);
+    gncEmployeeSetRate(pdata->employee, *val);
+    g_free(val);
+
+    return TRUE;
+}
+
+static gboolean
+employee_currency_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+    gnc_commodity *com;
+
+    com = dom_tree_to_commodity_ref(node, pdata->book);
+    g_return_val_if_fail (com, FALSE);
+
+    gncEmployeeSetCurrency (pdata->employee, com);
+
+    return TRUE;
+}
+
+static gboolean
+employee_ccard_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+    GncGUID *guid;
+    Account *ccard_acc;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail(guid, FALSE);
+
+    ccard_acc = xaccAccountLookup (guid, pdata->book);
+    g_free(guid);
+
+    g_return_val_if_fail (ccard_acc, FALSE);
+    gncEmployeeSetCCard (pdata->employee, ccard_acc);
+
+    return TRUE;
+}
+
+static gboolean
+employee_slots_handler (xmlNodePtr node, gpointer employee_pdata)
+{
+    struct employee_pdata *pdata = employee_pdata;
+    return dom_tree_to_kvp_frame_given (
+               node, qof_instance_get_slots (QOF_INSTANCE(pdata->employee)));
+}
+
+static struct dom_tree_handler employee_handlers_v2[] =
+{
+    { employee_username_string, employee_username_handler, 1, 0 },
+    { employee_guid_string, employee_guid_handler, 1, 0 },
+    { employee_id_string, employee_id_handler, 1, 0 },
+    { employee_addr_string, employee_addr_handler, 1, 0 },
+    { employee_language_string, employee_language_handler, 0, 0 },
+    { employee_acl_string, employee_acl_handler, 0, 0 },
+    { employee_active_string, employee_active_handler, 1, 0 },
+    { employee_workday_string, employee_workday_handler, 1, 0 },
+    { employee_rate_string, employee_rate_handler, 1, 0 },
+    { employee_currency_string, employee_currency_handler, 0, 0 }, /* XXX */
+    { "employee:commodity", employee_currency_handler, 0, 0 }, /* XXX */
+    { employee_ccard_string, employee_ccard_handler, 0, 0 },
+    { employee_slots_string, employee_slots_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncEmployee*
+dom_tree_to_employee (xmlNodePtr node, QofBook *book)
+{
+    struct employee_pdata employee_pdata;
+    gboolean successful;
+
+    employee_pdata.employee = gncEmployeeCreate(book);
+    employee_pdata.book = book;
+    gncEmployeeBeginEdit (employee_pdata.employee);
+
+    successful = dom_tree_generic_parse (node, employee_handlers_v2,
+                                         &employee_pdata);
+    if (successful)
+        gncEmployeeCommitEdit (employee_pdata.employee);
+    else
+    {
+        PERR ("failed to parse employee tree");
+        gncEmployeeDestroy (employee_pdata.employee);
+        employee_pdata.employee = NULL;
+    }
+
+    return employee_pdata.employee;
+}
+
+static gboolean
+gnc_employee_end_handler(gpointer data_for_children,
+                         GSList* data_from_children, GSList* sibling_data,
+                         gpointer parent_data, gpointer global_data,
+                         gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncEmployee *employee;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    employee = dom_tree_to_employee(tree, book);
+    if (employee != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, employee);
+    }
+
+    xmlFreeNode(tree);
+
+    return employee != NULL;
+}
+
+static sixtp *
+employee_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_employee_end_handler, NULL, NULL);
+}
+
+static gboolean
+employee_should_be_saved (GncEmployee *employee)
+{
+    const char *id;
+
+    /* make sure this is a valid employee before we save it -- should have an ID */
+    id = gncEmployeeGetID (employee);
+    if (id == NULL || *id == '\0')
+        return FALSE;
+
+    return TRUE;
+}
+
+static void
+do_count (QofInstance * employee_p, gpointer count_p)
+{
+    int *count = count_p;
+    if (employee_should_be_saved ((GncEmployee *) employee_p))
+        (*count)++;
+}
+
+static int
+employee_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_employee (QofInstance * employee_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncEmployee *employee = (GncEmployee *) employee_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+    if (!employee_should_be_saved (employee))
+        return;
+
+    node = employee_dom_tree_create (employee);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+employee_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_employee, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+static gboolean
+employee_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "employee");
+}
+
+void
+gnc_employee_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_employee_string,
+        employee_sixtp_parser_create,
+        NULL,			/* add_item */
+        employee_get_count,
+        employee_write,
+        NULL,			/* scrub */
+        employee_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-employee-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-employee-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-employee-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,29 @@
+/*
+ * gnc-employee-xml-v2.h -- employee xml i/o parser/unparser
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_EMPLOYEE_XML_V2_H
+#define GNC_EMPLOYEE_XML_V2_H
+
+void gnc_employee_xml_initialize (void);
+
+#endif /* GNC_EMPLOYEE_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-entry-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-entry-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-entry-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,864 @@
+/********************************************************************\
+ * gnc-entry-xml-v2.c -- entry xml i/o implementation         *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncEntryP.h"
+#include "gncOrderP.h"
+#include "gncInvoiceP.h"
+#include "gncTaxTableP.h"
+#include "gnc-entry-xml-v2.h"
+#include "gnc-owner-xml-v2.h"
+
+#define _GNC_MOD_NAME	GNC_ID_ENTRY
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *entry_version_string = "2.0.0";
+
+/* ids */
+#define gnc_entry_string "gnc:GncEntry"
+#define entry_guid_string "entry:guid"
+#define entry_date_string "entry:date"
+#define entry_dateentered_string "entry:entered"
+#define entry_description_string "entry:description"
+#define entry_action_string "entry:action"
+#define entry_notes_string "entry:notes"
+#define entry_qty_string "entry:qty"
+
+/* cust inv */
+#define entry_invacct_string "entry:i-acct"
+#define entry_iprice_string "entry:i-price"
+#define entry_idiscount_string "entry:i-discount"
+#define entry_idisctype_string "entry:i-disc-type"
+#define entry_idischow_string "entry:i-disc-how"
+#define entry_itaxable_string "entry:i-taxable"
+#define entry_itaxincluded_string "entry:i-taxincluded"
+#define entry_itaxtable_string "entry:i-taxtable"
+
+/* vend bill */
+#define entry_billacct_string "entry:b-acct"
+#define entry_bprice_string "entry:b-price"
+#define entry_btaxable_string "entry:b-taxable"
+#define entry_btaxincluded_string "entry:b-taxincluded"
+#define entry_btaxtable_string "entry:b-taxtable"
+#define entry_billable_string "entry:billable"
+#define entry_billto_string "entry:billto"
+
+/* emp bill */
+#define entry_billpayment_string "entry:b-pay"
+
+/* other stuff */
+#define entry_order_string "entry:order"
+#define entry_invoice_string "entry:invoice"
+#define entry_bill_string "entry:bill"
+#define entry_slots_string "entry:slots"
+
+static void
+maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
+{
+    if (str && strlen(str) > 0)
+        xmlAddChild (ptr, text_to_dom_tree (tag, str));
+}
+
+static void
+maybe_add_numeric (xmlNodePtr ptr, const char *tag, gnc_numeric num)
+{
+    if (!gnc_numeric_zero_p (num))
+        xmlAddChild (ptr, gnc_numeric_to_dom_tree (tag, &num));
+}
+
+static xmlNodePtr
+entry_dom_tree_create (GncEntry *entry)
+{
+    xmlNodePtr ret;
+    Timespec ts;
+    Account *acc;
+    GncTaxTable *taxtable;
+    GncOrder *order;
+    GncInvoice *invoice;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_entry_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST entry_version_string);
+
+    xmlAddChild(ret, guid_to_dom_tree(entry_guid_string,
+                                      qof_instance_get_guid(QOF_INSTANCE(entry))));
+
+    ts = gncEntryGetDate (entry);
+    xmlAddChild(ret, timespec_to_dom_tree (entry_date_string, &ts));
+
+    ts = gncEntryGetDateEntered (entry);
+    xmlAddChild(ret, timespec_to_dom_tree (entry_dateentered_string, &ts));
+
+    maybe_add_string (ret, entry_description_string,
+                      gncEntryGetDescription (entry));
+    maybe_add_string (ret, entry_action_string, gncEntryGetAction (entry));
+    maybe_add_string (ret, entry_notes_string, gncEntryGetNotes (entry));
+
+    maybe_add_numeric (ret, entry_qty_string, gncEntryGetQuantity (entry));
+
+    /* cust invoice */
+
+    acc = gncEntryGetInvAccount (entry);
+    if (acc)
+        xmlAddChild (ret, guid_to_dom_tree (entry_invacct_string,
+                                            qof_instance_get_guid(QOF_INSTANCE(acc))));
+
+    maybe_add_numeric (ret, entry_iprice_string, gncEntryGetInvPrice (entry));
+
+    maybe_add_numeric (ret, entry_idiscount_string, gncEntryGetInvDiscount (entry));
+
+    invoice = gncEntryGetInvoice (entry);
+    if (invoice)
+    {
+        xmlAddChild (ret, guid_to_dom_tree (entry_invoice_string,
+                                            qof_instance_get_guid(QOF_INSTANCE(invoice))));
+
+        xmlAddChild(ret, text_to_dom_tree(entry_idisctype_string,
+                                          gncAmountTypeToString (
+                                              gncEntryGetInvDiscountType (entry))));
+        xmlAddChild(ret, text_to_dom_tree(entry_idischow_string,
+                                          gncEntryDiscountHowToString (
+                                              gncEntryGetInvDiscountHow (entry))));
+
+        xmlAddChild(ret, int_to_dom_tree(entry_itaxable_string,
+                                         gncEntryGetInvTaxable (entry)));
+        xmlAddChild(ret, int_to_dom_tree(entry_itaxincluded_string,
+                                         gncEntryGetInvTaxIncluded (entry)));
+    }
+
+    taxtable = gncEntryGetInvTaxTable (entry);
+    if (taxtable)
+        xmlAddChild (ret, guid_to_dom_tree (entry_itaxtable_string,
+                                            qof_instance_get_guid (QOF_INSTANCE(taxtable))));
+
+    /* vendor bills */
+
+    acc = gncEntryGetBillAccount (entry);
+    if (acc)
+        xmlAddChild (ret, guid_to_dom_tree (entry_billacct_string,
+                                            qof_instance_get_guid (QOF_INSTANCE(acc))));
+
+    maybe_add_numeric (ret, entry_bprice_string, gncEntryGetBillPrice (entry));
+
+    invoice = gncEntryGetBill (entry);
+    if (invoice)
+    {
+        GncOwner *owner;
+        xmlAddChild (ret, guid_to_dom_tree (entry_bill_string,
+                                            qof_instance_get_guid(QOF_INSTANCE(invoice))));
+        xmlAddChild(ret, int_to_dom_tree(entry_billable_string,
+                                         gncEntryGetBillable (entry)));
+        owner = gncEntryGetBillTo (entry);
+        if (owner && owner->owner.undefined != NULL)
+            xmlAddChild (ret, gnc_owner_to_dom_tree (entry_billto_string, owner));
+
+        xmlAddChild(ret, int_to_dom_tree(entry_btaxable_string,
+                                         gncEntryGetBillTaxable (entry)));
+        xmlAddChild(ret, int_to_dom_tree(entry_btaxincluded_string,
+                                         gncEntryGetBillTaxIncluded (entry)));
+        maybe_add_string (ret, entry_billpayment_string,
+                          gncEntryPaymentTypeToString (gncEntryGetBillPayment (entry)));
+    }
+
+    taxtable = gncEntryGetBillTaxTable (entry);
+    if (taxtable)
+        xmlAddChild (ret, guid_to_dom_tree (entry_btaxtable_string,
+                                            qof_instance_get_guid (QOF_INSTANCE(taxtable))));
+
+    /* Other stuff */
+
+    order = gncEntryGetOrder (entry);
+    if (order)
+        xmlAddChild (ret, guid_to_dom_tree (entry_order_string,
+                                            qof_instance_get_guid(QOF_INSTANCE (order))));
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct entry_pdata
+{
+    GncEntry *entry;
+    QofBook *book;
+    Account *acc;
+};
+
+static inline gboolean
+set_string(xmlNodePtr node, GncEntry* entry,
+           void (*func)(GncEntry *entry, const char *txt))
+{
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    func(entry, txt);
+    g_free(txt);
+    return TRUE;
+}
+
+static inline gboolean
+set_timespec(xmlNodePtr node, GncEntry* entry,
+             void (*func)(GncEntry *entry, Timespec ts))
+{
+    Timespec ts = dom_tree_to_timespec (node);
+    if (!dom_tree_valid_timespec(&ts, node->name)) return FALSE;
+
+    func(entry, ts);
+    return TRUE;
+}
+
+static inline gboolean
+set_numeric(xmlNodePtr node, GncEntry* entry,
+            void (*func)(GncEntry *entry, gnc_numeric num))
+{
+    gnc_numeric* num = dom_tree_to_gnc_numeric(node);
+    g_return_val_if_fail(num, FALSE);
+
+    func(entry, *num);
+    g_free(num);
+    return TRUE;
+}
+
+static inline gboolean
+set_boolean(xmlNodePtr node, GncEntry* entry,
+            void (*func)(GncEntry *entry, gboolean val))
+{
+    gint64 val;
+
+    if (!dom_tree_to_integer(node, &val))
+        return FALSE;
+    func (entry, (gboolean)val);
+    return TRUE;
+}
+
+static inline gboolean
+set_account(xmlNodePtr node, struct entry_pdata *pdata,
+            void (*func)(GncEntry *entry, Account *acc))
+{
+    GncGUID *guid;
+    Account * acc;
+
+    guid = dom_tree_to_guid (node);
+    g_return_val_if_fail (guid, FALSE);
+    acc = xaccAccountLookup (guid, pdata->book);
+    g_free (guid);
+    g_return_val_if_fail (acc, FALSE);
+
+    if (func)
+        func (pdata->entry, acc);
+    else
+        pdata->acc = acc;
+    return TRUE;
+}
+
+static inline gboolean
+set_taxtable (xmlNodePtr node, struct entry_pdata *pdata,
+              void (*func)(GncEntry *entry, GncTaxTable *taxtable))
+{
+    GncGUID *guid;
+    GncTaxTable *taxtable;
+
+    guid = dom_tree_to_guid (node);
+    g_return_val_if_fail (guid, FALSE);
+    taxtable = gncTaxTableLookup (pdata->book, guid);
+    if (!taxtable)
+    {
+        taxtable = gncTaxTableCreate (pdata->book);
+        gncTaxTableBeginEdit (taxtable);
+        gncTaxTableSetGUID (taxtable, guid);
+        gncTaxTableCommitEdit (taxtable);
+    }
+    else
+        gncTaxTableDecRef (taxtable);
+
+    func (pdata->entry, taxtable);
+    g_free(guid);
+    return TRUE;
+}
+
+static gboolean
+entry_guid_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    GncGUID *guid;
+    GncEntry *entry;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    entry = gncEntryLookup (pdata->book, guid);
+    if (entry)
+    {
+        gncEntryDestroy (pdata->entry);
+        pdata->entry = entry;
+        gncEntryBeginEdit (entry);
+    }
+    else
+    {
+        gncEntrySetGUID(pdata->entry, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+entry_date_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_timespec(node, pdata->entry, gncEntrySetDate);
+}
+
+static gboolean
+entry_dateentered_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_timespec(node, pdata->entry, gncEntrySetDateEntered);
+}
+
+static gboolean
+entry_description_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_string(node, pdata->entry, gncEntrySetDescription);
+}
+
+static gboolean
+entry_action_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_string(node, pdata->entry, gncEntrySetAction);
+}
+
+static gboolean
+entry_notes_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_string(node, pdata->entry, gncEntrySetNotes);
+}
+
+static gboolean
+entry_qty_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_numeric(node, pdata->entry, gncEntrySetQuantity);
+}
+
+/* Cust invoice */
+
+static gboolean
+entry_invacct_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_account (node, pdata, gncEntrySetInvAccount);
+}
+
+static gboolean
+entry_iprice_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_numeric(node, pdata->entry, gncEntrySetInvPrice);
+}
+
+static gboolean
+entry_idiscount_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_numeric(node, pdata->entry, gncEntrySetInvDiscount);
+}
+
+static gboolean
+entry_idisctype_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    GncAmountType type;
+    char *str;
+    gboolean ret;
+
+    str = dom_tree_to_text (node);
+    g_return_val_if_fail (str, FALSE);
+
+    ret = gncAmountStringToType (str, &type);
+    g_free (str);
+
+    if (ret)
+        gncEntrySetInvDiscountType(pdata->entry, type);
+
+    return ret;
+}
+
+static gboolean
+entry_idischow_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    GncDiscountHow how;
+    char *str;
+    gboolean ret;
+
+    str = dom_tree_to_text (node);
+    g_return_val_if_fail (str, FALSE);
+
+    ret = gncEntryDiscountStringToHow (str, &how);
+    g_free (str);
+
+    if (ret)
+        gncEntrySetInvDiscountHow(pdata->entry, how);
+
+    return ret;
+}
+
+static gboolean
+entry_itaxable_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_boolean (node, pdata->entry, gncEntrySetInvTaxable);
+}
+
+static gboolean
+entry_itaxincluded_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_boolean (node, pdata->entry, gncEntrySetInvTaxIncluded);
+}
+
+static gboolean
+entry_itaxtable_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_taxtable (node, pdata, gncEntrySetInvTaxTable);
+}
+
+/* vendor bills */
+
+static gboolean
+entry_billacct_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_account (node, pdata, gncEntrySetBillAccount);
+}
+
+static gboolean
+entry_bprice_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+
+    return set_numeric(node, pdata->entry, gncEntrySetBillPrice);
+}
+
+static gboolean
+entry_btaxable_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_boolean (node, pdata->entry, gncEntrySetBillTaxable);
+}
+
+static gboolean
+entry_btaxincluded_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_boolean (node, pdata->entry, gncEntrySetBillTaxIncluded);
+}
+
+static gboolean
+entry_btaxtable_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_taxtable (node, pdata, gncEntrySetBillTaxTable);
+}
+
+static gboolean
+entry_billable_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    return set_boolean (node, pdata->entry, gncEntrySetBillable);
+}
+
+static gboolean
+entry_billto_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    GncOwner billto;
+    gboolean ret;
+
+    ret = gnc_dom_tree_to_owner (node, &billto, pdata->book);
+    if (ret)
+        gncEntrySetBillTo (pdata->entry, &billto);
+
+    return ret;
+}
+
+/* employee bills */
+static gboolean
+entry_billpayment_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    GncEntryPaymentType type;
+    char *str;
+    gboolean ret;
+
+    str = dom_tree_to_text (node);
+    g_return_val_if_fail (str, FALSE);
+
+    ret = gncEntryPaymentStringToType (str, &type);
+    g_free (str);
+
+    if (ret)
+        gncEntrySetBillPayment(pdata->entry, type);
+
+    return ret;
+}
+
+/* The rest of the stuff */
+
+static gboolean
+entry_order_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    GncGUID *guid;
+    GncOrder *order;
+
+    guid = dom_tree_to_guid (node);
+    g_return_val_if_fail (guid, FALSE);
+    order = gncOrderLookup (pdata->book, guid);
+    if (!order)
+    {
+        order = gncOrderCreate (pdata->book);
+        gncOrderBeginEdit (order);
+        gncOrderSetGUID (order, guid);
+        gncOrderCommitEdit (order);
+    }
+    gncOrderBeginEdit (order);
+    gncOrderAddEntry (order, pdata->entry);
+    gncOrderCommitEdit (order);
+
+    g_free(guid);
+    return TRUE;
+}
+
+static gboolean
+entry_invoice_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    GncGUID *guid;
+    GncInvoice *invoice;
+
+    guid = dom_tree_to_guid (node);
+    g_return_val_if_fail (guid, FALSE);
+    invoice = gncInvoiceLookup (pdata->book, guid);
+    if (!invoice)
+    {
+        invoice = gncInvoiceCreate (pdata->book);
+        gncInvoiceBeginEdit (invoice);
+        gncInvoiceSetGUID (invoice, guid);
+        gncInvoiceCommitEdit (invoice);
+    }
+    gncInvoiceBeginEdit (invoice);
+    gncInvoiceAddEntry (invoice, pdata->entry);
+    gncInvoiceCommitEdit (invoice);
+
+    g_free(guid);
+    return TRUE;
+}
+
+static gboolean
+entry_bill_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    GncGUID *guid;
+    GncInvoice *invoice;
+
+    guid = dom_tree_to_guid (node);
+    g_return_val_if_fail (guid, FALSE);
+    invoice = gncInvoiceLookup (pdata->book, guid);
+    if (!invoice)
+    {
+        invoice = gncInvoiceCreate (pdata->book);
+        gncInvoiceBeginEdit (invoice);
+        gncInvoiceSetGUID (invoice, guid);
+        gncInvoiceCommitEdit (invoice);
+    }
+    gncInvoiceBeginEdit (invoice);
+    gncBillAddEntry (invoice, pdata->entry);
+    gncInvoiceCommitEdit (invoice);
+
+    g_free(guid);
+    return TRUE;
+}
+
+/* Support for older XML versions */
+
+static gboolean
+entry_acct_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    /* XXX: try to figure out if this is an 'invoice' or a 'bill' --
+     * we have to wait until the end!
+     */
+
+    return set_account (node, pdata, NULL);
+}
+
+static gboolean
+entry_price_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    struct entry_pdata *pdata = entry_pdata;
+    gboolean res;
+
+    /* just set both.. Don't worry about extra data if it's wrong */
+    res = set_numeric(node, pdata->entry, gncEntrySetInvPrice);
+    if (res)
+        gncEntrySetBillPrice (pdata->entry, gncEntryGetInvPrice (pdata->entry));
+    return res;
+}
+
+static gboolean
+entry_slots_handler (xmlNodePtr node, gpointer entry_pdata)
+{
+    return TRUE;
+}
+
+static struct dom_tree_handler entry_handlers_v2[] =
+{
+    { entry_guid_string, entry_guid_handler, 1, 0 },
+    { entry_date_string, entry_date_handler, 1, 0 },
+    { entry_dateentered_string, entry_dateentered_handler, 1, 0 },
+    { entry_description_string, entry_description_handler, 0, 0 },
+    { entry_action_string, entry_action_handler, 0, 0 },
+    { entry_notes_string, entry_notes_handler, 0, 0 },
+    { entry_qty_string, entry_qty_handler, 0, 0 },
+
+    /* cust invoice */
+    { entry_invacct_string, entry_invacct_handler, 0, 0 },
+    { entry_iprice_string, entry_iprice_handler, 0, 0 },
+    { entry_idiscount_string, entry_idiscount_handler, 0, 0 },
+    { entry_idisctype_string, entry_idisctype_handler, 0, 0 },
+    { entry_idischow_string, entry_idischow_handler, 0, 0 },
+    { entry_itaxable_string, entry_itaxable_handler, 0, 0 },
+    { entry_itaxincluded_string, entry_itaxincluded_handler, 0, 0 },
+    { entry_itaxtable_string, entry_itaxtable_handler, 0, 0 },
+
+    /* vendor invoice */
+    { entry_billacct_string, entry_billacct_handler, 0, 0 },
+    { entry_bprice_string, entry_bprice_handler, 0, 0 },
+    { entry_btaxable_string, entry_btaxable_handler, 0, 0 },
+    { entry_btaxincluded_string, entry_btaxincluded_handler, 0, 0 },
+    { entry_btaxtable_string, entry_btaxtable_handler, 0, 0 },
+    { entry_billable_string, entry_billable_handler, 0, 0 },
+    { entry_billto_string, entry_billto_handler, 0, 0 },
+
+    /* employee stuff */
+    { entry_billpayment_string, entry_billpayment_handler, 0, 0 },
+
+    /* Other stuff */
+    { entry_order_string, entry_order_handler, 0, 0 },
+    { entry_invoice_string, entry_invoice_handler, 0, 0 },
+    { entry_bill_string, entry_bill_handler, 0, 0 },
+    { entry_slots_string, entry_slots_handler, 0, 0 },
+
+    /* Old XML support */
+    { "entry:acct", entry_acct_handler, 0, 0 },
+    { "entry:price", entry_price_handler, 0, 0 },
+    { "entry:discount", entry_idiscount_handler, 0, 0 },
+    { "entry:disc-type", entry_idisctype_handler, 0, 0 },
+    { "entry:disc-how", entry_idischow_handler, 0, 0 },
+    { "entry:taxable", entry_itaxable_handler, 0, 0 },
+    { "entry:taxincluded", entry_itaxincluded_handler, 0, 0 },
+    { "entry:taxtable", entry_itaxtable_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncEntry*
+dom_tree_to_entry (xmlNodePtr node, QofBook *book)
+{
+    struct entry_pdata entry_pdata;
+    gboolean successful;
+
+    entry_pdata.entry = gncEntryCreate(book);
+    entry_pdata.book = book;
+    entry_pdata.acc = NULL;
+    gncEntryBeginEdit (entry_pdata.entry);
+
+    successful = dom_tree_generic_parse (node, entry_handlers_v2,
+                                         &entry_pdata);
+    if (entry_pdata.acc != NULL)
+    {
+        if (gncEntryGetBill (entry_pdata.entry))
+            gncEntrySetBillAccount (entry_pdata.entry, entry_pdata.acc);
+        else
+            gncEntrySetInvAccount (entry_pdata.entry, entry_pdata.acc);
+    }
+
+    if (successful)
+        gncEntryCommitEdit (entry_pdata.entry);
+    else
+    {
+        PERR ("failed to parse entry tree");
+        gncEntryDestroy (entry_pdata.entry);
+        entry_pdata.entry = NULL;
+    }
+
+    return entry_pdata.entry;
+}
+
+static gboolean
+gnc_entry_end_handler(gpointer data_for_children,
+                      GSList* data_from_children, GSList* sibling_data,
+                      gpointer parent_data, gpointer global_data,
+                      gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncEntry *entry;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    entry = dom_tree_to_entry(tree, book);
+    if (entry != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, entry);
+    }
+
+    xmlFreeNode(tree);
+
+    return entry != NULL;
+}
+
+static sixtp *
+entry_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_entry_end_handler, NULL, NULL);
+}
+
+static void
+do_count (QofInstance * entry_p, gpointer count_p)
+{
+    int *count = count_p;
+    (*count)++;
+}
+
+static int
+entry_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_entry (QofInstance * entry_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncEntry *entry = (GncEntry *) entry_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+
+    /* Don't save non-attached entries! */
+    if (!(gncEntryGetOrder (entry) || gncEntryGetInvoice (entry) ||
+            gncEntryGetBill (entry)))
+        return;
+
+    node = entry_dom_tree_create (entry);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+entry_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_entry, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+static gboolean
+entry_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "entry");
+}
+
+void
+gnc_entry_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_entry_string,
+        entry_sixtp_parser_create,
+        NULL,			/* add_item */
+        entry_get_count,
+        entry_write,
+        NULL,			/* scrub */
+        entry_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-entry-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-entry-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-entry-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,29 @@
+/*
+ * gnc-entry-xml-v2.h -- entry xml i/o parser/unparsers
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_ENTRY_XML_V2_H
+#define GNC_ENTRY_XML_V2_H
+
+void gnc_entry_xml_initialize (void);
+
+#endif /* GNC_ENTRY_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-invoice-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-invoice-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-invoice-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,574 @@
+/********************************************************************\
+ * gnc-invoice-xml-v2.c -- invoice xml i/o implementation         *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncBillTermP.h"
+#include "gncInvoiceP.h"
+#include "gnc-invoice-xml-v2.h"
+#include "gnc-owner-xml-v2.h"
+#include "gnc-bill-term-xml-v2.h"
+
+#define _GNC_MOD_NAME	GNC_ID_INVOICE
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *invoice_version_string = "2.0.0";
+
+/* ids */
+#define gnc_invoice_string "gnc:GncInvoice"
+#define invoice_guid_string "invoice:guid"
+#define invoice_id_string "invoice:id"
+#define invoice_owner_string "invoice:owner"
+#define invoice_opened_string "invoice:opened"
+#define invoice_posted_string "invoice:posted"
+#define invoice_terms_string "invoice:terms"
+#define invoice_billing_id_string "invoice:billing_id"
+#define invoice_notes_string "invoice:notes"
+#define invoice_active_string "invoice:active"
+#define invoice_posttxn_string "invoice:posttxn"
+#define invoice_postlot_string "invoice:postlot"
+#define invoice_postacc_string "invoice:postacc"
+#define invoice_currency_string "invoice:currency"
+#define invoice_billto_string "invoice:billto"
+#define invoice_tochargeamt_string "invoice:charge-amt"
+#define invoice_slots_string "invoice:slots"
+
+static void
+maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
+{
+    if (str && strlen(str) > 0)
+        xmlAddChild (ptr, text_to_dom_tree (tag, str));
+}
+
+static void
+maybe_add_timespec (xmlNodePtr ptr, const char *tag, Timespec ts)
+{
+    if (ts.tv_sec || ts.tv_nsec)
+        xmlAddChild (ptr, timespec_to_dom_tree (tag, &ts));
+}
+
+static xmlNodePtr
+invoice_dom_tree_create (GncInvoice *invoice)
+{
+    xmlNodePtr ret;
+    Timespec ts;
+    Transaction *txn;
+    GNCLot *lot;
+    Account *acc;
+    GncBillTerm *term;
+    GncOwner *billto;
+    gnc_numeric amt;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_invoice_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST invoice_version_string);
+
+    xmlAddChild(ret, guid_to_dom_tree(invoice_guid_string,
+                                      qof_instance_get_guid(QOF_INSTANCE(invoice))));
+
+    xmlAddChild(ret, text_to_dom_tree(invoice_id_string,
+                                      gncInvoiceGetID (invoice)));
+
+    xmlAddChild(ret, gnc_owner_to_dom_tree (invoice_owner_string,
+                                            gncInvoiceGetOwner (invoice)));
+
+    ts = gncInvoiceGetDateOpened (invoice);
+    xmlAddChild(ret, timespec_to_dom_tree (invoice_opened_string, &ts));
+
+    maybe_add_timespec (ret, invoice_posted_string,
+                        gncInvoiceGetDatePosted (invoice));
+
+    term = gncInvoiceGetTerms (invoice);
+    if (term)
+        xmlAddChild(ret, guid_to_dom_tree(invoice_terms_string,
+                                          qof_instance_get_guid (QOF_INSTANCE(term))));
+
+    maybe_add_string (ret, invoice_billing_id_string,
+                      gncInvoiceGetBillingID (invoice));
+    maybe_add_string (ret, invoice_notes_string, gncInvoiceGetNotes (invoice));
+
+    xmlAddChild(ret, int_to_dom_tree(invoice_active_string,
+                                     gncInvoiceGetActive (invoice)));
+
+    txn = gncInvoiceGetPostedTxn (invoice);
+    if (txn)
+        xmlAddChild (ret, guid_to_dom_tree (invoice_posttxn_string,
+                                            xaccTransGetGUID (txn)));
+
+    lot = gncInvoiceGetPostedLot (invoice);
+    if (lot)
+        xmlAddChild (ret, guid_to_dom_tree (invoice_postlot_string,
+                                            gnc_lot_get_guid (lot)));
+
+    acc = gncInvoiceGetPostedAcc (invoice);
+    if (acc)
+        xmlAddChild (ret, guid_to_dom_tree (invoice_postacc_string,
+                                            qof_instance_get_guid(QOF_INSTANCE(acc))));
+
+    xmlAddChild
+    (ret,
+     commodity_ref_to_dom_tree(invoice_currency_string,
+                               gncInvoiceGetCurrency (invoice)));
+
+    billto = gncInvoiceGetBillTo (invoice);
+    if (billto && billto->owner.undefined != NULL)
+        xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_billto_string, billto));
+
+    amt = gncInvoiceGetToChargeAmount (invoice);
+    if (! gnc_numeric_zero_p (amt))
+        xmlAddChild (ret, gnc_numeric_to_dom_tree (invoice_tochargeamt_string, &amt));
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct invoice_pdata
+{
+    GncInvoice *invoice;
+    QofBook *book;
+};
+
+static inline gboolean
+set_string(xmlNodePtr node, GncInvoice* invoice,
+           void (*func)(GncInvoice *invoice, const char *txt))
+{
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    func(invoice, txt);
+
+    g_free(txt);
+    return TRUE;
+}
+
+static inline gboolean
+set_timespec(xmlNodePtr node, GncInvoice* invoice,
+             void (*func)(GncInvoice *invoice, Timespec ts))
+{
+    Timespec ts = dom_tree_to_timespec(node);
+    if (!dom_tree_valid_timespec(&ts, node->name)) return FALSE;
+
+    func(invoice, ts);
+    return TRUE;
+}
+
+static gboolean
+invoice_guid_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    GncGUID *guid;
+    GncInvoice *invoice;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    invoice = gncInvoiceLookup (pdata->book, guid);
+    if (invoice)
+    {
+        gncInvoiceDestroy (pdata->invoice);
+        pdata->invoice = invoice;
+        gncInvoiceBeginEdit (invoice);
+    }
+    else
+    {
+        gncInvoiceSetGUID(pdata->invoice, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+invoice_id_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+
+    return set_string(node, pdata->invoice, gncInvoiceSetID);
+}
+
+static gboolean
+invoice_owner_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    GncOwner owner;
+    gboolean ret;
+
+    ret = gnc_dom_tree_to_owner (node, &owner, pdata->book);
+    if (ret)
+        gncInvoiceSetOwner (pdata->invoice, &owner);
+
+    return ret;
+}
+
+static gboolean
+invoice_opened_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+
+    return set_timespec (node, pdata->invoice, gncInvoiceSetDateOpened);
+}
+
+static gboolean
+invoice_posted_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+
+    return set_timespec (node, pdata->invoice, gncInvoiceSetDatePosted);
+}
+
+static gboolean
+invoice_billing_id_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+
+    return set_string(node, pdata->invoice, gncInvoiceSetBillingID);
+}
+
+static gboolean
+invoice_notes_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+
+    return set_string(node, pdata->invoice, gncInvoiceSetNotes);
+}
+
+static gboolean
+invoice_active_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    gint64 val;
+    gboolean ret;
+
+    ret = dom_tree_to_integer(node, &val);
+    if (ret)
+        gncInvoiceSetActive(pdata->invoice, (gboolean)val);
+
+    return ret;
+}
+
+static gboolean
+invoice_terms_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    GncGUID *guid;
+    GncBillTerm *term;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    term = gnc_billterm_xml_find_or_create(pdata->book, guid);
+    g_assert(term);
+    g_free (guid);
+    gncInvoiceSetTerms (pdata->invoice, term);
+
+    return TRUE;
+}
+
+static gboolean
+invoice_posttxn_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    GncGUID *guid;
+    Transaction *txn;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    txn = xaccTransLookup (guid, pdata->book);
+    g_free (guid);
+    g_return_val_if_fail (txn, FALSE);
+
+    gncInvoiceSetPostedTxn (pdata->invoice, txn);
+    return TRUE;
+}
+
+static gboolean
+invoice_postlot_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    GncGUID *guid;
+    GNCLot *lot;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    lot = gnc_lot_lookup (guid, pdata->book);
+    g_free (guid);
+    g_return_val_if_fail (lot, FALSE);
+
+    gncInvoiceSetPostedLot (pdata->invoice, lot);
+    return TRUE;
+}
+
+static gboolean
+invoice_postacc_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    GncGUID *guid;
+    Account *acc;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    acc = xaccAccountLookup (guid, pdata->book);
+    g_free (guid);
+    g_return_val_if_fail (acc, FALSE);
+
+    gncInvoiceSetPostedAcc (pdata->invoice, acc);
+    return TRUE;
+}
+
+static gboolean
+invoice_currency_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    gnc_commodity *com;
+
+    com = dom_tree_to_commodity_ref(node, pdata->book);
+    g_return_val_if_fail (com, FALSE);
+
+    gncInvoiceSetCurrency (pdata->invoice, com);
+
+    return TRUE;
+}
+
+static gboolean
+invoice_billto_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    GncOwner owner;
+    gboolean ret;
+
+    ret = gnc_dom_tree_to_owner (node, &owner, pdata->book);
+    if (ret)
+        gncInvoiceSetBillTo (pdata->invoice, &owner);
+
+    return ret;
+}
+
+static gboolean
+invoice_tochargeamt_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    struct invoice_pdata *pdata = invoice_pdata;
+    gnc_numeric* num = dom_tree_to_gnc_numeric(node);
+    g_return_val_if_fail(num, FALSE);
+
+    gncInvoiceSetToChargeAmount (pdata->invoice, *num);
+    g_free(num);
+    return TRUE;
+}
+
+static gboolean
+invoice_slots_handler (xmlNodePtr node, gpointer invoice_pdata)
+{
+    return TRUE;
+}
+
+static struct dom_tree_handler invoice_handlers_v2[] =
+{
+    { invoice_guid_string, invoice_guid_handler, 1, 0 },
+    { invoice_id_string, invoice_id_handler, 1, 0 },
+    { invoice_owner_string, invoice_owner_handler, 1, 0 },
+    { invoice_opened_string, invoice_opened_handler, 1, 0 },
+    { invoice_posted_string, invoice_posted_handler, 0, 0 },
+    { invoice_billing_id_string, invoice_billing_id_handler, 0, 0 },
+    { invoice_notes_string, invoice_notes_handler, 0, 0 },
+    { invoice_active_string, invoice_active_handler, 1, 0 },
+    { invoice_terms_string, invoice_terms_handler, 0, 0 },
+    { invoice_posttxn_string, invoice_posttxn_handler, 0, 0 },
+    { invoice_postlot_string, invoice_postlot_handler, 0, 0 },
+    { invoice_postacc_string, invoice_postacc_handler, 0, 0 },
+    { invoice_currency_string, invoice_currency_handler, 0, 0 },
+    { "invoice:commodity", invoice_currency_handler, 0, 0 },
+    { invoice_billto_string, invoice_billto_handler, 0, 0 },
+    { invoice_tochargeamt_string, invoice_tochargeamt_handler, 0, 0},
+    { invoice_slots_string, invoice_slots_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncInvoice*
+dom_tree_to_invoice (xmlNodePtr node, QofBook *book)
+{
+    struct invoice_pdata invoice_pdata;
+    gboolean successful;
+
+    invoice_pdata.invoice = gncInvoiceCreate(book);
+    invoice_pdata.book = book;
+    gncInvoiceBeginEdit (invoice_pdata.invoice);
+
+    successful = dom_tree_generic_parse (node, invoice_handlers_v2,
+                                         &invoice_pdata);
+
+    if (successful)
+        gncInvoiceCommitEdit (invoice_pdata.invoice);
+    else
+    {
+        PERR ("failed to parse invoice tree");
+        gncInvoiceDestroy (invoice_pdata.invoice);
+        invoice_pdata.invoice = NULL;
+    }
+
+    return invoice_pdata.invoice;
+}
+
+static gboolean
+gnc_invoice_end_handler(gpointer data_for_children,
+                        GSList* data_from_children, GSList* sibling_data,
+                        gpointer parent_data, gpointer global_data,
+                        gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncInvoice *invoice;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    invoice = dom_tree_to_invoice(tree, book);
+    if (invoice != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, invoice);
+    }
+
+    xmlFreeNode(tree);
+
+    return invoice != NULL;
+}
+
+static sixtp *
+invoice_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_invoice_end_handler, NULL, NULL);
+}
+
+static gboolean
+invoice_should_be_saved (GncInvoice *invoice)
+{
+    const char *id;
+
+    /* make sure this is a valid invoice before we save it -- should have an ID */
+    id = gncInvoiceGetID (invoice);
+    if (id == NULL || *id == '\0')
+        return FALSE;
+
+    return TRUE;
+}
+
+static void
+do_count (QofInstance * invoice_p, gpointer count_p)
+{
+    int *count = count_p;
+    if (invoice_should_be_saved ((GncInvoice *)invoice_p))
+        (*count)++;
+}
+
+static int
+invoice_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_invoice (QofInstance * invoice_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncInvoice *invoice = (GncInvoice *) invoice_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+    if (!invoice_should_be_saved (invoice))
+        return;
+
+    node = invoice_dom_tree_create (invoice);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+invoice_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_invoice, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+static gboolean
+invoice_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "invoice");
+}
+
+void
+gnc_invoice_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_invoice_string,
+        invoice_sixtp_parser_create,
+        NULL,			/* add_item */
+        invoice_get_count,
+        invoice_write,
+        NULL,			/* scrub */
+        invoice_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-invoice-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-invoice-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-invoice-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,29 @@
+/*
+ * gnc-invoice-xml-v2.h -- invoice xml i/o parser/unparsers
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_INVOICE_XML_V2_H
+#define GNC_INVOICE_XML_V2_H
+
+void gnc_invoice_xml_initialize (void);
+
+#endif /* GNC_INVOICE_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-job-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-job-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-job-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,361 @@
+/********************************************************************\
+ * gnc-job-xml-v2.c -- job xml i/o implementation         *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncJobP.h"
+#include "gnc-job-xml-v2.h"
+#include "gnc-owner-xml-v2.h"
+#include "xml-helpers.h"
+
+#define _GNC_MOD_NAME	GNC_ID_JOB
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *job_version_string = "2.0.0";
+
+/* ids */
+#define gnc_job_string "gnc:GncJob"
+#define job_guid_string "job:guid"
+#define job_id_string "job:id"
+#define job_name_string "job:name"
+#define job_reference_string "job:reference"
+#define job_owner_string "job:owner"
+#define job_active_string "job:active"
+#define job_slots_string "job:slots"
+
+static xmlNodePtr
+job_dom_tree_create (GncJob *job)
+{
+    xmlNodePtr ret;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_job_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST job_version_string);
+
+    xmlAddChild(ret, guid_to_dom_tree(job_guid_string,
+                                      qof_instance_get_guid (QOF_INSTANCE (job))));
+
+    xmlAddChild(ret, text_to_dom_tree(job_id_string,
+                                      gncJobGetID (job)));
+
+    xmlAddChild(ret, text_to_dom_tree(job_name_string,
+                                      gncJobGetName (job)));
+
+    maybe_add_string (ret, job_reference_string, gncJobGetReference (job));
+
+    xmlAddChild(ret, gnc_owner_to_dom_tree (job_owner_string,
+                                            gncJobGetOwner (job)));
+
+    xmlAddChild(ret, int_to_dom_tree(job_active_string,
+                                     gncJobGetActive (job)));
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct job_pdata
+{
+    GncJob *job;
+    QofBook *book;
+};
+
+static gboolean
+set_string(xmlNodePtr node, GncJob* job,
+           void (*func)(GncJob *job, const char *txt))
+{
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    func(job, txt);
+
+    g_free(txt);
+
+    return TRUE;
+}
+
+static gboolean
+job_name_handler (xmlNodePtr node, gpointer job_pdata)
+{
+    struct job_pdata *pdata = job_pdata;
+
+    return set_string(node, pdata->job, gncJobSetName);
+}
+
+static gboolean
+job_guid_handler (xmlNodePtr node, gpointer job_pdata)
+{
+    struct job_pdata *pdata = job_pdata;
+    GncGUID *guid;
+    GncJob *job;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail(guid, FALSE);
+    job = gncJobLookup (pdata->book, guid);
+    if (job)
+    {
+        gncJobDestroy (pdata->job);
+        pdata->job = job;
+        gncJobBeginEdit (job);
+    }
+    else
+    {
+        gncJobSetGUID(pdata->job, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+job_id_handler (xmlNodePtr node, gpointer job_pdata)
+{
+    struct job_pdata *pdata = job_pdata;
+
+    return set_string(node, pdata->job, gncJobSetID);
+}
+
+static gboolean
+job_reference_handler (xmlNodePtr node, gpointer job_pdata)
+{
+    struct job_pdata *pdata = job_pdata;
+
+    return set_string(node, pdata->job, gncJobSetReference);
+}
+
+static gboolean
+job_owner_handler (xmlNodePtr node, gpointer job_pdata)
+{
+    struct job_pdata *pdata = job_pdata;
+    GncOwner owner;
+    gboolean ret;
+
+    ret = gnc_dom_tree_to_owner (node, &owner, pdata->book);
+    if (ret)
+        gncJobSetOwner (pdata->job, &owner);
+
+    return ret;
+}
+
+static gboolean
+job_active_handler (xmlNodePtr node, gpointer job_pdata)
+{
+    struct job_pdata *pdata = job_pdata;
+    gint64 val;
+    gboolean ret;
+
+    ret = dom_tree_to_integer(node, &val);
+    if (ret)
+        gncJobSetActive(pdata->job, (gboolean)val);
+
+    return ret;
+}
+
+static gboolean
+job_slots_handler (xmlNodePtr node, gpointer job_pdata)
+{
+    return TRUE;
+}
+
+static struct dom_tree_handler job_handlers_v2[] =
+{
+    { job_guid_string, job_guid_handler, 1, 0 },
+    { job_id_string, job_id_handler, 1, 0 },
+    { job_name_string, job_name_handler, 1, 0 },
+    { job_reference_string, job_reference_handler, 0, 0 },
+    { job_owner_string, job_owner_handler, 1, 0 },
+    { job_active_string, job_active_handler, 1, 0 },
+    { job_slots_string, job_slots_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncJob*
+dom_tree_to_job (xmlNodePtr node, QofBook *book)
+{
+    struct job_pdata job_pdata;
+    gboolean successful;
+
+    job_pdata.job = gncJobCreate(book);
+    job_pdata.book = book;
+    gncJobBeginEdit (job_pdata.job);
+
+    successful = dom_tree_generic_parse (node, job_handlers_v2,
+                                         &job_pdata);
+
+    if (successful)
+        gncJobCommitEdit (job_pdata.job);
+    else
+    {
+        PERR ("failed to parse job tree");
+        gncJobDestroy (job_pdata.job);
+        job_pdata.job = NULL;
+    }
+
+    return job_pdata.job;
+}
+
+static gboolean
+gnc_job_end_handler(gpointer data_for_children,
+                    GSList* data_from_children, GSList* sibling_data,
+                    gpointer parent_data, gpointer global_data,
+                    gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncJob *job;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    job = dom_tree_to_job(tree, book);
+    if (job != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, job);
+    }
+
+    xmlFreeNode(tree);
+
+    return job != NULL;
+}
+
+static sixtp *
+job_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_job_end_handler, NULL, NULL);
+}
+
+static gboolean
+job_should_be_saved (GncJob *job)
+{
+    const char *id;
+
+    /* make sure this is a valid job before we save it -- should have an ID */
+    id = gncJobGetID (job);
+    if (id == NULL || *id == '\0')
+        return FALSE;
+
+    return TRUE;
+}
+
+static void
+do_count (QofInstance * job_p, gpointer count_p)
+{
+    int *count = count_p;
+    if (job_should_be_saved ((GncJob *)job_p))
+        (*count)++;
+}
+
+static int
+job_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_job (QofInstance * job_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncJob *job = (GncJob *) job_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+    if (!job_should_be_saved (job))
+        return;
+
+    node = job_dom_tree_create (job);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+job_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_job, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+static gboolean
+job_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "job");
+}
+
+void
+gnc_job_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_job_string,
+        job_sixtp_parser_create,
+        NULL,			/* add_item */
+        job_get_count,
+        job_write,
+        NULL,			/* scrub */
+        job_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-job-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-job-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-job-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,29 @@
+/*
+ * gnc-job-xml-v2.h -- job xml i/o parser/unparsers
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_JOB_XML_V2_H
+#define GNC_JOB_XML_V2_H
+
+void gnc_job_xml_initialize (void);
+
+#endif /* GNC_JOB_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-order-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-order-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-order-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,404 @@
+/********************************************************************\
+ * gnc-order-xml-v2.c -- order xml i/o implementation         *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncOrderP.h"
+
+#include "gnc-order-xml-v2.h"
+#include "gnc-owner-xml-v2.h"
+
+#define _GNC_MOD_NAME	GNC_ID_ORDER
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *order_version_string = "2.0.0";
+
+/* ids */
+#define gnc_order_string "gnc:GncOrder"
+#define order_guid_string "order:guid"
+#define order_id_string "order:id"
+#define order_owner_string "order:owner"
+#define order_opened_string "order:opened"
+#define order_closed_string "order:closed"
+#define order_notes_string "order:notes"
+#define order_reference_string "order:reference"
+#define order_active_string "order:active"
+#define order_slots_string "order:slots"
+
+static void
+maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
+{
+    if (str && strlen(str) > 0)
+        xmlAddChild (ptr, text_to_dom_tree (tag, str));
+}
+
+static xmlNodePtr
+order_dom_tree_create (GncOrder *order)
+{
+    xmlNodePtr ret;
+    Timespec ts;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_order_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST order_version_string);
+
+    xmlAddChild(ret, guid_to_dom_tree(order_guid_string,
+                                      qof_instance_get_guid(QOF_INSTANCE (order))));
+
+    xmlAddChild(ret, text_to_dom_tree(order_id_string,
+                                      gncOrderGetID (order)));
+
+    xmlAddChild(ret, gnc_owner_to_dom_tree (order_owner_string,
+                                            gncOrderGetOwner (order)));
+
+    ts = gncOrderGetDateOpened (order);
+    xmlAddChild(ret, timespec_to_dom_tree (order_opened_string, &ts));
+
+    ts = gncOrderGetDateClosed (order);
+    if (ts.tv_sec || ts.tv_nsec)
+        xmlAddChild(ret, timespec_to_dom_tree (order_closed_string, &ts));
+
+    maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order));
+    maybe_add_string (ret, order_reference_string, gncOrderGetReference (order));
+
+    xmlAddChild(ret, int_to_dom_tree(order_active_string,
+                                     gncOrderGetActive (order)));
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct order_pdata
+{
+    GncOrder *order;
+    QofBook *book;
+};
+
+static inline gboolean
+set_string(xmlNodePtr node, GncOrder* order,
+           void (*func)(GncOrder *order, const char *txt))
+{
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    func(order, txt);
+
+    g_free(txt);
+    return TRUE;
+}
+
+static inline gboolean
+set_timespec(xmlNodePtr node, GncOrder* order,
+             void (*func)(GncOrder *order, Timespec ts))
+{
+    Timespec ts = dom_tree_to_timespec(node);
+    if (!dom_tree_valid_timespec(&ts, node->name)) return FALSE;
+
+    func(order, ts);
+    return TRUE;
+}
+
+static gboolean
+order_guid_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    struct order_pdata *pdata = order_pdata;
+    GncGUID *guid;
+    GncOrder *order;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    order = gncOrderLookup (pdata->book, guid);
+    if (order)
+    {
+        gncOrderDestroy (pdata->order);
+        pdata->order = order;
+        gncOrderBeginEdit (order);
+    }
+    else
+    {
+        gncOrderSetGUID(pdata->order, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+order_id_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    struct order_pdata *pdata = order_pdata;
+
+    return set_string(node, pdata->order, gncOrderSetID);
+}
+
+static gboolean
+order_owner_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    struct order_pdata *pdata = order_pdata;
+    GncOwner owner;
+    gboolean ret;
+
+    ret = gnc_dom_tree_to_owner (node, &owner, pdata->book);
+    if (ret)
+        gncOrderSetOwner (pdata->order, &owner);
+
+    return ret;
+}
+
+static gboolean
+order_opened_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    struct order_pdata *pdata = order_pdata;
+
+    return set_timespec (node, pdata->order, gncOrderSetDateOpened);
+}
+
+static gboolean
+order_closed_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    struct order_pdata *pdata = order_pdata;
+
+    return set_timespec (node, pdata->order, gncOrderSetDateClosed);
+}
+
+static gboolean
+order_notes_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    struct order_pdata *pdata = order_pdata;
+
+    return set_string(node, pdata->order, gncOrderSetNotes);
+}
+
+static gboolean
+order_reference_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    struct order_pdata *pdata = order_pdata;
+
+    return set_string(node, pdata->order, gncOrderSetReference);
+}
+
+static gboolean
+order_active_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    struct order_pdata *pdata = order_pdata;
+    gint64 val;
+    gboolean ret;
+
+    ret = dom_tree_to_integer(node, &val);
+    if (ret)
+        gncOrderSetActive(pdata->order, (gboolean)val);
+
+    return ret;
+}
+
+static gboolean
+order_slots_handler (xmlNodePtr node, gpointer order_pdata)
+{
+    return TRUE;
+}
+
+static struct dom_tree_handler order_handlers_v2[] =
+{
+    { order_guid_string, order_guid_handler, 1, 0 },
+    { order_id_string, order_id_handler, 1, 0 },
+    { order_owner_string, order_owner_handler, 1, 0 },
+    { order_opened_string, order_opened_handler, 1, 0 },
+    { order_closed_string, order_closed_handler, 0, 0 },
+    { order_notes_string, order_notes_handler, 0, 0 },
+    { order_reference_string, order_reference_handler, 0, 0 },
+    { order_active_string, order_active_handler, 1, 0 },
+    { order_slots_string, order_slots_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncOrder*
+dom_tree_to_order (xmlNodePtr node, QofBook *book)
+{
+    struct order_pdata order_pdata;
+    gboolean successful;
+
+    order_pdata.order = gncOrderCreate(book);
+    order_pdata.book = book;
+    gncOrderBeginEdit (order_pdata.order);
+
+    successful = dom_tree_generic_parse (node, order_handlers_v2,
+                                         &order_pdata);
+
+    if (successful)
+        gncOrderCommitEdit (order_pdata.order);
+    else
+    {
+        PERR ("failed to parse order tree");
+        gncOrderDestroy (order_pdata.order);
+        order_pdata.order = NULL;
+    }
+
+    return order_pdata.order;
+}
+
+static gboolean
+gnc_order_end_handler(gpointer data_for_children,
+                      GSList* data_from_children, GSList* sibling_data,
+                      gpointer parent_data, gpointer global_data,
+                      gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncOrder *order;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    order = dom_tree_to_order(tree, book);
+    if (order != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, order);
+    }
+
+    xmlFreeNode(tree);
+
+    return order != NULL;
+}
+
+static sixtp *
+order_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_order_end_handler, NULL, NULL);
+}
+
+static gboolean
+order_should_be_saved (GncOrder *order)
+{
+    const char *id;
+
+    /* make sure this is a valid order before we save it -- should have an ID */
+    id = gncOrderGetID (order);
+    if (id == NULL || *id == '\0')
+        return FALSE;
+
+    return TRUE;
+}
+
+static void
+do_count (QofInstance * order_p, gpointer count_p)
+{
+    int *count = count_p;
+    if (order_should_be_saved ((GncOrder *) order_p))
+        (*count)++;
+}
+
+static int
+order_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_order (QofInstance * order_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncOrder *order = (GncOrder *) order_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+    if (!order_should_be_saved (order))
+        return;
+
+    node = order_dom_tree_create (order);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+order_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_order, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+static gboolean
+order_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "order");
+}
+
+void
+gnc_order_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_order_string,
+        order_sixtp_parser_create,
+        NULL,			/* add_item */
+        order_get_count,
+        order_write,
+        NULL,			/* scrub */
+        order_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-order-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-order-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-order-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,29 @@
+/*
+ * gnc-order-xml-v2.h -- order xml i/o parser/unparsers
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_ORDER_XML_V2_H
+#define GNC_ORDER_XML_V2_H
+
+void gnc_order_xml_initialize (void);
+
+#endif /* GNC_ORDER_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-owner-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-owner-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-owner-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,244 @@
+/********************************************************************\
+ * gnc-owner-xml-v2.c -- owner xml i/o implementation           *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gnc-owner-xml-v2.h"
+#include "gncCustomerP.h"
+#include "gncJobP.h"
+#include "gncVendorP.h"
+#include "gncEmployeeP.h"
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *owner_version_string = "2.0.0";
+
+/* ids */
+#define owner_type_string	"owner:type"
+#define owner_id_string		"owner:id"
+
+xmlNodePtr
+gnc_owner_to_dom_tree (const char *tag, GncOwner *owner)
+{
+    xmlNodePtr ret;
+    const char *type_str;
+
+    switch (gncOwnerGetType (owner))
+    {
+    case GNC_OWNER_CUSTOMER:
+        type_str = GNC_ID_CUSTOMER;
+        break;
+    case GNC_OWNER_JOB:
+        type_str = GNC_ID_JOB;
+        break;
+    case GNC_OWNER_VENDOR:
+        type_str = GNC_ID_VENDOR;
+        break;
+    case GNC_OWNER_EMPLOYEE:
+        type_str = GNC_ID_EMPLOYEE;
+        break;
+    default:
+        PWARN ("Invalid owner type: %d", gncOwnerGetType (owner));
+        return NULL;
+    }
+
+    ret = xmlNewNode(NULL, BAD_CAST tag);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST owner_version_string);
+
+    xmlAddChild (ret, text_to_dom_tree (owner_type_string, type_str));
+    xmlAddChild (ret, guid_to_dom_tree (owner_id_string,
+                                        gncOwnerGetGUID (owner)));
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct owner_pdata
+{
+    GncOwner *owner;
+    QofBook *book;
+};
+
+static gboolean
+owner_type_handler (xmlNodePtr node, gpointer owner_pdata)
+{
+    struct owner_pdata *pdata = owner_pdata;
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    if (!safe_strcmp (txt, GNC_ID_CUSTOMER))
+        gncOwnerInitCustomer (pdata->owner, NULL);
+    else if (!safe_strcmp (txt, GNC_ID_JOB))
+        gncOwnerInitJob (pdata->owner, NULL);
+    else if (!safe_strcmp (txt, GNC_ID_VENDOR))
+        gncOwnerInitVendor (pdata->owner, NULL);
+    else if (!safe_strcmp (txt, GNC_ID_EMPLOYEE))
+        gncOwnerInitEmployee (pdata->owner, NULL);
+    else
+    {
+        PWARN ("Unknown owner type: %s", txt);
+        g_free(txt);
+        return FALSE;
+    }
+
+    g_free(txt);
+    return TRUE;
+}
+
+static gboolean
+owner_id_handler (xmlNodePtr node, gpointer owner_pdata)
+{
+    struct owner_pdata *pdata = owner_pdata;
+    GncGUID *guid;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+
+    switch (gncOwnerGetType (pdata->owner))
+    {
+    case GNC_OWNER_CUSTOMER:
+    {
+        GncCustomer *cust = gncCustomerLookup (pdata->book, guid);
+        if (!cust)
+        {
+            cust = gncCustomerCreate (pdata->book);
+            gncCustomerSetGUID (cust, guid);
+        }
+        gncOwnerInitCustomer (pdata->owner, cust);
+        break;
+    }
+    case GNC_OWNER_JOB:
+    {
+        GncJob *job = gncJobLookup (pdata->book, guid);
+        if (!job)
+        {
+            job = gncJobCreate (pdata->book);
+            gncJobSetGUID (job, guid);
+        }
+        gncOwnerInitJob (pdata->owner, job);
+        break;
+    }
+    case GNC_OWNER_VENDOR:
+    {
+        GncVendor *vendor = gncVendorLookup (pdata->book, guid);
+        if (!vendor)
+        {
+            vendor = gncVendorCreate (pdata->book);
+            gncVendorSetGUID (vendor, guid);
+        }
+        gncOwnerInitVendor (pdata->owner, vendor);
+        break;
+    }
+    case GNC_OWNER_EMPLOYEE:
+    {
+        GncEmployee *employee = gncEmployeeLookup (pdata->book, guid);
+        if (!employee)
+        {
+            employee = gncEmployeeCreate (pdata->book);
+            gncEmployeeSetGUID (employee, guid);
+        }
+        gncOwnerInitEmployee (pdata->owner, employee);
+        break;
+    }
+    default:
+        PWARN ("Invalid owner type: %d\n", gncOwnerGetType (pdata->owner));
+        g_free (guid);
+        return FALSE;
+    }
+
+    g_free (guid);
+    return TRUE;
+}
+
+static struct dom_tree_handler owner_handlers_v2[] =
+{
+    { owner_type_string, owner_type_handler, 1, 0 },
+    { owner_id_string, owner_id_handler, 1, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+gboolean
+gnc_dom_tree_to_owner (xmlNodePtr node, GncOwner *owner, QofBook *book)
+{
+    struct owner_pdata owner_pdata;
+    gboolean successful;
+
+    owner_pdata.owner = owner;
+    owner_pdata.book = book;
+
+    successful = dom_tree_generic_parse (node, owner_handlers_v2,
+                                         &owner_pdata);
+
+    if (!successful)
+    {
+        PERR ("failed to parse owner tree");
+    }
+
+    return successful;
+}
+
+static gboolean
+owner_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "owner");
+}
+
+void
+gnc_owner_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        "gnc:Owner",
+        NULL,			/* parser_create */
+        NULL,			/* add_item */
+        NULL,			/* get_count */
+        NULL,			/* write */
+        NULL,			/* scrub */
+        owner_ns,
+    };
+
+    qof_object_register_backend ("gnc:Owner",
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-owner-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-owner-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-owner-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,34 @@
+/* gnc-owner-xml-v2.h -- Owner XML header
+ *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_OWNER_XML_V2_H
+#define GNC_OWNER_XML_V2_H
+
+#include "gncOwner.h"
+#include "qof.h"
+
+gboolean   gnc_dom_tree_to_owner (xmlNodePtr node, GncOwner *owner,
+                                  QofBook *book);
+xmlNodePtr gnc_owner_to_dom_tree (const char *tag, GncOwner *addr);
+void gnc_owner_xml_initialize (void);
+
+#endif /* GNC_OWNER_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-tax-table-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-tax-table-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-tax-table-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,716 @@
+/********************************************************************\
+ * gnc-tax-table-xml-v2.c -- tax table xml i/o implementation       *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncEntry.h"
+#include "gncTaxTableP.h"
+#include "gnc-tax-table-xml-v2.h"
+
+#define _GNC_MOD_NAME	GNC_ID_TAXTABLE
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *taxtable_version_string = "2.0.0";
+
+/* ids */
+#define gnc_taxtable_string "gnc:GncTaxTable"
+#define taxtable_guid_string "taxtable:guid"
+#define taxtable_name_string "taxtable:name"
+#define taxtable_refcount_string "taxtable:refcount"
+#define taxtable_invisible_string "taxtable:invisible"
+#define taxtable_parent_string "taxtable:parent"
+#define taxtable_child_string "taxtable:child"
+#define taxtable_entries_string "taxtable:entries"
+#define taxtable_slots_string "taxtable:slots"
+
+#define gnc_taxtableentry_string "gnc:GncTaxTableEntry"
+#define ttentry_account_string "tte:acct"
+#define ttentry_type_string "tte:type"
+#define ttentry_amount_string "tte:amount"
+
+static void
+maybe_add_guid (xmlNodePtr ptr, const char *tag, GncTaxTable *table)
+{
+    if (table)
+        xmlAddChild (ptr, guid_to_dom_tree (tag,
+                                            qof_instance_get_guid(QOF_INSTANCE(table))));
+}
+
+static xmlNodePtr
+ttentry_dom_tree_create (GncTaxTableEntry *entry)
+{
+    xmlNodePtr ret;
+    Account *account;
+    gnc_numeric amount;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_taxtableentry_string);
+
+    account = gncTaxTableEntryGetAccount (entry);
+    if (account)
+        xmlAddChild(ret, guid_to_dom_tree (ttentry_account_string,
+                                           qof_instance_get_guid (QOF_INSTANCE(account))));
+
+    amount = gncTaxTableEntryGetAmount (entry);
+    xmlAddChild (ret, gnc_numeric_to_dom_tree (ttentry_amount_string, &amount));
+
+    xmlAddChild(ret, text_to_dom_tree (ttentry_type_string,
+                                       gncAmountTypeToString (
+                                           gncTaxTableEntryGetType (entry))));
+
+    return ret;
+}
+
+static xmlNodePtr
+taxtable_dom_tree_create (GncTaxTable *table)
+{
+    xmlNodePtr ret, entries;
+    GList *list;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_taxtable_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST taxtable_version_string);
+
+    maybe_add_guid(ret, taxtable_guid_string, table);
+    xmlAddChild(ret, text_to_dom_tree (taxtable_name_string,
+                                       gncTaxTableGetName (table)));
+
+    xmlAddChild(ret, int_to_dom_tree (taxtable_refcount_string,
+                                      gncTaxTableGetRefcount (table)));
+    xmlAddChild(ret, int_to_dom_tree (taxtable_invisible_string,
+                                      gncTaxTableGetInvisible (table)));
+
+    /* We should not be our own child */
+    if (gncTaxTableGetChild(table) != table)
+        maybe_add_guid(ret, taxtable_child_string, gncTaxTableGetChild (table));
+
+    maybe_add_guid(ret, taxtable_parent_string, gncTaxTableGetParent (table));
+
+    entries = xmlNewChild (ret, NULL, BAD_CAST taxtable_entries_string, NULL);
+    for (list = gncTaxTableGetEntries (table); list; list = list->next)
+    {
+        GncTaxTableEntry *entry = list->data;
+        xmlAddChild(entries, ttentry_dom_tree_create (entry));
+    }
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct ttentry_pdata
+{
+    GncTaxTableEntry *ttentry;
+    QofBook *book;
+};
+
+static gboolean
+ttentry_acct_handler (xmlNodePtr node, gpointer ttentry_pdata)
+{
+    struct ttentry_pdata *pdata = ttentry_pdata;
+    GncGUID *guid;
+    Account * acc;
+
+    guid = dom_tree_to_guid (node);
+    g_return_val_if_fail (guid, FALSE);
+    acc = xaccAccountLookup (guid, pdata->book);
+    g_free (guid);
+    g_return_val_if_fail (acc, FALSE);
+
+    gncTaxTableEntrySetAccount (pdata->ttentry, acc);
+    return TRUE;
+}
+
+static gboolean
+ttentry_type_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    struct ttentry_pdata *pdata = taxtable_pdata;
+    GncAmountType type;
+    char *str;
+    gboolean ret;
+
+    str = dom_tree_to_text (node);
+    g_return_val_if_fail (str, FALSE);
+
+    ret = gncAmountStringToType (str, &type);
+    g_free (str);
+
+    if (ret)
+        gncTaxTableEntrySetType (pdata->ttentry, type);
+
+    return ret;
+}
+
+static gboolean
+ttentry_amount_handler (xmlNodePtr node, gpointer ttentry_pdata)
+{
+    struct ttentry_pdata *pdata = ttentry_pdata;
+    gnc_numeric* num = dom_tree_to_gnc_numeric(node);
+    g_return_val_if_fail(num, FALSE);
+
+    gncTaxTableEntrySetAmount (pdata->ttentry, *num);
+    g_free(num);
+    return TRUE;
+}
+
+static struct dom_tree_handler ttentry_handlers_v2[] =
+{
+    { ttentry_account_string, ttentry_acct_handler, 0, 0 },
+    { ttentry_type_string, ttentry_type_handler, 1, 0 },
+    { ttentry_amount_string, ttentry_amount_handler, 1, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncTaxTableEntry*
+dom_tree_to_ttentry (xmlNodePtr node, QofBook *book)
+{
+    struct ttentry_pdata ttentry_pdata;
+    gboolean successful;
+
+    ttentry_pdata.ttentry = gncTaxTableEntryCreate ();
+    ttentry_pdata.book = book;
+
+    successful = dom_tree_generic_parse (node, ttentry_handlers_v2,
+                                         &ttentry_pdata);
+
+    if (!successful)
+    {
+        PERR ("failed to parse tax table entry tree");
+        gncTaxTableEntryDestroy (ttentry_pdata.ttentry);
+        ttentry_pdata.ttentry = NULL;
+    }
+
+    return ttentry_pdata.ttentry;
+}
+
+/***********************************************************************/
+
+struct taxtable_pdata
+{
+    GncTaxTable *table;
+    QofBook *book;
+};
+
+static gboolean
+set_parent_child (xmlNodePtr node, struct taxtable_pdata *pdata,
+                  void (*func)(GncTaxTable *, GncTaxTable *))
+{
+    GncGUID *guid;
+    GncTaxTable *table;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    table = gncTaxTableLookup (pdata->book, guid);
+
+    /* Ignore pointers to self */
+    if (table == pdata->table)
+    {
+        PINFO ("found a self-referential parent/child; ignoring.\n");
+        return TRUE;
+    }
+
+    if (!table)
+    {
+        table = gncTaxTableCreate (pdata->book);
+        gncTaxTableBeginEdit (table);
+        gncTaxTableSetGUID (table, guid);
+        gncTaxTableCommitEdit (table);
+    }
+    g_free (guid);
+    g_return_val_if_fail (table, FALSE);
+    func (pdata->table, table);
+
+    return TRUE;
+}
+
+static gboolean
+taxtable_guid_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    struct taxtable_pdata *pdata = taxtable_pdata;
+    GncGUID *guid;
+    GncTaxTable *table;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    table = gncTaxTableLookup (pdata->book, guid);
+    if (table)
+    {
+        gncTaxTableDestroy (pdata->table);
+        pdata->table = table;
+        gncTaxTableBeginEdit (table);
+    }
+    else
+    {
+        gncTaxTableSetGUID(pdata->table, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+taxtable_name_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    struct taxtable_pdata *pdata = taxtable_pdata;
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    gncTaxTableSetName (pdata->table, txt);
+    g_free(txt);
+    return TRUE;
+}
+
+static gboolean
+taxtable_refcount_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    struct taxtable_pdata *pdata = taxtable_pdata;
+    gint64 val;
+
+    dom_tree_to_integer(node, &val);
+    gncTaxTableSetRefcount (pdata->table, val);
+    return TRUE;
+}
+
+static gboolean
+taxtable_invisible_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    struct taxtable_pdata *pdata = taxtable_pdata;
+    gint64 val;
+
+    dom_tree_to_integer(node, &val);
+    if (val)
+        gncTaxTableMakeInvisible (pdata->table);
+    return TRUE;
+}
+
+static gboolean
+taxtable_parent_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    struct taxtable_pdata *pdata = taxtable_pdata;
+    return set_parent_child (node, pdata, gncTaxTableSetParent);
+}
+
+static gboolean
+taxtable_child_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    struct taxtable_pdata *pdata = taxtable_pdata;
+    return set_parent_child (node, pdata, gncTaxTableSetChild);
+}
+
+static gboolean
+taxtable_entries_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    struct taxtable_pdata *pdata = taxtable_pdata;
+    xmlNodePtr mark;
+
+    g_return_val_if_fail (node, FALSE);
+    g_return_val_if_fail (node->xmlChildrenNode, FALSE);
+
+    for (mark = node->xmlChildrenNode; mark; mark = mark->next)
+    {
+        GncTaxTableEntry *entry;
+
+        if (safe_strcmp ("text", (char*)mark->name) == 0)
+            continue;
+
+        if (safe_strcmp (gnc_taxtableentry_string, (char*)mark->name))
+            return FALSE;
+
+        entry = dom_tree_to_ttentry (mark, pdata->book);
+
+        if (entry)
+            gncTaxTableAddEntry (pdata->table, entry);
+        else
+            return FALSE;
+
+    }
+    return TRUE;
+}
+
+static gboolean
+taxtable_slots_handler (xmlNodePtr node, gpointer taxtable_pdata)
+{
+    return TRUE;
+}
+
+static struct dom_tree_handler taxtable_handlers_v2[] =
+{
+    { taxtable_guid_string, taxtable_guid_handler, 1, 0 },
+    { taxtable_name_string, taxtable_name_handler, 1, 0 },
+    { taxtable_refcount_string, taxtable_refcount_handler, 1, 0 },
+    { taxtable_invisible_string, taxtable_invisible_handler, 1, 0 },
+    { taxtable_parent_string, taxtable_parent_handler, 0, 0 },
+    { taxtable_child_string, taxtable_child_handler, 0, 0 },
+    { taxtable_entries_string, taxtable_entries_handler, 1, 0 },
+    { taxtable_slots_string, taxtable_slots_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncTaxTable*
+dom_tree_to_taxtable (xmlNodePtr node, QofBook *book)
+{
+    struct taxtable_pdata taxtable_pdata;
+    gboolean successful;
+
+    taxtable_pdata.table = gncTaxTableCreate (book);
+    taxtable_pdata.book = book;
+    gncTaxTableBeginEdit (taxtable_pdata.table);
+
+    successful = dom_tree_generic_parse (node, taxtable_handlers_v2,
+                                         &taxtable_pdata);
+
+    if (successful)
+        gncTaxTableCommitEdit (taxtable_pdata.table);
+    else
+    {
+        PERR ("failed to parse tax table tree");
+        gncTaxTableDestroy (taxtable_pdata.table);
+        taxtable_pdata.table = NULL;
+    }
+
+    return taxtable_pdata.table;
+}
+
+static gboolean
+gnc_taxtable_end_handler(gpointer data_for_children,
+                         GSList* data_from_children, GSList* sibling_data,
+                         gpointer parent_data, gpointer global_data,
+                         gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncTaxTable *table;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    table = dom_tree_to_taxtable (tree, book);
+    if (table != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, table);
+    }
+
+    xmlFreeNode(tree);
+
+    return table != NULL;
+}
+
+static sixtp *
+taxtable_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_taxtable_end_handler, NULL, NULL);
+}
+
+static void
+do_count (QofInstance * table_p, gpointer count_p)
+{
+    int *count = count_p;
+    (*count)++;
+}
+
+static int
+taxtable_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_taxtable (QofInstance * table_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncTaxTable *table = (GncTaxTable *) table_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+
+    node = taxtable_dom_tree_create (table);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+taxtable_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_taxtable, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+
+static gboolean
+taxtable_is_grandchild (GncTaxTable *table)
+{
+    return (gncTaxTableGetParent(gncTaxTableGetParent(table)) != NULL);
+}
+
+static GncTaxTable *
+taxtable_find_senior (GncTaxTable *table)
+{
+    GncTaxTable *temp, *parent, *gp = NULL;
+
+    temp = table;
+    do
+    {
+        /* See if "temp" is a grandchild */
+        parent = gncTaxTableGetParent(temp);
+        if (!parent)
+            break;
+        gp = gncTaxTableGetParent(parent);
+        if (!gp)
+            break;
+
+        /* Yep, this is a grandchild.  Move up one generation and try again */
+        temp = parent;
+    }
+    while (TRUE);
+
+    /* Ok, at this point temp points to the most senior child and parent
+     * should point to the top taxtable (and gp should be NULL).  If
+     * parent is NULL then we are the most senior child (and have no
+     * children), so do nothing.  If temp == table then there is no
+     * grandparent, so do nothing.
+     *
+     * Do something if parent != NULL && temp != table
+     */
+    g_assert (gp == NULL);
+
+    /* return the most senior table */
+    return temp;
+}
+
+/* build a list of tax tables that are grandchildren or bogus (empty entry list). */
+static void
+taxtable_scrub_cb (QofInstance * table_p, gpointer list_p)
+{
+    GncTaxTable *table = GNC_TAXTABLE(table_p);
+    GList **list = list_p;
+
+    if (taxtable_is_grandchild(table) || gncTaxTableGetEntries(table) == NULL)
+        *list = g_list_prepend(*list, table);
+}
+
+/* for each entry, check the tax tables.  If the tax tables are
+ * grandchildren, then fix them to point to the most senior child
+ */
+static void
+taxtable_scrub_entries (QofInstance * entry_p, gpointer ht_p)
+{
+    GHashTable *ht = ht_p;
+    GncEntry *entry = GNC_ENTRY(entry_p);
+    GncTaxTable *table, *new_tt;
+    gint32 count;
+
+    table = gncEntryGetInvTaxTable(entry);
+    if (table)
+    {
+        if (taxtable_is_grandchild(table))
+        {
+            PINFO("Fixing i-taxtable on entry %s\n",
+                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(entry))));
+            new_tt = taxtable_find_senior(table);
+            gncEntryBeginEdit(entry);
+            gncEntrySetInvTaxTable(entry, new_tt);
+            gncEntryCommitEdit(entry);
+            table = new_tt;
+        }
+        if (table)
+        {
+            count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
+            count++;
+            g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
+        }
+    }
+
+    table = gncEntryGetBillTaxTable(entry);
+    if (table)
+    {
+        if (taxtable_is_grandchild(table))
+        {
+            PINFO("Fixing b-taxtable on entry %s\n",
+                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(entry))));
+            new_tt = taxtable_find_senior(table);
+            gncEntryBeginEdit(entry);
+            gncEntrySetBillTaxTable(entry, new_tt);
+            gncEntryCommitEdit(entry);
+            table = new_tt;
+        }
+        if (table)
+        {
+            count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
+            count++;
+            g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
+        }
+    }
+}
+
+static void
+taxtable_scrub_cust (QofInstance * cust_p, gpointer ht_p)
+{
+    GHashTable *ht = ht_p;
+    GncCustomer *cust = GNC_CUSTOMER(cust_p);
+    GncTaxTable *table;
+    gint32 count;
+
+    table = gncCustomerGetTaxTable(cust);
+    if (table)
+    {
+        count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
+        count++;
+        g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
+    }
+}
+
+static void
+taxtable_scrub_vendor (QofInstance * vendor_p, gpointer ht_p)
+{
+    GHashTable *ht = ht_p;
+    GncVendor *vendor = GNC_VENDOR(vendor_p);
+    GncTaxTable *table;
+    gint32 count;
+
+    table = gncVendorGetTaxTable(vendor);
+    if (table)
+    {
+        count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
+        count++;
+        g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
+    }
+}
+
+static void
+taxtable_reset_refcount (gpointer key, gpointer value, gpointer notused)
+{
+    GncTaxTable *table = key;
+    gint32 count = GPOINTER_TO_INT(value);
+
+    if (count != gncTaxTableGetRefcount(table) && !gncTaxTableGetInvisible(table))
+    {
+        PWARN("Fixing refcount on taxtable %s (%" G_GINT64_FORMAT " -> %d)\n",
+              guid_to_string(qof_instance_get_guid(QOF_INSTANCE(table))),
+              gncTaxTableGetRefcount(table), count);
+        gncTaxTableSetRefcount(table, count);
+    }
+}
+
+static void
+taxtable_scrub (QofBook *book)
+{
+    GList *list = NULL;
+    GList *node;
+    GncTaxTable *parent, *table;
+    GHashTable *ht = g_hash_table_new(g_direct_hash, g_direct_equal);
+
+    qof_object_foreach (GNC_ID_ENTRY, book, taxtable_scrub_entries, ht);
+    qof_object_foreach (GNC_ID_CUSTOMER, book, taxtable_scrub_cust, ht);
+    qof_object_foreach (GNC_ID_VENDOR, book, taxtable_scrub_vendor, ht);
+    qof_object_foreach (GNC_ID_TAXTABLE, book, taxtable_scrub_cb, &list);
+
+    /* destroy the list of "grandchildren" tax tables */
+    for (node = list; node; node = node->next)
+    {
+        table = node->data;
+
+        PINFO ("deleting grandchild taxtable: %s\n",
+               guid_to_string(qof_instance_get_guid(QOF_INSTANCE(table))));
+
+        /* Make sure the parent has no children */
+        parent = gncTaxTableGetParent(table);
+        gncTaxTableSetChild(parent, NULL);
+
+        /* Destroy this tax table */
+        gncTaxTableBeginEdit(table);
+        gncTaxTableDestroy(table);
+    }
+
+    /* reset the refcounts as necessary */
+    g_hash_table_foreach(ht, taxtable_reset_refcount, NULL);
+
+    g_list_free(list);
+    g_hash_table_destroy(ht);
+}
+
+static gboolean
+taxtable_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return
+        gnc_xml2_write_namespace_decl(out, "taxtable")
+        && gnc_xml2_write_namespace_decl(out, "tte");
+}
+
+void
+gnc_taxtable_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_taxtable_string,
+        taxtable_sixtp_parser_create,
+        NULL,			/* add_item */
+        taxtable_get_count,
+        taxtable_write,
+        taxtable_scrub,
+        taxtable_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-tax-table-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-tax-table-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-tax-table-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,29 @@
+/*
+ * gnc-tax-table-xml-v2.h -- tax table xml i/o parser/unparsers
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_TAXTABLE_XML_V2_H
+#define GNC_TAXTABLE_XML_V2_H
+
+void gnc_taxtable_xml_initialize (void);
+
+#endif /* GNC_TAXTABLE_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/gnc-vendor-xml-v2.c (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.c)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-vendor-xml-v2.c	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-vendor-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,489 @@
+/********************************************************************\
+ * gnc-vendor-xml-v2.c -- vendor xml i/o implementation         *
+ *                                                                  *
+ * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
+ *                                                                  *
+ * This program is free software; you can redistribute it and/or    *
+ * modify it under the terms of the GNU General Public License as   *
+ * published by the Free Software Foundation; either version 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+ *                                                                  *
+\********************************************************************/
+
+#include "config.h"
+
+#include <glib.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "gnc-xml-helper.h"
+
+#include "sixtp.h"
+#include "sixtp-utils.h"
+#include "sixtp-parsers.h"
+#include "sixtp-utils.h"
+#include "sixtp-dom-parsers.h"
+#include "sixtp-dom-generators.h"
+
+#include "gnc-xml.h"
+#include "io-gncxml-gen.h"
+#include "io-gncxml-v2.h"
+
+#include "gncBillTermP.h"
+#include "gncVendorP.h"
+#include "gncTaxTableP.h"
+#include "gnc-vendor-xml-v2.h"
+#include "gnc-address-xml-v2.h"
+#include "xml-helpers.h"
+#include "gnc-bill-term-xml-v2.h"
+
+#define _GNC_MOD_NAME	GNC_ID_VENDOR
+
+static QofLogModule log_module = GNC_MOD_IO;
+
+const gchar *vendor_version_string = "2.0.0";
+
+/* ids */
+#define gnc_vendor_string "gnc:GncVendor"
+#define vendor_name_string "vendor:name"
+#define vendor_guid_string "vendor:guid"
+#define vendor_id_string "vendor:id"
+#define vendor_addr_string "vendor:addr"
+#define vendor_notes_string "vendor:notes"
+#define vendor_terms_string "vendor:terms"
+#define vendor_taxincluded_string "vendor:taxincluded"
+#define vendor_active_string "vendor:active"
+#define vendor_currency_string "vendor:currency"
+#define vendor_taxtable_string "vendor:taxtable"
+#define vendor_taxtableoverride_string "vendor:use-tt"
+#define vendor_slots_string "vendor:slots"
+
+static xmlNodePtr
+vendor_dom_tree_create (GncVendor *vendor)
+{
+    xmlNodePtr ret, kvpnode;
+    GncBillTerm *term;
+    GncTaxTable *taxtable;
+
+    ret = xmlNewNode(NULL, BAD_CAST gnc_vendor_string);
+    xmlSetProp(ret, BAD_CAST "version", BAD_CAST vendor_version_string);
+
+    xmlAddChild(ret, guid_to_dom_tree(vendor_guid_string,
+                                      qof_instance_get_guid (QOF_INSTANCE(vendor))));
+
+    xmlAddChild(ret, text_to_dom_tree(vendor_name_string,
+                                      gncVendorGetName (vendor)));
+
+    xmlAddChild(ret, text_to_dom_tree(vendor_id_string,
+                                      gncVendorGetID (vendor)));
+
+    xmlAddChild(ret, gnc_address_to_dom_tree(vendor_addr_string,
+                gncVendorGetAddr (vendor)));
+
+    maybe_add_string (ret, vendor_notes_string, gncVendorGetNotes (vendor));
+
+    term = gncVendorGetTerms (vendor);
+    if (term)
+        xmlAddChild(ret, guid_to_dom_tree(vendor_terms_string,
+                                          qof_instance_get_guid(QOF_INSTANCE(term))));
+
+    xmlAddChild(ret, text_to_dom_tree(vendor_taxincluded_string,
+                                      gncTaxIncludedTypeToString (
+                                          gncVendorGetTaxIncluded (vendor))));
+
+    xmlAddChild(ret, int_to_dom_tree(vendor_active_string,
+                                     gncVendorGetActive (vendor)));
+
+    xmlAddChild
+    (ret,
+     commodity_ref_to_dom_tree(vendor_currency_string,
+                               gncVendorGetCurrency (vendor)));
+
+    xmlAddChild (ret, int_to_dom_tree (vendor_taxtableoverride_string,
+                                       gncVendorGetTaxTableOverride (vendor)));
+    taxtable = gncVendorGetTaxTable (vendor);
+    if (taxtable)
+        xmlAddChild (ret, guid_to_dom_tree (vendor_taxtable_string,
+                                            qof_instance_get_guid(QOF_INSTANCE(taxtable))));
+
+    kvpnode = kvp_frame_to_dom_tree (vendor_slots_string,
+                                     qof_instance_get_slots (QOF_INSTANCE(vendor)));
+    if (kvpnode) xmlAddChild (ret, kvpnode);
+
+    return ret;
+}
+
+/***********************************************************************/
+
+struct vendor_pdata
+{
+    GncVendor *vendor;
+    QofBook *book;
+};
+
+static gboolean
+set_string(xmlNodePtr node, GncVendor* vendor,
+           void (*func)(GncVendor *vendor, const char *txt))
+{
+    char* txt = dom_tree_to_text(node);
+    g_return_val_if_fail(txt, FALSE);
+
+    func(vendor, txt);
+
+    g_free(txt);
+
+    return TRUE;
+}
+
+static gboolean
+set_boolean(xmlNodePtr node, GncVendor* vendor,
+            void (*func)(GncVendor* vendor, gboolean b))
+{
+    gint64 val;
+    gboolean ret;
+
+    ret = dom_tree_to_integer(node, &val);
+    if (ret)
+        func(vendor, (gboolean)val);
+
+    return ret;
+}
+
+static gboolean
+vendor_name_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+
+    return set_string(node, pdata->vendor, gncVendorSetName);
+}
+
+static gboolean
+vendor_guid_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+    GncGUID *guid;
+    GncVendor *vendor;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail(guid, FALSE);
+    vendor = gncVendorLookup (pdata->book, guid);
+    if (vendor)
+    {
+        gncVendorDestroy (pdata->vendor);
+        pdata->vendor = vendor;
+        gncVendorBeginEdit (vendor);
+    }
+    else
+    {
+        gncVendorSetGUID(pdata->vendor, guid);
+    }
+
+    g_free(guid);
+
+    return TRUE;
+}
+
+static gboolean
+vendor_id_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+
+    return set_string(node, pdata->vendor, gncVendorSetID);
+}
+
+static gboolean
+vendor_notes_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+
+    return set_string(node, pdata->vendor, gncVendorSetNotes);
+}
+
+static gboolean
+vendor_terms_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+    GncGUID *guid;
+    GncBillTerm *term;
+
+    guid = dom_tree_to_guid(node);
+    g_return_val_if_fail (guid, FALSE);
+    term = gnc_billterm_xml_find_or_create(pdata->book, guid);
+    g_assert(term);
+    g_free (guid);
+    gncVendorSetTerms (pdata->vendor, term);
+
+    return TRUE;
+}
+
+static gboolean
+vendor_addr_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+
+    return gnc_dom_tree_to_address (node, gncVendorGetAddr(pdata->vendor));
+}
+
+static gboolean
+vendor_taxincluded_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+    GncTaxIncluded type;
+    char *str;
+    gboolean ret;
+
+    str = dom_tree_to_text (node);
+    g_return_val_if_fail (str, FALSE);
+
+    ret = gncTaxIncludedStringToType (str, &type);
+    g_free (str);
+
+    if (ret)
+        gncVendorSetTaxIncluded(pdata->vendor, type);
+
+    return ret;
+}
+
+static gboolean
+vendor_active_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+    return set_boolean (node, pdata->vendor, gncVendorSetActive);
+}
+
+static gboolean
+vendor_currency_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+    gnc_commodity *com;
+
+    com = dom_tree_to_commodity_ref(node, pdata->book);
+    g_return_val_if_fail (com, FALSE);
+
+    gncVendorSetCurrency (pdata->vendor, com);
+
+    return TRUE;
+}
+
+static gboolean
+vendor_taxtable_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+    GncGUID *guid;
+    GncTaxTable *taxtable;
+
+    guid = dom_tree_to_guid (node);
+    g_return_val_if_fail (guid, FALSE);
+    taxtable = gncTaxTableLookup (pdata->book, guid);
+    if (!taxtable)
+    {
+        taxtable = gncTaxTableCreate (pdata->book);
+        gncTaxTableBeginEdit (taxtable);
+        gncTaxTableSetGUID (taxtable, guid);
+        gncTaxTableCommitEdit (taxtable);
+    }
+    else
+        gncTaxTableDecRef (taxtable);
+
+    gncVendorSetTaxTable (pdata->vendor, taxtable);
+    g_free(guid);
+    return TRUE;
+}
+
+static gboolean
+vendor_taxtableoverride_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+    return set_boolean (node, pdata->vendor, gncVendorSetTaxTableOverride);
+}
+
+static gboolean
+vendor_slots_handler (xmlNodePtr node, gpointer vendor_pdata)
+{
+    struct vendor_pdata *pdata = vendor_pdata;
+    return dom_tree_to_kvp_frame_given (
+               node, qof_instance_get_slots (QOF_INSTANCE(pdata->vendor)));
+
+}
+
+static struct dom_tree_handler vendor_handlers_v2[] =
+{
+    { vendor_name_string, vendor_name_handler, 1, 0 },
+    { vendor_guid_string, vendor_guid_handler, 1, 0 },
+    { vendor_id_string, vendor_id_handler, 1, 0 },
+    { vendor_addr_string, vendor_addr_handler, 1, 0 },
+    { vendor_notes_string, vendor_notes_handler, 0, 0 },
+    { vendor_terms_string, vendor_terms_handler, 0, 0 },
+    { vendor_taxincluded_string, vendor_taxincluded_handler, 1, 0 },
+    { vendor_active_string, vendor_active_handler, 1, 0 },
+    { vendor_currency_string, vendor_currency_handler, 0, 0 }, /* XXX */
+    { "vendor:commodity", vendor_currency_handler, 0, 0 }, /* XXX */
+    { vendor_taxtable_string, vendor_taxtable_handler, 0, 0 },
+    { vendor_taxtableoverride_string, vendor_taxtableoverride_handler, 0, 0 },
+    { vendor_slots_string, vendor_slots_handler, 0, 0 },
+    { NULL, 0, 0, 0 }
+};
+
+static GncVendor*
+dom_tree_to_vendor (xmlNodePtr node, QofBook *book)
+{
+    struct vendor_pdata vendor_pdata;
+    gboolean successful;
+
+    vendor_pdata.vendor = gncVendorCreate(book);
+    vendor_pdata.book = book;
+    gncVendorBeginEdit (vendor_pdata.vendor);
+
+    successful = dom_tree_generic_parse (node, vendor_handlers_v2,
+                                         &vendor_pdata);
+
+    if (successful)
+        gncVendorCommitEdit (vendor_pdata.vendor);
+    else
+    {
+        PERR ("failed to parse vendor tree");
+        gncVendorDestroy (vendor_pdata.vendor);
+        vendor_pdata.vendor = NULL;
+    }
+
+    return vendor_pdata.vendor;
+}
+
+static gboolean
+gnc_vendor_end_handler(gpointer data_for_children,
+                       GSList* data_from_children, GSList* sibling_data,
+                       gpointer parent_data, gpointer global_data,
+                       gpointer *result, const gchar *tag)
+{
+    int successful;
+    GncVendor *vendor;
+    xmlNodePtr tree = (xmlNodePtr)data_for_children;
+    gxpf_data *gdata = (gxpf_data*)global_data;
+    QofBook *book = gdata->bookdata;
+
+    successful = TRUE;
+
+    if (parent_data)
+    {
+        return TRUE;
+    }
+
+    /* OK.  For some messed up reason this is getting called again with a
+       NULL tag.  So we ignore those cases */
+    if (!tag)
+    {
+        return TRUE;
+    }
+
+    g_return_val_if_fail(tree, FALSE);
+
+    vendor = dom_tree_to_vendor(tree, book);
+    if (vendor != NULL)
+    {
+        gdata->cb(tag, gdata->parsedata, vendor);
+    }
+
+    xmlFreeNode(tree);
+
+    return vendor != NULL;
+}
+
+static sixtp *
+vendor_sixtp_parser_create(void)
+{
+    return sixtp_dom_parser_new(gnc_vendor_end_handler, NULL, NULL);
+}
+
+static gboolean
+vendor_should_be_saved (GncVendor *vendor)
+{
+    const char *id;
+
+    /* make sure this is a valid vendor before we save it -- should have an ID */
+    id = gncVendorGetID (vendor);
+    if (id == NULL || *id == '\0')
+        return FALSE;
+
+    return TRUE;
+}
+
+static void
+do_count (QofInstance * vendor_p, gpointer count_p)
+{
+    int *count = count_p;
+    if (vendor_should_be_saved ((GncVendor *)vendor_p))
+        (*count)++;
+}
+
+static int
+vendor_get_count (QofBook *book)
+{
+    int count = 0;
+    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
+    return count;
+}
+
+static void
+xml_add_vendor (QofInstance * vendor_p, gpointer out_p)
+{
+    xmlNodePtr node;
+    GncVendor *vendor = (GncVendor *) vendor_p;
+    FILE *out = out_p;
+
+    if (ferror(out))
+        return;
+    if (!vendor_should_be_saved (vendor))
+        return;
+
+    node = vendor_dom_tree_create (vendor);
+    xmlElemDump(out, NULL, node);
+    xmlFreeNode (node);
+    if (ferror(out) || fprintf(out, "\n") < 0)
+        return;
+}
+
+static gboolean
+vendor_write (FILE *out, QofBook *book)
+{
+    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_vendor, (gpointer) out);
+    return ferror(out) == 0;
+}
+
+static gboolean
+vendor_ns(FILE *out)
+{
+    g_return_val_if_fail(out, FALSE);
+    return gnc_xml2_write_namespace_decl(out, "vendor");
+}
+
+void
+gnc_vendor_xml_initialize (void)
+{
+    static GncXmlDataType_t be_data =
+    {
+        GNC_FILE_BACKEND_VERS,
+        gnc_vendor_string,
+        vendor_sixtp_parser_create,
+        NULL,			/* add_item */
+        vendor_get_count,
+        vendor_write,
+        NULL,			/* scrub */
+        vendor_ns,
+    };
+
+    qof_object_register_backend (_GNC_MOD_NAME,
+                                 GNC_FILE_BACKEND,
+                                 &be_data);
+}

Copied: gnucash/trunk/src/backend/xml/gnc-vendor-xml-v2.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.h)
===================================================================
--- gnucash/trunk/src/backend/xml/gnc-vendor-xml-v2.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/gnc-vendor-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,29 @@
+/*
+ * gnc-vendor-xml-v2.h -- vendor xml i/o parser/unparsers
+ *
+ * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, contact:
+ *
+ * Free Software Foundation           Voice:  +1-617-542-5942
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org
+ */
+
+#ifndef GNC_VENDOR_XML_V2_H
+#define GNC_VENDOR_XML_V2_H
+
+void gnc_vendor_xml_initialize (void);
+
+#endif /* GNC_VENDOR_XML_V2_H */

Copied: gnucash/trunk/src/backend/xml/xml-helpers.h (from rev 19360, gnucash/trunk/src/business/business-core/xml/xml-helpers.h)
===================================================================
--- gnucash/trunk/src/backend/xml/xml-helpers.h	                        (rev 0)
+++ gnucash/trunk/src/backend/xml/xml-helpers.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -0,0 +1,34 @@
+
+/* xml-helpers.h
+ * Miscellaneous bogus helper routines.
+ */
+
+static inline void
+maybe_add_int (xmlNodePtr ptr, const char *tag, gint val)
+{
+    if (val)
+        xmlAddChild (ptr, int_to_dom_tree (tag, val));
+}
+
+static inline void
+maybe_add_numeric (xmlNodePtr ptr, const char *tag, gnc_numeric val)
+{
+    if (!gnc_numeric_zero_p (val))
+        xmlAddChild (ptr, gnc_numeric_to_dom_tree (tag, &val));
+}
+
+static inline void
+maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
+{
+    if (str && strlen(str) > 0)
+        xmlAddChild (ptr, text_to_dom_tree (tag, str));
+}
+
+static inline void
+maybe_add_guid (xmlNodePtr ptr, const char *tag, QofInstance *inst)
+{
+    if (inst)
+        xmlAddChild (ptr, guid_to_dom_tree (tag,
+                                            qof_instance_get_guid (inst)));
+}
+

Deleted: gnucash/trunk/src/business/business-core/CMakeLists.txt
===================================================================
--- gnucash/trunk/src/business/business-core/CMakeLists.txt	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/CMakeLists.txt	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,48 +0,0 @@
-# CMakeLists.txt for src/business/business-code
-
-ADD_DEFINITIONS (-DG_LOG_DOMAIN=\"gnc.business.core\")
-
-INCLUDE_DIRECTORIES (${GLIB2_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${GCONF2_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${LIBINTL_INCLUDE_PATH})
-INCLUDE_DIRECTORIES (${REGEX_INCLUDE_PATH})
-INCLUDE_DIRECTORIES (${GUILE_INCLUDE_DIRS})
-INCLUDE_DIRECTORIES (${LIBXML2_INCLUDE_DIR})
-INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src ) # for config.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src ) # for gnc-ui.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/gnc-module )
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/engine )
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/libqof/qof) # for qof.h
-INCLUDE_DIRECTORIES (${CMAKE_BINARY_DIR}/src/engine) # for swig-runtime.h
-INCLUDE_DIRECTORIES (${CMAKE_SOURCE_DIR}/src/backend/xml) # for io-gncxml-v2.h
-INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR}) # when building swig-core-utils.c
-INCLUDE_DIRECTORIES (${CMAKE_CURRENT_BINARY_DIR}) # for gncla-dir.h
-
-SET (libgnc_business_core_SOURCES
-  gncmod-business-core.c
-)
-
-SET (libgnc_business_core_xml_SOURCES
-  xml/gnc-address-xml-v2.c
-  xml/gnc-bill-term-xml-v2.c
-  xml/gnc-customer-xml-v2.c
-  xml/gnc-employee-xml-v2.c
-  xml/gnc-entry-xml-v2.c
-  xml/gnc-invoice-xml-v2.c
-  xml/gnc-job-xml-v2.c
-  xml/gnc-order-xml-v2.c
-  xml/gnc-owner-xml-v2.c
-  xml/gnc-tax-table-xml-v2.c
-  xml/gnc-vendor-xml-v2.c
-  xml/gncmod-business-backend-xml.c
-)
-
-SET (libgnc_business_core_HEADERS
-)
-
-ADD_LIBRARY (business-core
-  ${libgnc_business_core_SOURCES}
-  ${libgnc_business_core_HEADERS}
-  ${libgnc_business_core_xml_SOURCES}
-)
-

Modified: gnucash/trunk/src/business/business-core/xml/Makefile.am
===================================================================
--- gnucash/trunk/src/business/business-core/xml/Makefile.am	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/Makefile.am	2010-07-13 09:55:46 UTC (rev 19361)
@@ -13,34 +13,9 @@
   ${LIBXML2_CFLAGS} \
   ${GLIB_CFLAGS}
 
-libgncmod_business_backend_xml_la_SOURCES = \
-  gncmod-business-backend-xml.c \
-  gnc-address-xml-v2.c \
-  gnc-bill-term-xml-v2.c \
-  gnc-customer-xml-v2.c \
-  gnc-employee-xml-v2.c \
-  gnc-entry-xml-v2.c \
-  gnc-invoice-xml-v2.c \
-  gnc-job-xml-v2.c \
-  gnc-order-xml-v2.c \
-  gnc-owner-xml-v2.c \
-  gnc-tax-table-xml-v2.c \
-  gnc-vendor-xml-v2.c
+libgncmod_business_backend_xml_la_SOURCES =
 
-noinst_HEADERS = \
-  gncmod-business-backend-xml.h \
-  gnc-address-xml-v2.h \
-  gnc-bill-term-xml-v2.h \
-  gnc-customer-xml-v2.h \
-  gnc-employee-xml-v2.h \
-  gnc-entry-xml-v2.h \
-  gnc-invoice-xml-v2.h \
-  gnc-job-xml-v2.h \
-  gnc-order-xml-v2.h \
-  gnc-owner-xml-v2.h \
-  gnc-tax-table-xml-v2.h \
-  gnc-vendor-xml-v2.h \
-  xml-helpers.h
+noinst_HEADERS =
 
 libgncmod_business_backend_xml_la_LDFLAGS = -module -avoid-version
 

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,239 +0,0 @@
-/********************************************************************\
- * gnc-address-xml-v2.c -- address xml i/o implementation           *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gnc-address-xml-v2.h"
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *address_version_string = "2.0.0";
-
-/* ids */
-#define addr_name_string	"addr:name"
-#define addr_addr1_string	"addr:addr1"
-#define addr_addr2_string	"addr:addr2"
-#define addr_addr3_string	"addr:addr3"
-#define addr_addr4_string	"addr:addr4"
-#define addr_phone_string	"addr:phone"
-#define addr_fax_string		"addr:fax"
-#define addr_email_string	"addr:email"
-#define addr_slots_string	"addr:slots"
-
-static void
-maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
-{
-    if (str && strlen(str) > 0)
-        xmlAddChild (ptr, text_to_dom_tree (tag, str));
-}
-
-xmlNodePtr
-gnc_address_to_dom_tree (const char *tag, GncAddress *addr)
-{
-    xmlNodePtr ret;
-
-    ret = xmlNewNode(NULL, BAD_CAST tag);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST address_version_string);
-
-    maybe_add_string (ret, addr_name_string, gncAddressGetName (addr));
-
-    maybe_add_string (ret, addr_addr1_string, gncAddressGetAddr1 (addr));
-    maybe_add_string (ret, addr_addr2_string, gncAddressGetAddr2 (addr));
-    maybe_add_string (ret, addr_addr3_string, gncAddressGetAddr3 (addr));
-    maybe_add_string (ret, addr_addr4_string, gncAddressGetAddr4 (addr));
-
-    maybe_add_string (ret, addr_phone_string, gncAddressGetPhone (addr));
-    maybe_add_string (ret, addr_fax_string, gncAddressGetFax (addr));
-    maybe_add_string (ret, addr_email_string, gncAddressGetEmail (addr));
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct address_pdata
-{
-    GncAddress *address;
-};
-
-static gboolean
-set_string(xmlNodePtr node, GncAddress* addr,
-           void (*func)(GncAddress *addr, const char *txt))
-{
-    gchar* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    func(addr, txt);
-
-    g_free(txt);
-
-    return TRUE;
-}
-
-static gboolean
-address_name_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    struct address_pdata *pdata = addr_pdata;
-
-    return set_string(node, pdata->address, gncAddressSetName);
-}
-
-static gboolean
-address_addr1_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    struct address_pdata *pdata = addr_pdata;
-
-    return set_string(node, pdata->address, gncAddressSetAddr1);
-}
-
-static gboolean
-address_addr2_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    struct address_pdata *pdata = addr_pdata;
-
-    return set_string(node, pdata->address, gncAddressSetAddr2);
-}
-
-static gboolean
-address_addr3_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    struct address_pdata *pdata = addr_pdata;
-
-    return set_string(node, pdata->address, gncAddressSetAddr3);
-}
-
-static gboolean
-address_addr4_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    struct address_pdata *pdata = addr_pdata;
-
-    return set_string(node, pdata->address, gncAddressSetAddr4);
-}
-
-static gboolean
-address_phone_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    struct address_pdata *pdata = addr_pdata;
-
-    return set_string(node, pdata->address, gncAddressSetPhone);
-}
-
-static gboolean
-address_fax_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    struct address_pdata *pdata = addr_pdata;
-
-    return set_string(node, pdata->address, gncAddressSetFax);
-}
-
-static gboolean
-address_email_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    struct address_pdata *pdata = addr_pdata;
-
-    return set_string(node, pdata->address, gncAddressSetEmail);
-}
-
-static gboolean
-address_slots_handler (xmlNodePtr node, gpointer addr_pdata)
-{
-    return TRUE;
-}
-
-static struct dom_tree_handler address_handlers_v2[] =
-{
-    { addr_name_string, address_name_handler, 0, 0 },
-    { addr_addr1_string, address_addr1_handler, 0, 0 },
-    { addr_addr2_string, address_addr2_handler, 0, 0 },
-    { addr_addr3_string, address_addr3_handler, 0, 0 },
-    { addr_addr4_string, address_addr4_handler, 0, 0 },
-    { addr_phone_string, address_phone_handler, 0, 0 },
-    { addr_fax_string, address_fax_handler, 0, 0 },
-    { addr_email_string, address_email_handler, 0, 0 },
-    { addr_slots_string, address_slots_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-gboolean
-gnc_dom_tree_to_address (xmlNodePtr node, GncAddress *address)
-{
-    struct address_pdata addr_pdata;
-    gboolean successful;
-
-    addr_pdata.address = address;
-
-    successful = dom_tree_generic_parse (node, address_handlers_v2,
-                                         &addr_pdata);
-
-    if (!successful)
-    {
-        PERR ("failed to parse address tree");
-    }
-
-    return successful;
-}
-
-static gboolean
-address_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "addr");
-}
-
-void
-gnc_address_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        "gnc:Address",
-        NULL,			/* parser_create */
-        NULL,			/* add_item */
-        NULL,			/* get_count */
-        NULL,			/* write */
-        NULL,			/* scrub */
-        address_ns,
-    };
-
-    qof_object_register_backend ("gnc:Address",
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-address-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,32 +0,0 @@
-/* gnc-address-xml-v2.h -- Address XML header
- *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_ADDRESS_XML_V2_H
-#define GNC_ADDRESS_XML_V2_H
-
-#include "gncAddress.h"
-
-gboolean   gnc_dom_tree_to_address (xmlNodePtr node, GncAddress *address);
-xmlNodePtr gnc_address_to_dom_tree (const char *tag, GncAddress *addr);
-void gnc_address_xml_initialize (void);
-
-#endif /* GNC_ADDRESS_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,792 +0,0 @@
-/********************************************************************\
- * gnc-bill-term-xml-v2.c -- billing term xml i/o implementation    *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncBillTermP.h"
-#include "gncInvoice.h"
-#include "gnc-bill-term-xml-v2.h"
-#include "qof.h"
-
-#include "xml-helpers.h"
-
-#define _GNC_MOD_NAME	GNC_ID_BILLTERM
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *billterm_version_string = "2.0.0";
-
-/* ids */
-#define gnc_billterm_string "gnc:GncBillTerm"
-#define billterm_guid_string "billterm:guid"
-#define billterm_name_string "billterm:name"
-#define billterm_desc_string "billterm:desc"
-#define billterm_refcount_string "billterm:refcount"
-#define billterm_invisible_string "billterm:invisible"
-#define billterm_parent_string "billterm:parent"
-#define billterm_child_string "billterm:child"
-#define billterm_slots_string "billterm:slots"
-
-#define gnc_daystype_string "billterm:days"
-#define days_duedays_string "bt-days:due-days"
-#define days_discdays_string "bt-days:disc-days"
-#define days_discount_string "bt-days:discount"
-
-#define gnc_proximotype_string "billterm:proximo"
-#define prox_dueday_string "bt-prox:due-day"
-#define prox_discday_string "bt-prox:disc-day"
-#define prox_discount_string "bt-prox:discount"
-#define prox_cutoff_string "bt-prox:cutoff-day"
-
-static xmlNodePtr
-billterm_dom_tree_create (GncBillTerm *term)
-{
-    xmlNodePtr ret, data, kvpnode;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_billterm_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST billterm_version_string);
-
-    maybe_add_guid(ret, billterm_guid_string, QOF_INSTANCE(term));
-    xmlAddChild(ret, text_to_dom_tree (billterm_name_string,
-                                       gncBillTermGetName (term)));
-    xmlAddChild(ret, text_to_dom_tree (billterm_desc_string,
-                                       gncBillTermGetDescription (term)));
-
-    xmlAddChild(ret, int_to_dom_tree (billterm_refcount_string,
-                                      gncBillTermGetRefcount (term)));
-    xmlAddChild(ret, int_to_dom_tree (billterm_invisible_string,
-                                      gncBillTermGetInvisible (term)));
-
-    kvpnode = kvp_frame_to_dom_tree (billterm_slots_string,
-                                     qof_instance_get_slots (QOF_INSTANCE(term)));
-    if (kvpnode) xmlAddChild (ret, kvpnode);
-
-
-    /* We should not be our own child */
-    if (gncBillTermGetChild(term) != term)
-        maybe_add_guid(ret, billterm_child_string,
-                       QOF_INSTANCE(gncBillTermGetChild (term)));
-
-    maybe_add_guid(ret, billterm_parent_string,
-                   QOF_INSTANCE(gncBillTermGetParent (term)));
-
-    switch (gncBillTermGetType (term))
-    {
-    case GNC_TERM_TYPE_DAYS:
-        data = xmlNewChild (ret, NULL, BAD_CAST gnc_daystype_string, NULL);
-        maybe_add_int (data, days_duedays_string, gncBillTermGetDueDays (term));
-        maybe_add_int (data, days_discdays_string,
-                       gncBillTermGetDiscountDays (term));
-        maybe_add_numeric (data, days_discount_string,
-                           gncBillTermGetDiscount (term));
-        break;
-
-    case GNC_TERM_TYPE_PROXIMO:
-        data = xmlNewChild (ret, NULL, BAD_CAST gnc_proximotype_string, NULL);
-        maybe_add_int (data, prox_dueday_string, gncBillTermGetDueDays (term));
-        maybe_add_int (data, prox_discday_string,
-                       gncBillTermGetDiscountDays (term));
-        maybe_add_numeric (data, prox_discount_string,
-                           gncBillTermGetDiscount (term));
-        maybe_add_int (data, prox_cutoff_string, gncBillTermGetCutoff (term));
-        break;
-    }
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct billterm_pdata
-{
-    GncBillTerm *term;
-    QofBook *book;
-};
-
-static gboolean
-set_int (xmlNodePtr node, GncBillTerm *term,
-         void (*func)(GncBillTerm *, gint))
-{
-    gint64 val;
-    dom_tree_to_integer (node, &val);
-    func (term, val);
-    return TRUE;
-}
-
-static gboolean
-set_numeric (xmlNodePtr node, GncBillTerm *term,
-             void (*func)(GncBillTerm *, gnc_numeric))
-{
-    gnc_numeric* num = dom_tree_to_gnc_numeric (node);
-    g_return_val_if_fail (num, FALSE);
-
-    func (term, *num);
-    g_free (num);
-    return TRUE;
-}
-
-/***********************************************************************/
-
-static gboolean
-days_duedays_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_int (node, pdata->term, gncBillTermSetDueDays);
-}
-
-static gboolean
-days_discdays_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_int (node, pdata->term, gncBillTermSetDiscountDays);
-}
-
-static gboolean
-days_discount_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_numeric (node, pdata->term, gncBillTermSetDiscount);
-}
-
-static struct dom_tree_handler days_data_handlers_v2[] =
-{
-    { days_duedays_string, days_duedays_handler, 0, 0 },
-    { days_discdays_string, days_discdays_handler, 0, 0 },
-    { days_discount_string, days_discount_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static gboolean
-dom_tree_to_days_data (xmlNodePtr node, struct billterm_pdata *pdata)
-{
-    gboolean successful;
-
-    successful = dom_tree_generic_parse (node, days_data_handlers_v2, pdata);
-
-    if (!successful)
-        PERR ("failed to parse billing term days data");
-
-    return successful;
-}
-
-/***********************************************************************/
-
-static gboolean
-prox_dueday_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_int (node, pdata->term, gncBillTermSetDueDays);
-}
-
-static gboolean
-prox_discday_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_int (node, pdata->term, gncBillTermSetDiscountDays);
-}
-
-static gboolean
-prox_discount_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_numeric (node, pdata->term, gncBillTermSetDiscount);
-}
-
-static gboolean
-prox_cutoff_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_int (node, pdata->term, gncBillTermSetCutoff);
-}
-
-static struct dom_tree_handler prox_data_handlers_v2[] =
-{
-    { prox_dueday_string, prox_dueday_handler, 0, 0 },
-    { prox_discday_string, prox_discday_handler, 0, 0 },
-    { prox_discount_string, prox_discount_handler, 0, 0 },
-    { prox_cutoff_string, prox_cutoff_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static gboolean
-dom_tree_to_prox_data (xmlNodePtr node, struct billterm_pdata *pdata)
-{
-    gboolean successful;
-
-    successful = dom_tree_generic_parse (node, prox_data_handlers_v2, pdata);
-
-    if (!successful)
-        PERR ("failed to parse billing term prox data");
-
-    return successful;
-}
-
-/***********************************************************************/
-
-static gboolean
-set_parent_child (xmlNodePtr node, struct billterm_pdata *pdata,
-                  void (*func)(GncBillTerm *, GncBillTerm *))
-{
-    GncGUID *guid;
-    GncBillTerm *term;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    term = gncBillTermLookup (pdata->book, guid);
-    if (!term)
-    {
-        term = gncBillTermCreate (pdata->book);
-        gncBillTermBeginEdit (term);
-        gncBillTermSetGUID (term, guid);
-        gncBillTermCommitEdit (term);
-    }
-    g_free (guid);
-    g_return_val_if_fail (term, FALSE);
-    func (pdata->term, term);
-
-    return TRUE;
-}
-
-static gboolean
-set_string (xmlNodePtr node, GncBillTerm *term,
-            void (*func)(GncBillTerm *, const char *))
-{
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-    func (term, txt);
-    g_free(txt);
-    return TRUE;
-}
-
-static gboolean
-billterm_guid_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    GncGUID *guid;
-    GncBillTerm *term;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    term = gncBillTermLookup (pdata->book, guid);
-    if (term)
-    {
-        gncBillTermDestroy (pdata->term);
-        pdata->term = term;
-        gncBillTermBeginEdit (term);
-    }
-    else
-    {
-        gncBillTermSetGUID(pdata->term, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-billterm_name_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_string (node, pdata->term, gncBillTermSetName);
-}
-
-static gboolean
-billterm_desc_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_string (node, pdata->term, gncBillTermSetDescription);
-}
-
-static gboolean
-billterm_refcount_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    gint64 val;
-
-    dom_tree_to_integer(node, &val);
-    gncBillTermSetRefcount (pdata->term, val);
-    return TRUE;
-}
-
-static gboolean
-billterm_invisible_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    gint64 val;
-
-    dom_tree_to_integer(node, &val);
-    if (val)
-        gncBillTermMakeInvisible (pdata->term);
-    return TRUE;
-}
-
-static gboolean
-billterm_parent_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_parent_child (node, pdata, gncBillTermSetParent);
-}
-
-static gboolean
-billterm_child_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return set_parent_child (node, pdata, gncBillTermSetChild);
-}
-
-static gboolean
-billterm_days_data_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-
-    g_return_val_if_fail (node, FALSE);
-    g_return_val_if_fail (gncBillTermGetType (pdata->term) == 0, FALSE);
-
-    gncBillTermSetType (pdata->term, GNC_TERM_TYPE_DAYS);
-    return dom_tree_to_days_data (node, pdata);
-}
-
-static gboolean
-billterm_prox_data_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-
-    g_return_val_if_fail (node, FALSE);
-    g_return_val_if_fail (gncBillTermGetType (pdata->term) == 0, FALSE);
-
-    gncBillTermSetType (pdata->term, GNC_TERM_TYPE_PROXIMO);
-    return dom_tree_to_prox_data (node, pdata);
-}
-
-static gboolean
-billterm_slots_handler (xmlNodePtr node, gpointer billterm_pdata)
-{
-    struct billterm_pdata *pdata = billterm_pdata;
-    return dom_tree_to_kvp_frame_given (node,
-                                        qof_instance_get_slots (QOF_INSTANCE(pdata->term)));
-}
-
-static struct dom_tree_handler billterm_handlers_v2[] =
-{
-    { billterm_guid_string, billterm_guid_handler, 1, 0 },
-    { billterm_name_string, billterm_name_handler, 1, 0 },
-    { billterm_desc_string, billterm_desc_handler, 1, 0 },
-    { billterm_refcount_string, billterm_refcount_handler, 1, 0 },
-    { billterm_invisible_string, billterm_invisible_handler, 1, 0 },
-    { billterm_parent_string, billterm_parent_handler, 0, 0 },
-    { billterm_child_string, billterm_child_handler, 0, 0 },
-    { billterm_slots_string, billterm_slots_handler, 0, 0 },
-    { gnc_daystype_string, billterm_days_data_handler, 0, 0 },
-    { gnc_proximotype_string, billterm_prox_data_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncBillTerm*
-dom_tree_to_billterm (xmlNodePtr node, QofBook *book)
-{
-    struct billterm_pdata billterm_pdata;
-    gboolean successful;
-
-    billterm_pdata.term = gncBillTermCreate (book);
-    billterm_pdata.book = book;
-    gncBillTermBeginEdit (billterm_pdata.term);
-
-    successful = dom_tree_generic_parse (node, billterm_handlers_v2,
-                                         &billterm_pdata);
-
-    if (successful)
-    {
-        gncBillTermCommitEdit (billterm_pdata.term);
-    }
-    else
-    {
-        PERR ("failed to parse billing term tree");
-        gncBillTermDestroy (billterm_pdata.term);
-        billterm_pdata.term = NULL;
-    }
-
-    return billterm_pdata.term;
-}
-
-static gboolean
-gnc_billterm_end_handler(gpointer data_for_children,
-                         GSList* data_from_children, GSList* sibling_data,
-                         gpointer parent_data, gpointer global_data,
-                         gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncBillTerm *term;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    term = dom_tree_to_billterm (tree, book);
-    if (term != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, term);
-    }
-
-    xmlFreeNode(tree);
-
-    return term != NULL;
-}
-
-static sixtp *
-billterm_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_billterm_end_handler, NULL, NULL);
-}
-
-static void
-do_count (QofInstance *term_p, gpointer count_p)
-{
-    int *count = count_p;
-    (*count)++;
-}
-
-static int
-billterm_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_billterm (QofInstance *term_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncBillTerm *term = (GncBillTerm *) term_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-
-    node = billterm_dom_tree_create (term);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-billterm_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_billterm, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-static gboolean
-billterm_is_grandchild (GncBillTerm *term)
-{
-    return (gncBillTermGetParent(gncBillTermGetParent(term)) != NULL);
-}
-
-static GncBillTerm *
-billterm_find_senior (GncBillTerm *term)
-{
-    GncBillTerm *temp, *parent, *gp = NULL;
-
-    temp = term;
-    do
-    {
-        /* See if "temp" is a grandchild */
-        parent = gncBillTermGetParent(temp);
-        if (!parent)
-            break;
-        gp = gncBillTermGetParent(parent);
-        if (!gp)
-            break;
-
-        /* Yep, this is a grandchild.  Move up one generation and try again */
-        temp = parent;
-    }
-    while (TRUE);
-
-    /* Ok, at this point temp points to the most senior child and parent
-     * should point to the top billterm (and gp should be NULL).  If
-     * parent is NULL then we are the most senior child (and have no
-     * children), so do nothing.  If temp == term then there is no
-     * grandparent, so do nothing.
-     *
-     * Do something if parent != NULL && temp != term
-     */
-    g_assert (gp == NULL);
-
-    /* return the most senior term */
-    return temp;
-}
-
-/* build a list of bill terms that are grandchildren or bogus (empty entry list). */
-static void
-billterm_scrub_cb (QofInstance *term_p, gpointer list_p)
-{
-    GncBillTerm *term = GNC_BILLTERM(term_p);
-    GList **list = list_p;
-
-    if (billterm_is_grandchild(term))
-    {
-        *list = g_list_prepend(*list, term);
-
-    }
-    else if (!gncBillTermGetType(term))
-    {
-        GncBillTerm *t = gncBillTermGetParent(term);
-        if (t)
-        {
-            /* Fix up the broken "copy" function */
-            PWARN("Fixing broken child billterm: %s",
-                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))));
-
-            gncBillTermBeginEdit(term);
-            gncBillTermSetType(term, gncBillTermGetType(t));
-            gncBillTermSetDueDays (term, gncBillTermGetDueDays(t));
-            gncBillTermSetDiscountDays (term, gncBillTermGetDiscountDays(t));
-            gncBillTermSetDiscount (term, gncBillTermGetDiscount(t));
-            gncBillTermSetCutoff (term, gncBillTermGetCutoff(t));
-            gncBillTermCommitEdit(term);
-
-        }
-        else
-        {
-            /* No parent?  Must be a standalone */
-            *list = g_list_prepend(*list, term);
-        }
-    }
-}
-
-/* for each invoice, check the bill terms.  If the bill terms are
- * grandchildren, then fix them to point to the most senior child
- */
-static void
-billterm_scrub_invoices (QofInstance * invoice_p, gpointer ht_p)
-{
-    GHashTable *ht = ht_p;
-    GncInvoice *invoice = GNC_INVOICE(invoice_p);
-    GncBillTerm *term, *new_bt;
-    gint32 count;
-
-    term = gncInvoiceGetTerms(invoice);
-    if (term)
-    {
-        if (billterm_is_grandchild(term))
-        {
-            PWARN("Fixing i-billterm on invoice %s\n",
-                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(invoice))));
-            new_bt = billterm_find_senior(term);
-            gncInvoiceBeginEdit(invoice);
-            gncInvoiceSetTerms(invoice, new_bt);
-            gncInvoiceCommitEdit(invoice);
-            term = new_bt;
-        }
-        if (term)
-        {
-            count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
-            count++;
-            g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
-        }
-    }
-}
-
-static void
-billterm_scrub_cust (QofInstance * cust_p, gpointer ht_p)
-{
-    GHashTable *ht = ht_p;
-    GncCustomer *cust = GNC_CUSTOMER(cust_p);
-    GncBillTerm *term;
-    gint32 count;
-
-    term = gncCustomerGetTerms(cust);
-    if (term)
-    {
-        count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
-        count++;
-        g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
-        if (billterm_is_grandchild(term))
-            PWARN("customer %s has grandchild billterm %s\n",
-                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(cust))),
-                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))));
-    }
-}
-
-static void
-billterm_scrub_vendor (QofInstance * vendor_p, gpointer ht_p)
-{
-    GHashTable *ht = ht_p;
-    GncVendor *vendor = GNC_VENDOR(vendor_p);
-    GncBillTerm *term;
-    gint32 count;
-
-    term = gncVendorGetTerms(vendor);
-    if (term)
-    {
-        count = GPOINTER_TO_INT(g_hash_table_lookup(ht, term));
-        count++;
-        g_hash_table_insert(ht, term, GINT_TO_POINTER(count));
-        if (billterm_is_grandchild(term))
-            PWARN("vendor %s has grandchild billterm %s\n",
-                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(vendor))),
-                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))));
-    }
-}
-
-static void
-billterm_reset_refcount (gpointer key, gpointer value, gpointer notused)
-{
-    GncBillTerm *term = key;
-    gint32 count = GPOINTER_TO_INT(value);
-
-    if (count != gncBillTermGetRefcount(term) && !gncBillTermGetInvisible(term))
-    {
-        PWARN("Fixing refcount on billterm %s (%" G_GINT64_FORMAT " -> %d)\n",
-              guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))),
-              gncBillTermGetRefcount(term), count);
-        gncBillTermSetRefcount(term, count);
-    }
-}
-
-static void
-billterm_scrub (QofBook *book)
-{
-    GList *list = NULL;
-    GList *node;
-    GncBillTerm *parent, *term;
-    GHashTable *ht = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-    DEBUG("scrubbing billterms...");
-    qof_object_foreach (GNC_ID_INVOICE,  book, billterm_scrub_invoices, ht);
-    qof_object_foreach (GNC_ID_CUSTOMER, book, billterm_scrub_cust, ht);
-    qof_object_foreach (GNC_ID_VENDOR,   book, billterm_scrub_vendor, ht);
-    qof_object_foreach (GNC_ID_BILLTERM, book, billterm_scrub_cb, &list);
-
-    /* destroy the list of "grandchildren" bill terms */
-    for (node = list; node; node = node->next)
-    {
-        term = node->data;
-
-        PWARN ("deleting grandchild billterm: %s\n",
-               guid_to_string(qof_instance_get_guid(QOF_INSTANCE(term))));
-
-        /* Make sure the parent has no children */
-        parent = gncBillTermGetParent(term);
-        gncBillTermSetChild(parent, NULL);
-
-        /* Destroy this bill term */
-        gncBillTermBeginEdit(term);
-        gncBillTermDestroy(term);
-    }
-
-    /* reset the refcounts as necessary */
-    g_hash_table_foreach(ht, billterm_reset_refcount, NULL);
-
-    g_list_free(list);
-    g_hash_table_destroy(ht);
-}
-
-static gboolean
-billterm_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return
-        gnc_xml2_write_namespace_decl(out, "billterm")
-        && gnc_xml2_write_namespace_decl(out, "bt-days")
-        && gnc_xml2_write_namespace_decl(out, "bt-prox");
-}
-
-void
-gnc_billterm_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_billterm_string,
-        billterm_sixtp_parser_create,
-        NULL,			/* add_item */
-        billterm_get_count,
-        billterm_write,
-        billterm_scrub,
-        billterm_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}
-
-GncBillTerm *
-gnc_billterm_xml_find_or_create(QofBook *book, GncGUID *guid)
-{
-    GncBillTerm *term;
-
-    g_return_val_if_fail(book, NULL);
-    g_return_val_if_fail(guid, NULL);
-    term = gncBillTermLookup(book, guid);
-    DEBUG("looking for billterm %s, found %p", guid_to_string(guid), term);
-    if (!term)
-    {
-        term = gncBillTermCreate(book);
-        gncBillTermBeginEdit(term);
-        gncBillTermSetGUID(term, guid);
-        gncBillTermCommitEdit(term);
-        DEBUG("Created term: %p", term);
-    }
-    else
-        gncBillTermDecRef(term);
-
-    return term;
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-bill-term-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,31 +0,0 @@
-/*
- * gnc-bill-term-xml-v2.h -- billing term xml i/o parser/unparsers
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_BILLTERM_XML_V2_H
-#define GNC_BILLTERM_XML_V2_H
-
-#include "gncBillTerm.h"
-void gnc_billterm_xml_initialize (void);
-GncBillTerm *gnc_billterm_xml_find_or_create(QofBook *book, GncGUID *guid);
-
-#endif /* GNC_BILLTERM_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,545 +0,0 @@
-/********************************************************************\
- * gnc-customer-xml-v2.c -- customer xml i/o implementation         *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncBillTermP.h"
-#include "gncCustomerP.h"
-#include "gncTaxTableP.h"
-#include "gnc-customer-xml-v2.h"
-#include "gnc-address-xml-v2.h"
-#include "gnc-bill-term-xml-v2.h"
-
-#include "xml-helpers.h"
-
-#define _GNC_MOD_NAME	GNC_ID_CUSTOMER
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *customer_version_string = "2.0.0";
-
-/* ids */
-#define gnc_customer_string "gnc:GncCustomer"
-#define cust_name_string "cust:name"
-#define cust_guid_string "cust:guid"
-#define cust_id_string "cust:id"
-#define cust_addr_string "cust:addr"
-#define cust_shipaddr_string "cust:shipaddr"
-#define cust_notes_string "cust:notes"
-#define cust_terms_string "cust:terms"
-#define cust_taxincluded_string "cust:taxincluded"
-#define cust_active_string "cust:active"
-#define cust_discount_string "cust:discount"
-#define cust_credit_string "cust:credit"
-#define cust_currency_string "cust:currency"
-#define cust_taxtable_string "cust:taxtable"
-#define cust_taxtableoverride_string "cust:use-tt"
-#define cust_slots_string "cust:slots"
-
-static xmlNodePtr
-customer_dom_tree_create (GncCustomer *cust)
-{
-    xmlNodePtr ret, kvpnode;
-    gnc_numeric num;
-    GncBillTerm *term;
-    GncTaxTable *taxtable;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_customer_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST customer_version_string);
-
-    xmlAddChild(ret, guid_to_dom_tree(cust_guid_string,
-                                      qof_instance_get_guid(QOF_INSTANCE(cust))));
-
-    xmlAddChild(ret, text_to_dom_tree(cust_name_string,
-                                      gncCustomerGetName (cust)));
-
-    xmlAddChild(ret, text_to_dom_tree(cust_id_string,
-                                      gncCustomerGetID (cust)));
-
-    xmlAddChild(ret, gnc_address_to_dom_tree(cust_addr_string,
-                gncCustomerGetAddr (cust)));
-
-    xmlAddChild(ret, gnc_address_to_dom_tree(cust_shipaddr_string,
-                gncCustomerGetShipAddr (cust)));
-
-    maybe_add_string (ret, cust_notes_string, gncCustomerGetNotes (cust));
-
-    term = gncCustomerGetTerms (cust);
-    if (term)
-        xmlAddChild(ret, guid_to_dom_tree(cust_terms_string,
-                                          qof_instance_get_guid (QOF_INSTANCE(term))));
-
-    xmlAddChild(ret, text_to_dom_tree(cust_taxincluded_string,
-                                      gncTaxIncludedTypeToString (
-                                          gncCustomerGetTaxIncluded (cust))));
-
-    xmlAddChild(ret, int_to_dom_tree(cust_active_string,
-                                     gncCustomerGetActive (cust)));
-
-    num = gncCustomerGetDiscount (cust);
-    xmlAddChild(ret, gnc_numeric_to_dom_tree(cust_discount_string, &num));
-
-    num = gncCustomerGetCredit (cust);
-    xmlAddChild(ret, gnc_numeric_to_dom_tree(cust_credit_string, &num));
-
-    xmlAddChild
-    (ret,
-     commodity_ref_to_dom_tree(cust_currency_string,
-                               gncCustomerGetCurrency (cust)));
-
-    xmlAddChild (ret, int_to_dom_tree (cust_taxtableoverride_string,
-                                       gncCustomerGetTaxTableOverride (cust)));
-    taxtable = gncCustomerGetTaxTable (cust);
-    if (taxtable)
-        xmlAddChild (ret, guid_to_dom_tree (cust_taxtable_string,
-                                            qof_instance_get_guid(QOF_INSTANCE(taxtable))));
-
-    kvpnode = kvp_frame_to_dom_tree (cust_slots_string,
-                                     qof_instance_get_slots (QOF_INSTANCE(cust)));
-    if (kvpnode) xmlAddChild (ret, kvpnode);
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct customer_pdata
-{
-    GncCustomer *customer;
-    QofBook *book;
-};
-
-static gboolean
-set_string(xmlNodePtr node, GncCustomer* cust,
-           void (*func)(GncCustomer *cust, const char *txt))
-{
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    func(cust, txt);
-
-    g_free(txt);
-
-    return TRUE;
-}
-
-static gboolean
-set_boolean(xmlNodePtr node, GncCustomer* cust,
-            void (*func)(GncCustomer* cust, gboolean b))
-{
-    gint64 val;
-    gboolean ret;
-
-    ret = dom_tree_to_integer(node, &val);
-    if (ret)
-        func(cust, (gboolean)val);
-
-    return ret;
-}
-
-static gboolean
-customer_name_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-
-    return set_string(node, pdata->customer, gncCustomerSetName);
-}
-
-static gboolean
-customer_guid_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    GncGUID *guid;
-    GncCustomer *cust;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail(guid, FALSE);
-    cust = gncCustomerLookup (pdata->book, guid);
-    if (cust)
-    {
-        gncCustomerDestroy (pdata->customer);
-        pdata->customer = cust;
-        gncCustomerBeginEdit (cust);
-    }
-    else
-    {
-        gncCustomerSetGUID(pdata->customer, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-customer_id_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-
-    return set_string(node, pdata->customer, gncCustomerSetID);
-}
-
-static gboolean
-customer_notes_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-
-    return set_string(node, pdata->customer, gncCustomerSetNotes);
-}
-
-static gboolean
-customer_terms_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    GncGUID *guid;
-    GncBillTerm *term;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    term = gnc_billterm_xml_find_or_create(pdata->book, guid);
-    g_assert(term);
-    g_free (guid);
-    gncCustomerSetTerms (pdata->customer, term);
-
-    return TRUE;
-}
-
-static gboolean
-customer_addr_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-
-    return gnc_dom_tree_to_address (node, gncCustomerGetAddr(pdata->customer));
-}
-
-static gboolean
-customer_shipaddr_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-
-    return gnc_dom_tree_to_address (node,
-                                    gncCustomerGetShipAddr(pdata->customer));
-}
-
-
-static gboolean
-customer_taxincluded_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    GncTaxIncluded type;
-    char *str;
-    gboolean ret;
-
-    str = dom_tree_to_text (node);
-    g_return_val_if_fail (str, FALSE);
-
-    ret = gncTaxIncludedStringToType (str, &type);
-    g_free (str);
-
-    if (ret)
-        gncCustomerSetTaxIncluded(pdata->customer, type);
-
-    return ret;
-}
-
-static gboolean
-customer_active_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    return set_boolean (node, pdata->customer, gncCustomerSetActive);
-}
-
-static gboolean
-customer_discount_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    gnc_numeric *val;
-
-    val = dom_tree_to_gnc_numeric(node);
-    g_return_val_if_fail(val, FALSE);
-
-    gncCustomerSetDiscount(pdata->customer, *val);
-    g_free (val);
-
-    return TRUE;
-}
-
-static gboolean
-customer_credit_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    gnc_numeric *val;
-
-    val = dom_tree_to_gnc_numeric(node);
-    g_return_val_if_fail(val, FALSE);
-
-    gncCustomerSetCredit(pdata->customer, *val);
-    g_free (val);
-
-    return TRUE;
-}
-
-static gboolean
-customer_currency_handler (xmlNodePtr node, gpointer customer_pdata)
-{
-    struct customer_pdata *pdata = customer_pdata;
-    gnc_commodity *com;
-
-    com = dom_tree_to_commodity_ref(node, pdata->book);
-    g_return_val_if_fail (com, FALSE);
-
-    gncCustomerSetCurrency (pdata->customer, com);
-
-    return TRUE;
-}
-
-static gboolean
-customer_taxtable_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    GncGUID *guid;
-    GncTaxTable *taxtable;
-
-    guid = dom_tree_to_guid (node);
-    g_return_val_if_fail (guid, FALSE);
-    taxtable = gncTaxTableLookup (pdata->book, guid);
-    if (!taxtable)
-    {
-        taxtable = gncTaxTableCreate (pdata->book);
-        gncTaxTableBeginEdit (taxtable);
-        gncTaxTableSetGUID (taxtable, guid);
-        gncTaxTableCommitEdit (taxtable);
-    }
-    else
-        gncTaxTableDecRef (taxtable);
-
-    gncCustomerSetTaxTable (pdata->customer, taxtable);
-    g_free(guid);
-    return TRUE;
-}
-
-static gboolean
-customer_taxtableoverride_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    return set_boolean (node, pdata->customer, gncCustomerSetTaxTableOverride);
-}
-
-static gboolean
-customer_slots_handler (xmlNodePtr node, gpointer cust_pdata)
-{
-    struct customer_pdata *pdata = cust_pdata;
-    return dom_tree_to_kvp_frame_given (node,
-                                        qof_instance_get_slots (QOF_INSTANCE(pdata->customer)));
-}
-
-static struct dom_tree_handler customer_handlers_v2[] =
-{
-    { cust_name_string, customer_name_handler, 1, 0 },
-    { cust_guid_string, customer_guid_handler, 1, 0 },
-    { cust_id_string, customer_id_handler, 1, 0 },
-    { cust_addr_string, customer_addr_handler, 1, 0 },
-    { cust_shipaddr_string, customer_shipaddr_handler, 1, 0 },
-    { cust_notes_string, customer_notes_handler, 0, 0 },
-    { cust_terms_string, customer_terms_handler, 0, 0 },
-    { cust_taxincluded_string, customer_taxincluded_handler, 1, 0 },
-    { cust_active_string, customer_active_handler, 1, 0 },
-    { cust_discount_string, customer_discount_handler, 1, 0 },
-    { cust_credit_string, customer_credit_handler, 1, 0 },
-    { cust_currency_string, customer_currency_handler, 0, 0 }, /* XXX */
-    { "cust:commodity", customer_currency_handler, 0, 0 }, /* XXX */
-    { cust_taxtable_string, customer_taxtable_handler, 0, 0 },
-    { cust_taxtableoverride_string, customer_taxtableoverride_handler, 0, 0 },
-    { cust_slots_string, customer_slots_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncCustomer*
-dom_tree_to_customer (xmlNodePtr node, QofBook *book)
-{
-    struct customer_pdata cust_pdata;
-    gboolean successful;
-
-    cust_pdata.customer = gncCustomerCreate(book);
-    cust_pdata.book = book;
-    gncCustomerBeginEdit (cust_pdata.customer);
-
-    successful = dom_tree_generic_parse (node, customer_handlers_v2,
-                                         &cust_pdata);
-
-    if (successful)
-        gncCustomerCommitEdit (cust_pdata.customer);
-    else
-    {
-        PERR ("failed to parse customer tree");
-        gncCustomerDestroy (cust_pdata.customer);
-        cust_pdata.customer = NULL;
-    }
-
-    return cust_pdata.customer;
-}
-
-static gboolean
-gnc_customer_end_handler(gpointer data_for_children,
-                         GSList* data_from_children, GSList* sibling_data,
-                         gpointer parent_data, gpointer global_data,
-                         gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncCustomer *cust;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    cust = dom_tree_to_customer(tree, book);
-    if (cust != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, cust);
-    }
-
-    xmlFreeNode(tree);
-
-    return cust != NULL;
-}
-
-static sixtp *
-customer_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_customer_end_handler, NULL, NULL);
-}
-
-static gboolean
-customer_should_be_saved (GncCustomer *customer)
-{
-    const char *id;
-
-    /* make sure this is a valid customer before we save it -- should have an ID */
-    id = gncCustomerGetID (customer);
-    if (id == NULL || *id == '\0')
-        return FALSE;
-
-    return TRUE;
-}
-
-static void
-do_count (QofInstance * cust_p, gpointer count_p)
-{
-    int *count = count_p;
-    if (customer_should_be_saved ((GncCustomer *)cust_p))
-        (*count)++;
-}
-
-static int
-customer_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_customer (QofInstance * cust_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncCustomer *cust = (GncCustomer *) cust_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-    if (!customer_should_be_saved (cust))
-        return;
-
-    node = customer_dom_tree_create (cust);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-customer_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_customer, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-static gboolean
-customer_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "cust");
-}
-
-void
-gnc_customer_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_customer_string,
-        customer_sixtp_parser_create,
-        NULL,			/* add_item */
-        customer_get_count,
-        customer_write,
-        NULL,			/* scrub */
-        customer_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-customer-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,29 +0,0 @@
-/*
- * gnc-customer-xml-v2.h -- customer xml i/o parser/unparser
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_CUSTOMER_XML_V2_H
-#define GNC_CUSTOMER_XML_V2_H
-
-void gnc_customer_xml_initialize (void);
-
-#endif /* GNC_CUSTOMER_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,468 +0,0 @@
-/********************************************************************\
- * gnc-employee-xml-v2.c -- employee xml i/o implementation         *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncEmployeeP.h"
-#include "gnc-employee-xml-v2.h"
-#include "gnc-address-xml-v2.h"
-
-#define _GNC_MOD_NAME	GNC_ID_EMPLOYEE
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *employee_version_string = "2.0.0";
-
-/* ids */
-#define gnc_employee_string "gnc:GncEmployee"
-#define employee_username_string "employee:username"
-#define employee_guid_string "employee:guid"
-#define employee_id_string "employee:id"
-#define employee_addr_string "employee:addr"
-#define employee_language_string "employee:language"
-#define employee_acl_string "employee:acl"
-#define employee_active_string "employee:active"
-#define employee_workday_string "employee:workday"
-#define employee_rate_string "employee:rate"
-#define employee_currency_string "employee:currency"
-#define employee_ccard_string "employee:ccard"
-#define employee_slots_string "employee:slots"
-
-static void
-maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
-{
-    if (str && strlen(str) > 0)
-        xmlAddChild (ptr, text_to_dom_tree (tag, str));
-}
-
-static xmlNodePtr
-employee_dom_tree_create (GncEmployee *employee)
-{
-    xmlNodePtr ret, kvpnode;
-    gnc_numeric num;
-    Account* ccard_acc;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_employee_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST employee_version_string);
-
-    xmlAddChild(ret, guid_to_dom_tree(employee_guid_string,
-                                      qof_instance_get_guid(QOF_INSTANCE (employee))));
-
-    xmlAddChild(ret, text_to_dom_tree(employee_username_string,
-                                      gncEmployeeGetUsername (employee)));
-
-    xmlAddChild(ret, text_to_dom_tree(employee_id_string,
-                                      gncEmployeeGetID (employee)));
-
-    xmlAddChild(ret, gnc_address_to_dom_tree(employee_addr_string,
-                gncEmployeeGetAddr (employee)));
-
-    maybe_add_string (ret, employee_language_string,
-                      gncEmployeeGetLanguage (employee));
-    maybe_add_string (ret, employee_acl_string, gncEmployeeGetAcl (employee));
-
-    xmlAddChild(ret, int_to_dom_tree(employee_active_string,
-                                     gncEmployeeGetActive (employee)));
-
-    num = gncEmployeeGetWorkday (employee);
-    xmlAddChild(ret, gnc_numeric_to_dom_tree (employee_workday_string, &num));
-
-    num = gncEmployeeGetRate (employee);
-    xmlAddChild(ret, gnc_numeric_to_dom_tree (employee_rate_string, &num));
-
-    xmlAddChild
-    (ret,
-     commodity_ref_to_dom_tree(employee_currency_string,
-                               gncEmployeeGetCurrency (employee)));
-
-    ccard_acc = gncEmployeeGetCCard (employee);
-    if (ccard_acc)
-        xmlAddChild(ret, guid_to_dom_tree(employee_ccard_string,
-                                          qof_instance_get_guid(QOF_INSTANCE(ccard_acc))));
-
-    kvpnode = kvp_frame_to_dom_tree (employee_slots_string,
-                                     qof_instance_get_slots (QOF_INSTANCE(employee)));
-    if (kvpnode) xmlAddChild (ret, kvpnode);
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct employee_pdata
-{
-    GncEmployee *employee;
-    QofBook *book;
-};
-
-static gboolean
-set_string(xmlNodePtr node, GncEmployee* employee,
-           void (*func)(GncEmployee *employee, const char *txt))
-{
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    func(employee, txt);
-
-    g_free(txt);
-
-    return TRUE;
-}
-
-static gboolean
-employee_username_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-
-    return set_string(node, pdata->employee, gncEmployeeSetUsername);
-}
-
-static gboolean
-employee_guid_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-    GncGUID *guid;
-    GncEmployee *employee;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail(guid, FALSE);
-
-    /* See if we've already created this one */
-    employee = gncEmployeeLookup (pdata->book, guid);
-    if (employee)
-    {
-        gncEmployeeDestroy (pdata->employee);
-        pdata->employee = employee;
-        gncEmployeeBeginEdit (employee);
-    }
-    else
-    {
-        gncEmployeeSetGUID(pdata->employee, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-employee_id_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-
-    return set_string(node, pdata->employee, gncEmployeeSetID);
-}
-
-static gboolean
-employee_language_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-
-    return set_string(node, pdata->employee, gncEmployeeSetLanguage);
-}
-
-static gboolean
-employee_acl_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-
-    return set_string(node, pdata->employee, gncEmployeeSetAcl);
-}
-
-static gboolean
-employee_addr_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-
-    return gnc_dom_tree_to_address (node, gncEmployeeGetAddr(pdata->employee));
-}
-
-static gboolean
-employee_active_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-    gint64 val;
-    gboolean ret;
-
-    ret = dom_tree_to_integer(node, &val);
-    if (ret)
-        gncEmployeeSetActive(pdata->employee, (gboolean)val);
-
-    return ret;
-}
-
-static gboolean
-employee_workday_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-    gnc_numeric *val;
-
-    val = dom_tree_to_gnc_numeric(node);
-    g_return_val_if_fail(val, FALSE);
-    gncEmployeeSetWorkday(pdata->employee, *val);
-    g_free(val);
-
-    return TRUE;
-}
-
-static gboolean
-employee_rate_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-    gnc_numeric *val;
-
-    val = dom_tree_to_gnc_numeric(node);
-    g_return_val_if_fail(val, FALSE);
-    gncEmployeeSetRate(pdata->employee, *val);
-    g_free(val);
-
-    return TRUE;
-}
-
-static gboolean
-employee_currency_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-    gnc_commodity *com;
-
-    com = dom_tree_to_commodity_ref(node, pdata->book);
-    g_return_val_if_fail (com, FALSE);
-
-    gncEmployeeSetCurrency (pdata->employee, com);
-
-    return TRUE;
-}
-
-static gboolean
-employee_ccard_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-    GncGUID *guid;
-    Account *ccard_acc;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail(guid, FALSE);
-
-    ccard_acc = xaccAccountLookup (guid, pdata->book);
-    g_free(guid);
-
-    g_return_val_if_fail (ccard_acc, FALSE);
-    gncEmployeeSetCCard (pdata->employee, ccard_acc);
-
-    return TRUE;
-}
-
-static gboolean
-employee_slots_handler (xmlNodePtr node, gpointer employee_pdata)
-{
-    struct employee_pdata *pdata = employee_pdata;
-    return dom_tree_to_kvp_frame_given (
-               node, qof_instance_get_slots (QOF_INSTANCE(pdata->employee)));
-}
-
-static struct dom_tree_handler employee_handlers_v2[] =
-{
-    { employee_username_string, employee_username_handler, 1, 0 },
-    { employee_guid_string, employee_guid_handler, 1, 0 },
-    { employee_id_string, employee_id_handler, 1, 0 },
-    { employee_addr_string, employee_addr_handler, 1, 0 },
-    { employee_language_string, employee_language_handler, 0, 0 },
-    { employee_acl_string, employee_acl_handler, 0, 0 },
-    { employee_active_string, employee_active_handler, 1, 0 },
-    { employee_workday_string, employee_workday_handler, 1, 0 },
-    { employee_rate_string, employee_rate_handler, 1, 0 },
-    { employee_currency_string, employee_currency_handler, 0, 0 }, /* XXX */
-    { "employee:commodity", employee_currency_handler, 0, 0 }, /* XXX */
-    { employee_ccard_string, employee_ccard_handler, 0, 0 },
-    { employee_slots_string, employee_slots_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncEmployee*
-dom_tree_to_employee (xmlNodePtr node, QofBook *book)
-{
-    struct employee_pdata employee_pdata;
-    gboolean successful;
-
-    employee_pdata.employee = gncEmployeeCreate(book);
-    employee_pdata.book = book;
-    gncEmployeeBeginEdit (employee_pdata.employee);
-
-    successful = dom_tree_generic_parse (node, employee_handlers_v2,
-                                         &employee_pdata);
-    if (successful)
-        gncEmployeeCommitEdit (employee_pdata.employee);
-    else
-    {
-        PERR ("failed to parse employee tree");
-        gncEmployeeDestroy (employee_pdata.employee);
-        employee_pdata.employee = NULL;
-    }
-
-    return employee_pdata.employee;
-}
-
-static gboolean
-gnc_employee_end_handler(gpointer data_for_children,
-                         GSList* data_from_children, GSList* sibling_data,
-                         gpointer parent_data, gpointer global_data,
-                         gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncEmployee *employee;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    employee = dom_tree_to_employee(tree, book);
-    if (employee != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, employee);
-    }
-
-    xmlFreeNode(tree);
-
-    return employee != NULL;
-}
-
-static sixtp *
-employee_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_employee_end_handler, NULL, NULL);
-}
-
-static gboolean
-employee_should_be_saved (GncEmployee *employee)
-{
-    const char *id;
-
-    /* make sure this is a valid employee before we save it -- should have an ID */
-    id = gncEmployeeGetID (employee);
-    if (id == NULL || *id == '\0')
-        return FALSE;
-
-    return TRUE;
-}
-
-static void
-do_count (QofInstance * employee_p, gpointer count_p)
-{
-    int *count = count_p;
-    if (employee_should_be_saved ((GncEmployee *) employee_p))
-        (*count)++;
-}
-
-static int
-employee_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_employee (QofInstance * employee_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncEmployee *employee = (GncEmployee *) employee_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-    if (!employee_should_be_saved (employee))
-        return;
-
-    node = employee_dom_tree_create (employee);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-employee_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_employee, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-static gboolean
-employee_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "employee");
-}
-
-void
-gnc_employee_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_employee_string,
-        employee_sixtp_parser_create,
-        NULL,			/* add_item */
-        employee_get_count,
-        employee_write,
-        NULL,			/* scrub */
-        employee_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-employee-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,29 +0,0 @@
-/*
- * gnc-employee-xml-v2.h -- employee xml i/o parser/unparser
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_EMPLOYEE_XML_V2_H
-#define GNC_EMPLOYEE_XML_V2_H
-
-void gnc_employee_xml_initialize (void);
-
-#endif /* GNC_EMPLOYEE_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,864 +0,0 @@
-/********************************************************************\
- * gnc-entry-xml-v2.c -- entry xml i/o implementation         *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncEntryP.h"
-#include "gncOrderP.h"
-#include "gncInvoiceP.h"
-#include "gncTaxTableP.h"
-#include "gnc-entry-xml-v2.h"
-#include "gnc-owner-xml-v2.h"
-
-#define _GNC_MOD_NAME	GNC_ID_ENTRY
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *entry_version_string = "2.0.0";
-
-/* ids */
-#define gnc_entry_string "gnc:GncEntry"
-#define entry_guid_string "entry:guid"
-#define entry_date_string "entry:date"
-#define entry_dateentered_string "entry:entered"
-#define entry_description_string "entry:description"
-#define entry_action_string "entry:action"
-#define entry_notes_string "entry:notes"
-#define entry_qty_string "entry:qty"
-
-/* cust inv */
-#define entry_invacct_string "entry:i-acct"
-#define entry_iprice_string "entry:i-price"
-#define entry_idiscount_string "entry:i-discount"
-#define entry_idisctype_string "entry:i-disc-type"
-#define entry_idischow_string "entry:i-disc-how"
-#define entry_itaxable_string "entry:i-taxable"
-#define entry_itaxincluded_string "entry:i-taxincluded"
-#define entry_itaxtable_string "entry:i-taxtable"
-
-/* vend bill */
-#define entry_billacct_string "entry:b-acct"
-#define entry_bprice_string "entry:b-price"
-#define entry_btaxable_string "entry:b-taxable"
-#define entry_btaxincluded_string "entry:b-taxincluded"
-#define entry_btaxtable_string "entry:b-taxtable"
-#define entry_billable_string "entry:billable"
-#define entry_billto_string "entry:billto"
-
-/* emp bill */
-#define entry_billpayment_string "entry:b-pay"
-
-/* other stuff */
-#define entry_order_string "entry:order"
-#define entry_invoice_string "entry:invoice"
-#define entry_bill_string "entry:bill"
-#define entry_slots_string "entry:slots"
-
-static void
-maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
-{
-    if (str && strlen(str) > 0)
-        xmlAddChild (ptr, text_to_dom_tree (tag, str));
-}
-
-static void
-maybe_add_numeric (xmlNodePtr ptr, const char *tag, gnc_numeric num)
-{
-    if (!gnc_numeric_zero_p (num))
-        xmlAddChild (ptr, gnc_numeric_to_dom_tree (tag, &num));
-}
-
-static xmlNodePtr
-entry_dom_tree_create (GncEntry *entry)
-{
-    xmlNodePtr ret;
-    Timespec ts;
-    Account *acc;
-    GncTaxTable *taxtable;
-    GncOrder *order;
-    GncInvoice *invoice;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_entry_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST entry_version_string);
-
-    xmlAddChild(ret, guid_to_dom_tree(entry_guid_string,
-                                      qof_instance_get_guid(QOF_INSTANCE(entry))));
-
-    ts = gncEntryGetDate (entry);
-    xmlAddChild(ret, timespec_to_dom_tree (entry_date_string, &ts));
-
-    ts = gncEntryGetDateEntered (entry);
-    xmlAddChild(ret, timespec_to_dom_tree (entry_dateentered_string, &ts));
-
-    maybe_add_string (ret, entry_description_string,
-                      gncEntryGetDescription (entry));
-    maybe_add_string (ret, entry_action_string, gncEntryGetAction (entry));
-    maybe_add_string (ret, entry_notes_string, gncEntryGetNotes (entry));
-
-    maybe_add_numeric (ret, entry_qty_string, gncEntryGetQuantity (entry));
-
-    /* cust invoice */
-
-    acc = gncEntryGetInvAccount (entry);
-    if (acc)
-        xmlAddChild (ret, guid_to_dom_tree (entry_invacct_string,
-                                            qof_instance_get_guid(QOF_INSTANCE(acc))));
-
-    maybe_add_numeric (ret, entry_iprice_string, gncEntryGetInvPrice (entry));
-
-    maybe_add_numeric (ret, entry_idiscount_string, gncEntryGetInvDiscount (entry));
-
-    invoice = gncEntryGetInvoice (entry);
-    if (invoice)
-    {
-        xmlAddChild (ret, guid_to_dom_tree (entry_invoice_string,
-                                            qof_instance_get_guid(QOF_INSTANCE(invoice))));
-
-        xmlAddChild(ret, text_to_dom_tree(entry_idisctype_string,
-                                          gncAmountTypeToString (
-                                              gncEntryGetInvDiscountType (entry))));
-        xmlAddChild(ret, text_to_dom_tree(entry_idischow_string,
-                                          gncEntryDiscountHowToString (
-                                              gncEntryGetInvDiscountHow (entry))));
-
-        xmlAddChild(ret, int_to_dom_tree(entry_itaxable_string,
-                                         gncEntryGetInvTaxable (entry)));
-        xmlAddChild(ret, int_to_dom_tree(entry_itaxincluded_string,
-                                         gncEntryGetInvTaxIncluded (entry)));
-    }
-
-    taxtable = gncEntryGetInvTaxTable (entry);
-    if (taxtable)
-        xmlAddChild (ret, guid_to_dom_tree (entry_itaxtable_string,
-                                            qof_instance_get_guid (QOF_INSTANCE(taxtable))));
-
-    /* vendor bills */
-
-    acc = gncEntryGetBillAccount (entry);
-    if (acc)
-        xmlAddChild (ret, guid_to_dom_tree (entry_billacct_string,
-                                            qof_instance_get_guid (QOF_INSTANCE(acc))));
-
-    maybe_add_numeric (ret, entry_bprice_string, gncEntryGetBillPrice (entry));
-
-    invoice = gncEntryGetBill (entry);
-    if (invoice)
-    {
-        GncOwner *owner;
-        xmlAddChild (ret, guid_to_dom_tree (entry_bill_string,
-                                            qof_instance_get_guid(QOF_INSTANCE(invoice))));
-        xmlAddChild(ret, int_to_dom_tree(entry_billable_string,
-                                         gncEntryGetBillable (entry)));
-        owner = gncEntryGetBillTo (entry);
-        if (owner && owner->owner.undefined != NULL)
-            xmlAddChild (ret, gnc_owner_to_dom_tree (entry_billto_string, owner));
-
-        xmlAddChild(ret, int_to_dom_tree(entry_btaxable_string,
-                                         gncEntryGetBillTaxable (entry)));
-        xmlAddChild(ret, int_to_dom_tree(entry_btaxincluded_string,
-                                         gncEntryGetBillTaxIncluded (entry)));
-        maybe_add_string (ret, entry_billpayment_string,
-                          gncEntryPaymentTypeToString (gncEntryGetBillPayment (entry)));
-    }
-
-    taxtable = gncEntryGetBillTaxTable (entry);
-    if (taxtable)
-        xmlAddChild (ret, guid_to_dom_tree (entry_btaxtable_string,
-                                            qof_instance_get_guid (QOF_INSTANCE(taxtable))));
-
-    /* Other stuff */
-
-    order = gncEntryGetOrder (entry);
-    if (order)
-        xmlAddChild (ret, guid_to_dom_tree (entry_order_string,
-                                            qof_instance_get_guid(QOF_INSTANCE (order))));
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct entry_pdata
-{
-    GncEntry *entry;
-    QofBook *book;
-    Account *acc;
-};
-
-static inline gboolean
-set_string(xmlNodePtr node, GncEntry* entry,
-           void (*func)(GncEntry *entry, const char *txt))
-{
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    func(entry, txt);
-    g_free(txt);
-    return TRUE;
-}
-
-static inline gboolean
-set_timespec(xmlNodePtr node, GncEntry* entry,
-             void (*func)(GncEntry *entry, Timespec ts))
-{
-    Timespec ts = dom_tree_to_timespec (node);
-    if (!dom_tree_valid_timespec(&ts, node->name)) return FALSE;
-
-    func(entry, ts);
-    return TRUE;
-}
-
-static inline gboolean
-set_numeric(xmlNodePtr node, GncEntry* entry,
-            void (*func)(GncEntry *entry, gnc_numeric num))
-{
-    gnc_numeric* num = dom_tree_to_gnc_numeric(node);
-    g_return_val_if_fail(num, FALSE);
-
-    func(entry, *num);
-    g_free(num);
-    return TRUE;
-}
-
-static inline gboolean
-set_boolean(xmlNodePtr node, GncEntry* entry,
-            void (*func)(GncEntry *entry, gboolean val))
-{
-    gint64 val;
-
-    if (!dom_tree_to_integer(node, &val))
-        return FALSE;
-    func (entry, (gboolean)val);
-    return TRUE;
-}
-
-static inline gboolean
-set_account(xmlNodePtr node, struct entry_pdata *pdata,
-            void (*func)(GncEntry *entry, Account *acc))
-{
-    GncGUID *guid;
-    Account * acc;
-
-    guid = dom_tree_to_guid (node);
-    g_return_val_if_fail (guid, FALSE);
-    acc = xaccAccountLookup (guid, pdata->book);
-    g_free (guid);
-    g_return_val_if_fail (acc, FALSE);
-
-    if (func)
-        func (pdata->entry, acc);
-    else
-        pdata->acc = acc;
-    return TRUE;
-}
-
-static inline gboolean
-set_taxtable (xmlNodePtr node, struct entry_pdata *pdata,
-              void (*func)(GncEntry *entry, GncTaxTable *taxtable))
-{
-    GncGUID *guid;
-    GncTaxTable *taxtable;
-
-    guid = dom_tree_to_guid (node);
-    g_return_val_if_fail (guid, FALSE);
-    taxtable = gncTaxTableLookup (pdata->book, guid);
-    if (!taxtable)
-    {
-        taxtable = gncTaxTableCreate (pdata->book);
-        gncTaxTableBeginEdit (taxtable);
-        gncTaxTableSetGUID (taxtable, guid);
-        gncTaxTableCommitEdit (taxtable);
-    }
-    else
-        gncTaxTableDecRef (taxtable);
-
-    func (pdata->entry, taxtable);
-    g_free(guid);
-    return TRUE;
-}
-
-static gboolean
-entry_guid_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    GncGUID *guid;
-    GncEntry *entry;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    entry = gncEntryLookup (pdata->book, guid);
-    if (entry)
-    {
-        gncEntryDestroy (pdata->entry);
-        pdata->entry = entry;
-        gncEntryBeginEdit (entry);
-    }
-    else
-    {
-        gncEntrySetGUID(pdata->entry, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-entry_date_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_timespec(node, pdata->entry, gncEntrySetDate);
-}
-
-static gboolean
-entry_dateentered_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_timespec(node, pdata->entry, gncEntrySetDateEntered);
-}
-
-static gboolean
-entry_description_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_string(node, pdata->entry, gncEntrySetDescription);
-}
-
-static gboolean
-entry_action_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_string(node, pdata->entry, gncEntrySetAction);
-}
-
-static gboolean
-entry_notes_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_string(node, pdata->entry, gncEntrySetNotes);
-}
-
-static gboolean
-entry_qty_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_numeric(node, pdata->entry, gncEntrySetQuantity);
-}
-
-/* Cust invoice */
-
-static gboolean
-entry_invacct_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_account (node, pdata, gncEntrySetInvAccount);
-}
-
-static gboolean
-entry_iprice_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_numeric(node, pdata->entry, gncEntrySetInvPrice);
-}
-
-static gboolean
-entry_idiscount_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_numeric(node, pdata->entry, gncEntrySetInvDiscount);
-}
-
-static gboolean
-entry_idisctype_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    GncAmountType type;
-    char *str;
-    gboolean ret;
-
-    str = dom_tree_to_text (node);
-    g_return_val_if_fail (str, FALSE);
-
-    ret = gncAmountStringToType (str, &type);
-    g_free (str);
-
-    if (ret)
-        gncEntrySetInvDiscountType(pdata->entry, type);
-
-    return ret;
-}
-
-static gboolean
-entry_idischow_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    GncDiscountHow how;
-    char *str;
-    gboolean ret;
-
-    str = dom_tree_to_text (node);
-    g_return_val_if_fail (str, FALSE);
-
-    ret = gncEntryDiscountStringToHow (str, &how);
-    g_free (str);
-
-    if (ret)
-        gncEntrySetInvDiscountHow(pdata->entry, how);
-
-    return ret;
-}
-
-static gboolean
-entry_itaxable_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_boolean (node, pdata->entry, gncEntrySetInvTaxable);
-}
-
-static gboolean
-entry_itaxincluded_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_boolean (node, pdata->entry, gncEntrySetInvTaxIncluded);
-}
-
-static gboolean
-entry_itaxtable_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_taxtable (node, pdata, gncEntrySetInvTaxTable);
-}
-
-/* vendor bills */
-
-static gboolean
-entry_billacct_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_account (node, pdata, gncEntrySetBillAccount);
-}
-
-static gboolean
-entry_bprice_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-
-    return set_numeric(node, pdata->entry, gncEntrySetBillPrice);
-}
-
-static gboolean
-entry_btaxable_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_boolean (node, pdata->entry, gncEntrySetBillTaxable);
-}
-
-static gboolean
-entry_btaxincluded_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_boolean (node, pdata->entry, gncEntrySetBillTaxIncluded);
-}
-
-static gboolean
-entry_btaxtable_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_taxtable (node, pdata, gncEntrySetBillTaxTable);
-}
-
-static gboolean
-entry_billable_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    return set_boolean (node, pdata->entry, gncEntrySetBillable);
-}
-
-static gboolean
-entry_billto_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    GncOwner billto;
-    gboolean ret;
-
-    ret = gnc_dom_tree_to_owner (node, &billto, pdata->book);
-    if (ret)
-        gncEntrySetBillTo (pdata->entry, &billto);
-
-    return ret;
-}
-
-/* employee bills */
-static gboolean
-entry_billpayment_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    GncEntryPaymentType type;
-    char *str;
-    gboolean ret;
-
-    str = dom_tree_to_text (node);
-    g_return_val_if_fail (str, FALSE);
-
-    ret = gncEntryPaymentStringToType (str, &type);
-    g_free (str);
-
-    if (ret)
-        gncEntrySetBillPayment(pdata->entry, type);
-
-    return ret;
-}
-
-/* The rest of the stuff */
-
-static gboolean
-entry_order_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    GncGUID *guid;
-    GncOrder *order;
-
-    guid = dom_tree_to_guid (node);
-    g_return_val_if_fail (guid, FALSE);
-    order = gncOrderLookup (pdata->book, guid);
-    if (!order)
-    {
-        order = gncOrderCreate (pdata->book);
-        gncOrderBeginEdit (order);
-        gncOrderSetGUID (order, guid);
-        gncOrderCommitEdit (order);
-    }
-    gncOrderBeginEdit (order);
-    gncOrderAddEntry (order, pdata->entry);
-    gncOrderCommitEdit (order);
-
-    g_free(guid);
-    return TRUE;
-}
-
-static gboolean
-entry_invoice_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    GncGUID *guid;
-    GncInvoice *invoice;
-
-    guid = dom_tree_to_guid (node);
-    g_return_val_if_fail (guid, FALSE);
-    invoice = gncInvoiceLookup (pdata->book, guid);
-    if (!invoice)
-    {
-        invoice = gncInvoiceCreate (pdata->book);
-        gncInvoiceBeginEdit (invoice);
-        gncInvoiceSetGUID (invoice, guid);
-        gncInvoiceCommitEdit (invoice);
-    }
-    gncInvoiceBeginEdit (invoice);
-    gncInvoiceAddEntry (invoice, pdata->entry);
-    gncInvoiceCommitEdit (invoice);
-
-    g_free(guid);
-    return TRUE;
-}
-
-static gboolean
-entry_bill_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    GncGUID *guid;
-    GncInvoice *invoice;
-
-    guid = dom_tree_to_guid (node);
-    g_return_val_if_fail (guid, FALSE);
-    invoice = gncInvoiceLookup (pdata->book, guid);
-    if (!invoice)
-    {
-        invoice = gncInvoiceCreate (pdata->book);
-        gncInvoiceBeginEdit (invoice);
-        gncInvoiceSetGUID (invoice, guid);
-        gncInvoiceCommitEdit (invoice);
-    }
-    gncInvoiceBeginEdit (invoice);
-    gncBillAddEntry (invoice, pdata->entry);
-    gncInvoiceCommitEdit (invoice);
-
-    g_free(guid);
-    return TRUE;
-}
-
-/* Support for older XML versions */
-
-static gboolean
-entry_acct_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    /* XXX: try to figure out if this is an 'invoice' or a 'bill' --
-     * we have to wait until the end!
-     */
-
-    return set_account (node, pdata, NULL);
-}
-
-static gboolean
-entry_price_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    struct entry_pdata *pdata = entry_pdata;
-    gboolean res;
-
-    /* just set both.. Don't worry about extra data if it's wrong */
-    res = set_numeric(node, pdata->entry, gncEntrySetInvPrice);
-    if (res)
-        gncEntrySetBillPrice (pdata->entry, gncEntryGetInvPrice (pdata->entry));
-    return res;
-}
-
-static gboolean
-entry_slots_handler (xmlNodePtr node, gpointer entry_pdata)
-{
-    return TRUE;
-}
-
-static struct dom_tree_handler entry_handlers_v2[] =
-{
-    { entry_guid_string, entry_guid_handler, 1, 0 },
-    { entry_date_string, entry_date_handler, 1, 0 },
-    { entry_dateentered_string, entry_dateentered_handler, 1, 0 },
-    { entry_description_string, entry_description_handler, 0, 0 },
-    { entry_action_string, entry_action_handler, 0, 0 },
-    { entry_notes_string, entry_notes_handler, 0, 0 },
-    { entry_qty_string, entry_qty_handler, 0, 0 },
-
-    /* cust invoice */
-    { entry_invacct_string, entry_invacct_handler, 0, 0 },
-    { entry_iprice_string, entry_iprice_handler, 0, 0 },
-    { entry_idiscount_string, entry_idiscount_handler, 0, 0 },
-    { entry_idisctype_string, entry_idisctype_handler, 0, 0 },
-    { entry_idischow_string, entry_idischow_handler, 0, 0 },
-    { entry_itaxable_string, entry_itaxable_handler, 0, 0 },
-    { entry_itaxincluded_string, entry_itaxincluded_handler, 0, 0 },
-    { entry_itaxtable_string, entry_itaxtable_handler, 0, 0 },
-
-    /* vendor invoice */
-    { entry_billacct_string, entry_billacct_handler, 0, 0 },
-    { entry_bprice_string, entry_bprice_handler, 0, 0 },
-    { entry_btaxable_string, entry_btaxable_handler, 0, 0 },
-    { entry_btaxincluded_string, entry_btaxincluded_handler, 0, 0 },
-    { entry_btaxtable_string, entry_btaxtable_handler, 0, 0 },
-    { entry_billable_string, entry_billable_handler, 0, 0 },
-    { entry_billto_string, entry_billto_handler, 0, 0 },
-
-    /* employee stuff */
-    { entry_billpayment_string, entry_billpayment_handler, 0, 0 },
-
-    /* Other stuff */
-    { entry_order_string, entry_order_handler, 0, 0 },
-    { entry_invoice_string, entry_invoice_handler, 0, 0 },
-    { entry_bill_string, entry_bill_handler, 0, 0 },
-    { entry_slots_string, entry_slots_handler, 0, 0 },
-
-    /* Old XML support */
-    { "entry:acct", entry_acct_handler, 0, 0 },
-    { "entry:price", entry_price_handler, 0, 0 },
-    { "entry:discount", entry_idiscount_handler, 0, 0 },
-    { "entry:disc-type", entry_idisctype_handler, 0, 0 },
-    { "entry:disc-how", entry_idischow_handler, 0, 0 },
-    { "entry:taxable", entry_itaxable_handler, 0, 0 },
-    { "entry:taxincluded", entry_itaxincluded_handler, 0, 0 },
-    { "entry:taxtable", entry_itaxtable_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncEntry*
-dom_tree_to_entry (xmlNodePtr node, QofBook *book)
-{
-    struct entry_pdata entry_pdata;
-    gboolean successful;
-
-    entry_pdata.entry = gncEntryCreate(book);
-    entry_pdata.book = book;
-    entry_pdata.acc = NULL;
-    gncEntryBeginEdit (entry_pdata.entry);
-
-    successful = dom_tree_generic_parse (node, entry_handlers_v2,
-                                         &entry_pdata);
-    if (entry_pdata.acc != NULL)
-    {
-        if (gncEntryGetBill (entry_pdata.entry))
-            gncEntrySetBillAccount (entry_pdata.entry, entry_pdata.acc);
-        else
-            gncEntrySetInvAccount (entry_pdata.entry, entry_pdata.acc);
-    }
-
-    if (successful)
-        gncEntryCommitEdit (entry_pdata.entry);
-    else
-    {
-        PERR ("failed to parse entry tree");
-        gncEntryDestroy (entry_pdata.entry);
-        entry_pdata.entry = NULL;
-    }
-
-    return entry_pdata.entry;
-}
-
-static gboolean
-gnc_entry_end_handler(gpointer data_for_children,
-                      GSList* data_from_children, GSList* sibling_data,
-                      gpointer parent_data, gpointer global_data,
-                      gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncEntry *entry;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    entry = dom_tree_to_entry(tree, book);
-    if (entry != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, entry);
-    }
-
-    xmlFreeNode(tree);
-
-    return entry != NULL;
-}
-
-static sixtp *
-entry_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_entry_end_handler, NULL, NULL);
-}
-
-static void
-do_count (QofInstance * entry_p, gpointer count_p)
-{
-    int *count = count_p;
-    (*count)++;
-}
-
-static int
-entry_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_entry (QofInstance * entry_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncEntry *entry = (GncEntry *) entry_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-
-    /* Don't save non-attached entries! */
-    if (!(gncEntryGetOrder (entry) || gncEntryGetInvoice (entry) ||
-            gncEntryGetBill (entry)))
-        return;
-
-    node = entry_dom_tree_create (entry);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-entry_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_entry, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-static gboolean
-entry_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "entry");
-}
-
-void
-gnc_entry_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_entry_string,
-        entry_sixtp_parser_create,
-        NULL,			/* add_item */
-        entry_get_count,
-        entry_write,
-        NULL,			/* scrub */
-        entry_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-entry-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,29 +0,0 @@
-/*
- * gnc-entry-xml-v2.h -- entry xml i/o parser/unparsers
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_ENTRY_XML_V2_H
-#define GNC_ENTRY_XML_V2_H
-
-void gnc_entry_xml_initialize (void);
-
-#endif /* GNC_ENTRY_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,574 +0,0 @@
-/********************************************************************\
- * gnc-invoice-xml-v2.c -- invoice xml i/o implementation         *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncBillTermP.h"
-#include "gncInvoiceP.h"
-#include "gnc-invoice-xml-v2.h"
-#include "gnc-owner-xml-v2.h"
-#include "gnc-bill-term-xml-v2.h"
-
-#define _GNC_MOD_NAME	GNC_ID_INVOICE
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *invoice_version_string = "2.0.0";
-
-/* ids */
-#define gnc_invoice_string "gnc:GncInvoice"
-#define invoice_guid_string "invoice:guid"
-#define invoice_id_string "invoice:id"
-#define invoice_owner_string "invoice:owner"
-#define invoice_opened_string "invoice:opened"
-#define invoice_posted_string "invoice:posted"
-#define invoice_terms_string "invoice:terms"
-#define invoice_billing_id_string "invoice:billing_id"
-#define invoice_notes_string "invoice:notes"
-#define invoice_active_string "invoice:active"
-#define invoice_posttxn_string "invoice:posttxn"
-#define invoice_postlot_string "invoice:postlot"
-#define invoice_postacc_string "invoice:postacc"
-#define invoice_currency_string "invoice:currency"
-#define invoice_billto_string "invoice:billto"
-#define invoice_tochargeamt_string "invoice:charge-amt"
-#define invoice_slots_string "invoice:slots"
-
-static void
-maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
-{
-    if (str && strlen(str) > 0)
-        xmlAddChild (ptr, text_to_dom_tree (tag, str));
-}
-
-static void
-maybe_add_timespec (xmlNodePtr ptr, const char *tag, Timespec ts)
-{
-    if (ts.tv_sec || ts.tv_nsec)
-        xmlAddChild (ptr, timespec_to_dom_tree (tag, &ts));
-}
-
-static xmlNodePtr
-invoice_dom_tree_create (GncInvoice *invoice)
-{
-    xmlNodePtr ret;
-    Timespec ts;
-    Transaction *txn;
-    GNCLot *lot;
-    Account *acc;
-    GncBillTerm *term;
-    GncOwner *billto;
-    gnc_numeric amt;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_invoice_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST invoice_version_string);
-
-    xmlAddChild(ret, guid_to_dom_tree(invoice_guid_string,
-                                      qof_instance_get_guid(QOF_INSTANCE(invoice))));
-
-    xmlAddChild(ret, text_to_dom_tree(invoice_id_string,
-                                      gncInvoiceGetID (invoice)));
-
-    xmlAddChild(ret, gnc_owner_to_dom_tree (invoice_owner_string,
-                                            gncInvoiceGetOwner (invoice)));
-
-    ts = gncInvoiceGetDateOpened (invoice);
-    xmlAddChild(ret, timespec_to_dom_tree (invoice_opened_string, &ts));
-
-    maybe_add_timespec (ret, invoice_posted_string,
-                        gncInvoiceGetDatePosted (invoice));
-
-    term = gncInvoiceGetTerms (invoice);
-    if (term)
-        xmlAddChild(ret, guid_to_dom_tree(invoice_terms_string,
-                                          qof_instance_get_guid (QOF_INSTANCE(term))));
-
-    maybe_add_string (ret, invoice_billing_id_string,
-                      gncInvoiceGetBillingID (invoice));
-    maybe_add_string (ret, invoice_notes_string, gncInvoiceGetNotes (invoice));
-
-    xmlAddChild(ret, int_to_dom_tree(invoice_active_string,
-                                     gncInvoiceGetActive (invoice)));
-
-    txn = gncInvoiceGetPostedTxn (invoice);
-    if (txn)
-        xmlAddChild (ret, guid_to_dom_tree (invoice_posttxn_string,
-                                            xaccTransGetGUID (txn)));
-
-    lot = gncInvoiceGetPostedLot (invoice);
-    if (lot)
-        xmlAddChild (ret, guid_to_dom_tree (invoice_postlot_string,
-                                            gnc_lot_get_guid (lot)));
-
-    acc = gncInvoiceGetPostedAcc (invoice);
-    if (acc)
-        xmlAddChild (ret, guid_to_dom_tree (invoice_postacc_string,
-                                            qof_instance_get_guid(QOF_INSTANCE(acc))));
-
-    xmlAddChild
-    (ret,
-     commodity_ref_to_dom_tree(invoice_currency_string,
-                               gncInvoiceGetCurrency (invoice)));
-
-    billto = gncInvoiceGetBillTo (invoice);
-    if (billto && billto->owner.undefined != NULL)
-        xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_billto_string, billto));
-
-    amt = gncInvoiceGetToChargeAmount (invoice);
-    if (! gnc_numeric_zero_p (amt))
-        xmlAddChild (ret, gnc_numeric_to_dom_tree (invoice_tochargeamt_string, &amt));
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct invoice_pdata
-{
-    GncInvoice *invoice;
-    QofBook *book;
-};
-
-static inline gboolean
-set_string(xmlNodePtr node, GncInvoice* invoice,
-           void (*func)(GncInvoice *invoice, const char *txt))
-{
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    func(invoice, txt);
-
-    g_free(txt);
-    return TRUE;
-}
-
-static inline gboolean
-set_timespec(xmlNodePtr node, GncInvoice* invoice,
-             void (*func)(GncInvoice *invoice, Timespec ts))
-{
-    Timespec ts = dom_tree_to_timespec(node);
-    if (!dom_tree_valid_timespec(&ts, node->name)) return FALSE;
-
-    func(invoice, ts);
-    return TRUE;
-}
-
-static gboolean
-invoice_guid_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    GncGUID *guid;
-    GncInvoice *invoice;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    invoice = gncInvoiceLookup (pdata->book, guid);
-    if (invoice)
-    {
-        gncInvoiceDestroy (pdata->invoice);
-        pdata->invoice = invoice;
-        gncInvoiceBeginEdit (invoice);
-    }
-    else
-    {
-        gncInvoiceSetGUID(pdata->invoice, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-invoice_id_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-
-    return set_string(node, pdata->invoice, gncInvoiceSetID);
-}
-
-static gboolean
-invoice_owner_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    GncOwner owner;
-    gboolean ret;
-
-    ret = gnc_dom_tree_to_owner (node, &owner, pdata->book);
-    if (ret)
-        gncInvoiceSetOwner (pdata->invoice, &owner);
-
-    return ret;
-}
-
-static gboolean
-invoice_opened_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-
-    return set_timespec (node, pdata->invoice, gncInvoiceSetDateOpened);
-}
-
-static gboolean
-invoice_posted_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-
-    return set_timespec (node, pdata->invoice, gncInvoiceSetDatePosted);
-}
-
-static gboolean
-invoice_billing_id_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-
-    return set_string(node, pdata->invoice, gncInvoiceSetBillingID);
-}
-
-static gboolean
-invoice_notes_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-
-    return set_string(node, pdata->invoice, gncInvoiceSetNotes);
-}
-
-static gboolean
-invoice_active_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    gint64 val;
-    gboolean ret;
-
-    ret = dom_tree_to_integer(node, &val);
-    if (ret)
-        gncInvoiceSetActive(pdata->invoice, (gboolean)val);
-
-    return ret;
-}
-
-static gboolean
-invoice_terms_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    GncGUID *guid;
-    GncBillTerm *term;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    term = gnc_billterm_xml_find_or_create(pdata->book, guid);
-    g_assert(term);
-    g_free (guid);
-    gncInvoiceSetTerms (pdata->invoice, term);
-
-    return TRUE;
-}
-
-static gboolean
-invoice_posttxn_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    GncGUID *guid;
-    Transaction *txn;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    txn = xaccTransLookup (guid, pdata->book);
-    g_free (guid);
-    g_return_val_if_fail (txn, FALSE);
-
-    gncInvoiceSetPostedTxn (pdata->invoice, txn);
-    return TRUE;
-}
-
-static gboolean
-invoice_postlot_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    GncGUID *guid;
-    GNCLot *lot;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    lot = gnc_lot_lookup (guid, pdata->book);
-    g_free (guid);
-    g_return_val_if_fail (lot, FALSE);
-
-    gncInvoiceSetPostedLot (pdata->invoice, lot);
-    return TRUE;
-}
-
-static gboolean
-invoice_postacc_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    GncGUID *guid;
-    Account *acc;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    acc = xaccAccountLookup (guid, pdata->book);
-    g_free (guid);
-    g_return_val_if_fail (acc, FALSE);
-
-    gncInvoiceSetPostedAcc (pdata->invoice, acc);
-    return TRUE;
-}
-
-static gboolean
-invoice_currency_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    gnc_commodity *com;
-
-    com = dom_tree_to_commodity_ref(node, pdata->book);
-    g_return_val_if_fail (com, FALSE);
-
-    gncInvoiceSetCurrency (pdata->invoice, com);
-
-    return TRUE;
-}
-
-static gboolean
-invoice_billto_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    GncOwner owner;
-    gboolean ret;
-
-    ret = gnc_dom_tree_to_owner (node, &owner, pdata->book);
-    if (ret)
-        gncInvoiceSetBillTo (pdata->invoice, &owner);
-
-    return ret;
-}
-
-static gboolean
-invoice_tochargeamt_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    struct invoice_pdata *pdata = invoice_pdata;
-    gnc_numeric* num = dom_tree_to_gnc_numeric(node);
-    g_return_val_if_fail(num, FALSE);
-
-    gncInvoiceSetToChargeAmount (pdata->invoice, *num);
-    g_free(num);
-    return TRUE;
-}
-
-static gboolean
-invoice_slots_handler (xmlNodePtr node, gpointer invoice_pdata)
-{
-    return TRUE;
-}
-
-static struct dom_tree_handler invoice_handlers_v2[] =
-{
-    { invoice_guid_string, invoice_guid_handler, 1, 0 },
-    { invoice_id_string, invoice_id_handler, 1, 0 },
-    { invoice_owner_string, invoice_owner_handler, 1, 0 },
-    { invoice_opened_string, invoice_opened_handler, 1, 0 },
-    { invoice_posted_string, invoice_posted_handler, 0, 0 },
-    { invoice_billing_id_string, invoice_billing_id_handler, 0, 0 },
-    { invoice_notes_string, invoice_notes_handler, 0, 0 },
-    { invoice_active_string, invoice_active_handler, 1, 0 },
-    { invoice_terms_string, invoice_terms_handler, 0, 0 },
-    { invoice_posttxn_string, invoice_posttxn_handler, 0, 0 },
-    { invoice_postlot_string, invoice_postlot_handler, 0, 0 },
-    { invoice_postacc_string, invoice_postacc_handler, 0, 0 },
-    { invoice_currency_string, invoice_currency_handler, 0, 0 },
-    { "invoice:commodity", invoice_currency_handler, 0, 0 },
-    { invoice_billto_string, invoice_billto_handler, 0, 0 },
-    { invoice_tochargeamt_string, invoice_tochargeamt_handler, 0, 0},
-    { invoice_slots_string, invoice_slots_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncInvoice*
-dom_tree_to_invoice (xmlNodePtr node, QofBook *book)
-{
-    struct invoice_pdata invoice_pdata;
-    gboolean successful;
-
-    invoice_pdata.invoice = gncInvoiceCreate(book);
-    invoice_pdata.book = book;
-    gncInvoiceBeginEdit (invoice_pdata.invoice);
-
-    successful = dom_tree_generic_parse (node, invoice_handlers_v2,
-                                         &invoice_pdata);
-
-    if (successful)
-        gncInvoiceCommitEdit (invoice_pdata.invoice);
-    else
-    {
-        PERR ("failed to parse invoice tree");
-        gncInvoiceDestroy (invoice_pdata.invoice);
-        invoice_pdata.invoice = NULL;
-    }
-
-    return invoice_pdata.invoice;
-}
-
-static gboolean
-gnc_invoice_end_handler(gpointer data_for_children,
-                        GSList* data_from_children, GSList* sibling_data,
-                        gpointer parent_data, gpointer global_data,
-                        gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncInvoice *invoice;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    invoice = dom_tree_to_invoice(tree, book);
-    if (invoice != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, invoice);
-    }
-
-    xmlFreeNode(tree);
-
-    return invoice != NULL;
-}
-
-static sixtp *
-invoice_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_invoice_end_handler, NULL, NULL);
-}
-
-static gboolean
-invoice_should_be_saved (GncInvoice *invoice)
-{
-    const char *id;
-
-    /* make sure this is a valid invoice before we save it -- should have an ID */
-    id = gncInvoiceGetID (invoice);
-    if (id == NULL || *id == '\0')
-        return FALSE;
-
-    return TRUE;
-}
-
-static void
-do_count (QofInstance * invoice_p, gpointer count_p)
-{
-    int *count = count_p;
-    if (invoice_should_be_saved ((GncInvoice *)invoice_p))
-        (*count)++;
-}
-
-static int
-invoice_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_invoice (QofInstance * invoice_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncInvoice *invoice = (GncInvoice *) invoice_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-    if (!invoice_should_be_saved (invoice))
-        return;
-
-    node = invoice_dom_tree_create (invoice);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-invoice_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_invoice, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-static gboolean
-invoice_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "invoice");
-}
-
-void
-gnc_invoice_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_invoice_string,
-        invoice_sixtp_parser_create,
-        NULL,			/* add_item */
-        invoice_get_count,
-        invoice_write,
-        NULL,			/* scrub */
-        invoice_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-invoice-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,29 +0,0 @@
-/*
- * gnc-invoice-xml-v2.h -- invoice xml i/o parser/unparsers
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_INVOICE_XML_V2_H
-#define GNC_INVOICE_XML_V2_H
-
-void gnc_invoice_xml_initialize (void);
-
-#endif /* GNC_INVOICE_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,361 +0,0 @@
-/********************************************************************\
- * gnc-job-xml-v2.c -- job xml i/o implementation         *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncJobP.h"
-#include "gnc-job-xml-v2.h"
-#include "gnc-owner-xml-v2.h"
-#include "xml-helpers.h"
-
-#define _GNC_MOD_NAME	GNC_ID_JOB
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *job_version_string = "2.0.0";
-
-/* ids */
-#define gnc_job_string "gnc:GncJob"
-#define job_guid_string "job:guid"
-#define job_id_string "job:id"
-#define job_name_string "job:name"
-#define job_reference_string "job:reference"
-#define job_owner_string "job:owner"
-#define job_active_string "job:active"
-#define job_slots_string "job:slots"
-
-static xmlNodePtr
-job_dom_tree_create (GncJob *job)
-{
-    xmlNodePtr ret;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_job_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST job_version_string);
-
-    xmlAddChild(ret, guid_to_dom_tree(job_guid_string,
-                                      qof_instance_get_guid (QOF_INSTANCE (job))));
-
-    xmlAddChild(ret, text_to_dom_tree(job_id_string,
-                                      gncJobGetID (job)));
-
-    xmlAddChild(ret, text_to_dom_tree(job_name_string,
-                                      gncJobGetName (job)));
-
-    maybe_add_string (ret, job_reference_string, gncJobGetReference (job));
-
-    xmlAddChild(ret, gnc_owner_to_dom_tree (job_owner_string,
-                                            gncJobGetOwner (job)));
-
-    xmlAddChild(ret, int_to_dom_tree(job_active_string,
-                                     gncJobGetActive (job)));
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct job_pdata
-{
-    GncJob *job;
-    QofBook *book;
-};
-
-static gboolean
-set_string(xmlNodePtr node, GncJob* job,
-           void (*func)(GncJob *job, const char *txt))
-{
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    func(job, txt);
-
-    g_free(txt);
-
-    return TRUE;
-}
-
-static gboolean
-job_name_handler (xmlNodePtr node, gpointer job_pdata)
-{
-    struct job_pdata *pdata = job_pdata;
-
-    return set_string(node, pdata->job, gncJobSetName);
-}
-
-static gboolean
-job_guid_handler (xmlNodePtr node, gpointer job_pdata)
-{
-    struct job_pdata *pdata = job_pdata;
-    GncGUID *guid;
-    GncJob *job;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail(guid, FALSE);
-    job = gncJobLookup (pdata->book, guid);
-    if (job)
-    {
-        gncJobDestroy (pdata->job);
-        pdata->job = job;
-        gncJobBeginEdit (job);
-    }
-    else
-    {
-        gncJobSetGUID(pdata->job, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-job_id_handler (xmlNodePtr node, gpointer job_pdata)
-{
-    struct job_pdata *pdata = job_pdata;
-
-    return set_string(node, pdata->job, gncJobSetID);
-}
-
-static gboolean
-job_reference_handler (xmlNodePtr node, gpointer job_pdata)
-{
-    struct job_pdata *pdata = job_pdata;
-
-    return set_string(node, pdata->job, gncJobSetReference);
-}
-
-static gboolean
-job_owner_handler (xmlNodePtr node, gpointer job_pdata)
-{
-    struct job_pdata *pdata = job_pdata;
-    GncOwner owner;
-    gboolean ret;
-
-    ret = gnc_dom_tree_to_owner (node, &owner, pdata->book);
-    if (ret)
-        gncJobSetOwner (pdata->job, &owner);
-
-    return ret;
-}
-
-static gboolean
-job_active_handler (xmlNodePtr node, gpointer job_pdata)
-{
-    struct job_pdata *pdata = job_pdata;
-    gint64 val;
-    gboolean ret;
-
-    ret = dom_tree_to_integer(node, &val);
-    if (ret)
-        gncJobSetActive(pdata->job, (gboolean)val);
-
-    return ret;
-}
-
-static gboolean
-job_slots_handler (xmlNodePtr node, gpointer job_pdata)
-{
-    return TRUE;
-}
-
-static struct dom_tree_handler job_handlers_v2[] =
-{
-    { job_guid_string, job_guid_handler, 1, 0 },
-    { job_id_string, job_id_handler, 1, 0 },
-    { job_name_string, job_name_handler, 1, 0 },
-    { job_reference_string, job_reference_handler, 0, 0 },
-    { job_owner_string, job_owner_handler, 1, 0 },
-    { job_active_string, job_active_handler, 1, 0 },
-    { job_slots_string, job_slots_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncJob*
-dom_tree_to_job (xmlNodePtr node, QofBook *book)
-{
-    struct job_pdata job_pdata;
-    gboolean successful;
-
-    job_pdata.job = gncJobCreate(book);
-    job_pdata.book = book;
-    gncJobBeginEdit (job_pdata.job);
-
-    successful = dom_tree_generic_parse (node, job_handlers_v2,
-                                         &job_pdata);
-
-    if (successful)
-        gncJobCommitEdit (job_pdata.job);
-    else
-    {
-        PERR ("failed to parse job tree");
-        gncJobDestroy (job_pdata.job);
-        job_pdata.job = NULL;
-    }
-
-    return job_pdata.job;
-}
-
-static gboolean
-gnc_job_end_handler(gpointer data_for_children,
-                    GSList* data_from_children, GSList* sibling_data,
-                    gpointer parent_data, gpointer global_data,
-                    gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncJob *job;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    job = dom_tree_to_job(tree, book);
-    if (job != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, job);
-    }
-
-    xmlFreeNode(tree);
-
-    return job != NULL;
-}
-
-static sixtp *
-job_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_job_end_handler, NULL, NULL);
-}
-
-static gboolean
-job_should_be_saved (GncJob *job)
-{
-    const char *id;
-
-    /* make sure this is a valid job before we save it -- should have an ID */
-    id = gncJobGetID (job);
-    if (id == NULL || *id == '\0')
-        return FALSE;
-
-    return TRUE;
-}
-
-static void
-do_count (QofInstance * job_p, gpointer count_p)
-{
-    int *count = count_p;
-    if (job_should_be_saved ((GncJob *)job_p))
-        (*count)++;
-}
-
-static int
-job_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_job (QofInstance * job_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncJob *job = (GncJob *) job_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-    if (!job_should_be_saved (job))
-        return;
-
-    node = job_dom_tree_create (job);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-job_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_job, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-static gboolean
-job_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "job");
-}
-
-void
-gnc_job_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_job_string,
-        job_sixtp_parser_create,
-        NULL,			/* add_item */
-        job_get_count,
-        job_write,
-        NULL,			/* scrub */
-        job_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-job-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,29 +0,0 @@
-/*
- * gnc-job-xml-v2.h -- job xml i/o parser/unparsers
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_JOB_XML_V2_H
-#define GNC_JOB_XML_V2_H
-
-void gnc_job_xml_initialize (void);
-
-#endif /* GNC_JOB_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,404 +0,0 @@
-/********************************************************************\
- * gnc-order-xml-v2.c -- order xml i/o implementation         *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncOrderP.h"
-
-#include "gnc-order-xml-v2.h"
-#include "gnc-owner-xml-v2.h"
-
-#define _GNC_MOD_NAME	GNC_ID_ORDER
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *order_version_string = "2.0.0";
-
-/* ids */
-#define gnc_order_string "gnc:GncOrder"
-#define order_guid_string "order:guid"
-#define order_id_string "order:id"
-#define order_owner_string "order:owner"
-#define order_opened_string "order:opened"
-#define order_closed_string "order:closed"
-#define order_notes_string "order:notes"
-#define order_reference_string "order:reference"
-#define order_active_string "order:active"
-#define order_slots_string "order:slots"
-
-static void
-maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
-{
-    if (str && strlen(str) > 0)
-        xmlAddChild (ptr, text_to_dom_tree (tag, str));
-}
-
-static xmlNodePtr
-order_dom_tree_create (GncOrder *order)
-{
-    xmlNodePtr ret;
-    Timespec ts;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_order_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST order_version_string);
-
-    xmlAddChild(ret, guid_to_dom_tree(order_guid_string,
-                                      qof_instance_get_guid(QOF_INSTANCE (order))));
-
-    xmlAddChild(ret, text_to_dom_tree(order_id_string,
-                                      gncOrderGetID (order)));
-
-    xmlAddChild(ret, gnc_owner_to_dom_tree (order_owner_string,
-                                            gncOrderGetOwner (order)));
-
-    ts = gncOrderGetDateOpened (order);
-    xmlAddChild(ret, timespec_to_dom_tree (order_opened_string, &ts));
-
-    ts = gncOrderGetDateClosed (order);
-    if (ts.tv_sec || ts.tv_nsec)
-        xmlAddChild(ret, timespec_to_dom_tree (order_closed_string, &ts));
-
-    maybe_add_string (ret, order_notes_string, gncOrderGetNotes (order));
-    maybe_add_string (ret, order_reference_string, gncOrderGetReference (order));
-
-    xmlAddChild(ret, int_to_dom_tree(order_active_string,
-                                     gncOrderGetActive (order)));
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct order_pdata
-{
-    GncOrder *order;
-    QofBook *book;
-};
-
-static inline gboolean
-set_string(xmlNodePtr node, GncOrder* order,
-           void (*func)(GncOrder *order, const char *txt))
-{
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    func(order, txt);
-
-    g_free(txt);
-    return TRUE;
-}
-
-static inline gboolean
-set_timespec(xmlNodePtr node, GncOrder* order,
-             void (*func)(GncOrder *order, Timespec ts))
-{
-    Timespec ts = dom_tree_to_timespec(node);
-    if (!dom_tree_valid_timespec(&ts, node->name)) return FALSE;
-
-    func(order, ts);
-    return TRUE;
-}
-
-static gboolean
-order_guid_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    struct order_pdata *pdata = order_pdata;
-    GncGUID *guid;
-    GncOrder *order;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    order = gncOrderLookup (pdata->book, guid);
-    if (order)
-    {
-        gncOrderDestroy (pdata->order);
-        pdata->order = order;
-        gncOrderBeginEdit (order);
-    }
-    else
-    {
-        gncOrderSetGUID(pdata->order, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-order_id_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    struct order_pdata *pdata = order_pdata;
-
-    return set_string(node, pdata->order, gncOrderSetID);
-}
-
-static gboolean
-order_owner_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    struct order_pdata *pdata = order_pdata;
-    GncOwner owner;
-    gboolean ret;
-
-    ret = gnc_dom_tree_to_owner (node, &owner, pdata->book);
-    if (ret)
-        gncOrderSetOwner (pdata->order, &owner);
-
-    return ret;
-}
-
-static gboolean
-order_opened_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    struct order_pdata *pdata = order_pdata;
-
-    return set_timespec (node, pdata->order, gncOrderSetDateOpened);
-}
-
-static gboolean
-order_closed_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    struct order_pdata *pdata = order_pdata;
-
-    return set_timespec (node, pdata->order, gncOrderSetDateClosed);
-}
-
-static gboolean
-order_notes_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    struct order_pdata *pdata = order_pdata;
-
-    return set_string(node, pdata->order, gncOrderSetNotes);
-}
-
-static gboolean
-order_reference_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    struct order_pdata *pdata = order_pdata;
-
-    return set_string(node, pdata->order, gncOrderSetReference);
-}
-
-static gboolean
-order_active_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    struct order_pdata *pdata = order_pdata;
-    gint64 val;
-    gboolean ret;
-
-    ret = dom_tree_to_integer(node, &val);
-    if (ret)
-        gncOrderSetActive(pdata->order, (gboolean)val);
-
-    return ret;
-}
-
-static gboolean
-order_slots_handler (xmlNodePtr node, gpointer order_pdata)
-{
-    return TRUE;
-}
-
-static struct dom_tree_handler order_handlers_v2[] =
-{
-    { order_guid_string, order_guid_handler, 1, 0 },
-    { order_id_string, order_id_handler, 1, 0 },
-    { order_owner_string, order_owner_handler, 1, 0 },
-    { order_opened_string, order_opened_handler, 1, 0 },
-    { order_closed_string, order_closed_handler, 0, 0 },
-    { order_notes_string, order_notes_handler, 0, 0 },
-    { order_reference_string, order_reference_handler, 0, 0 },
-    { order_active_string, order_active_handler, 1, 0 },
-    { order_slots_string, order_slots_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncOrder*
-dom_tree_to_order (xmlNodePtr node, QofBook *book)
-{
-    struct order_pdata order_pdata;
-    gboolean successful;
-
-    order_pdata.order = gncOrderCreate(book);
-    order_pdata.book = book;
-    gncOrderBeginEdit (order_pdata.order);
-
-    successful = dom_tree_generic_parse (node, order_handlers_v2,
-                                         &order_pdata);
-
-    if (successful)
-        gncOrderCommitEdit (order_pdata.order);
-    else
-    {
-        PERR ("failed to parse order tree");
-        gncOrderDestroy (order_pdata.order);
-        order_pdata.order = NULL;
-    }
-
-    return order_pdata.order;
-}
-
-static gboolean
-gnc_order_end_handler(gpointer data_for_children,
-                      GSList* data_from_children, GSList* sibling_data,
-                      gpointer parent_data, gpointer global_data,
-                      gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncOrder *order;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    order = dom_tree_to_order(tree, book);
-    if (order != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, order);
-    }
-
-    xmlFreeNode(tree);
-
-    return order != NULL;
-}
-
-static sixtp *
-order_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_order_end_handler, NULL, NULL);
-}
-
-static gboolean
-order_should_be_saved (GncOrder *order)
-{
-    const char *id;
-
-    /* make sure this is a valid order before we save it -- should have an ID */
-    id = gncOrderGetID (order);
-    if (id == NULL || *id == '\0')
-        return FALSE;
-
-    return TRUE;
-}
-
-static void
-do_count (QofInstance * order_p, gpointer count_p)
-{
-    int *count = count_p;
-    if (order_should_be_saved ((GncOrder *) order_p))
-        (*count)++;
-}
-
-static int
-order_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_order (QofInstance * order_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncOrder *order = (GncOrder *) order_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-    if (!order_should_be_saved (order))
-        return;
-
-    node = order_dom_tree_create (order);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-order_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_order, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-static gboolean
-order_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "order");
-}
-
-void
-gnc_order_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_order_string,
-        order_sixtp_parser_create,
-        NULL,			/* add_item */
-        order_get_count,
-        order_write,
-        NULL,			/* scrub */
-        order_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-order-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,29 +0,0 @@
-/*
- * gnc-order-xml-v2.h -- order xml i/o parser/unparsers
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_ORDER_XML_V2_H
-#define GNC_ORDER_XML_V2_H
-
-void gnc_order_xml_initialize (void);
-
-#endif /* GNC_ORDER_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,244 +0,0 @@
-/********************************************************************\
- * gnc-owner-xml-v2.c -- owner xml i/o implementation           *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gnc-owner-xml-v2.h"
-#include "gncCustomerP.h"
-#include "gncJobP.h"
-#include "gncVendorP.h"
-#include "gncEmployeeP.h"
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *owner_version_string = "2.0.0";
-
-/* ids */
-#define owner_type_string	"owner:type"
-#define owner_id_string		"owner:id"
-
-xmlNodePtr
-gnc_owner_to_dom_tree (const char *tag, GncOwner *owner)
-{
-    xmlNodePtr ret;
-    const char *type_str;
-
-    switch (gncOwnerGetType (owner))
-    {
-    case GNC_OWNER_CUSTOMER:
-        type_str = GNC_ID_CUSTOMER;
-        break;
-    case GNC_OWNER_JOB:
-        type_str = GNC_ID_JOB;
-        break;
-    case GNC_OWNER_VENDOR:
-        type_str = GNC_ID_VENDOR;
-        break;
-    case GNC_OWNER_EMPLOYEE:
-        type_str = GNC_ID_EMPLOYEE;
-        break;
-    default:
-        PWARN ("Invalid owner type: %d", gncOwnerGetType (owner));
-        return NULL;
-    }
-
-    ret = xmlNewNode(NULL, BAD_CAST tag);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST owner_version_string);
-
-    xmlAddChild (ret, text_to_dom_tree (owner_type_string, type_str));
-    xmlAddChild (ret, guid_to_dom_tree (owner_id_string,
-                                        gncOwnerGetGUID (owner)));
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct owner_pdata
-{
-    GncOwner *owner;
-    QofBook *book;
-};
-
-static gboolean
-owner_type_handler (xmlNodePtr node, gpointer owner_pdata)
-{
-    struct owner_pdata *pdata = owner_pdata;
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    if (!safe_strcmp (txt, GNC_ID_CUSTOMER))
-        gncOwnerInitCustomer (pdata->owner, NULL);
-    else if (!safe_strcmp (txt, GNC_ID_JOB))
-        gncOwnerInitJob (pdata->owner, NULL);
-    else if (!safe_strcmp (txt, GNC_ID_VENDOR))
-        gncOwnerInitVendor (pdata->owner, NULL);
-    else if (!safe_strcmp (txt, GNC_ID_EMPLOYEE))
-        gncOwnerInitEmployee (pdata->owner, NULL);
-    else
-    {
-        PWARN ("Unknown owner type: %s", txt);
-        g_free(txt);
-        return FALSE;
-    }
-
-    g_free(txt);
-    return TRUE;
-}
-
-static gboolean
-owner_id_handler (xmlNodePtr node, gpointer owner_pdata)
-{
-    struct owner_pdata *pdata = owner_pdata;
-    GncGUID *guid;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-
-    switch (gncOwnerGetType (pdata->owner))
-    {
-    case GNC_OWNER_CUSTOMER:
-    {
-        GncCustomer *cust = gncCustomerLookup (pdata->book, guid);
-        if (!cust)
-        {
-            cust = gncCustomerCreate (pdata->book);
-            gncCustomerSetGUID (cust, guid);
-        }
-        gncOwnerInitCustomer (pdata->owner, cust);
-        break;
-    }
-    case GNC_OWNER_JOB:
-    {
-        GncJob *job = gncJobLookup (pdata->book, guid);
-        if (!job)
-        {
-            job = gncJobCreate (pdata->book);
-            gncJobSetGUID (job, guid);
-        }
-        gncOwnerInitJob (pdata->owner, job);
-        break;
-    }
-    case GNC_OWNER_VENDOR:
-    {
-        GncVendor *vendor = gncVendorLookup (pdata->book, guid);
-        if (!vendor)
-        {
-            vendor = gncVendorCreate (pdata->book);
-            gncVendorSetGUID (vendor, guid);
-        }
-        gncOwnerInitVendor (pdata->owner, vendor);
-        break;
-    }
-    case GNC_OWNER_EMPLOYEE:
-    {
-        GncEmployee *employee = gncEmployeeLookup (pdata->book, guid);
-        if (!employee)
-        {
-            employee = gncEmployeeCreate (pdata->book);
-            gncEmployeeSetGUID (employee, guid);
-        }
-        gncOwnerInitEmployee (pdata->owner, employee);
-        break;
-    }
-    default:
-        PWARN ("Invalid owner type: %d\n", gncOwnerGetType (pdata->owner));
-        g_free (guid);
-        return FALSE;
-    }
-
-    g_free (guid);
-    return TRUE;
-}
-
-static struct dom_tree_handler owner_handlers_v2[] =
-{
-    { owner_type_string, owner_type_handler, 1, 0 },
-    { owner_id_string, owner_id_handler, 1, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-gboolean
-gnc_dom_tree_to_owner (xmlNodePtr node, GncOwner *owner, QofBook *book)
-{
-    struct owner_pdata owner_pdata;
-    gboolean successful;
-
-    owner_pdata.owner = owner;
-    owner_pdata.book = book;
-
-    successful = dom_tree_generic_parse (node, owner_handlers_v2,
-                                         &owner_pdata);
-
-    if (!successful)
-    {
-        PERR ("failed to parse owner tree");
-    }
-
-    return successful;
-}
-
-static gboolean
-owner_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "owner");
-}
-
-void
-gnc_owner_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        "gnc:Owner",
-        NULL,			/* parser_create */
-        NULL,			/* add_item */
-        NULL,			/* get_count */
-        NULL,			/* write */
-        NULL,			/* scrub */
-        owner_ns,
-    };
-
-    qof_object_register_backend ("gnc:Owner",
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-owner-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,34 +0,0 @@
-/* gnc-owner-xml-v2.h -- Owner XML header
- *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_OWNER_XML_V2_H
-#define GNC_OWNER_XML_V2_H
-
-#include "gncOwner.h"
-#include "qof.h"
-
-gboolean   gnc_dom_tree_to_owner (xmlNodePtr node, GncOwner *owner,
-                                  QofBook *book);
-xmlNodePtr gnc_owner_to_dom_tree (const char *tag, GncOwner *addr);
-void gnc_owner_xml_initialize (void);
-
-#endif /* GNC_OWNER_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,716 +0,0 @@
-/********************************************************************\
- * gnc-tax-table-xml-v2.c -- tax table xml i/o implementation       *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncEntry.h"
-#include "gncTaxTableP.h"
-#include "gnc-tax-table-xml-v2.h"
-
-#define _GNC_MOD_NAME	GNC_ID_TAXTABLE
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *taxtable_version_string = "2.0.0";
-
-/* ids */
-#define gnc_taxtable_string "gnc:GncTaxTable"
-#define taxtable_guid_string "taxtable:guid"
-#define taxtable_name_string "taxtable:name"
-#define taxtable_refcount_string "taxtable:refcount"
-#define taxtable_invisible_string "taxtable:invisible"
-#define taxtable_parent_string "taxtable:parent"
-#define taxtable_child_string "taxtable:child"
-#define taxtable_entries_string "taxtable:entries"
-#define taxtable_slots_string "taxtable:slots"
-
-#define gnc_taxtableentry_string "gnc:GncTaxTableEntry"
-#define ttentry_account_string "tte:acct"
-#define ttentry_type_string "tte:type"
-#define ttentry_amount_string "tte:amount"
-
-static void
-maybe_add_guid (xmlNodePtr ptr, const char *tag, GncTaxTable *table)
-{
-    if (table)
-        xmlAddChild (ptr, guid_to_dom_tree (tag,
-                                            qof_instance_get_guid(QOF_INSTANCE(table))));
-}
-
-static xmlNodePtr
-ttentry_dom_tree_create (GncTaxTableEntry *entry)
-{
-    xmlNodePtr ret;
-    Account *account;
-    gnc_numeric amount;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_taxtableentry_string);
-
-    account = gncTaxTableEntryGetAccount (entry);
-    if (account)
-        xmlAddChild(ret, guid_to_dom_tree (ttentry_account_string,
-                                           qof_instance_get_guid (QOF_INSTANCE(account))));
-
-    amount = gncTaxTableEntryGetAmount (entry);
-    xmlAddChild (ret, gnc_numeric_to_dom_tree (ttentry_amount_string, &amount));
-
-    xmlAddChild(ret, text_to_dom_tree (ttentry_type_string,
-                                       gncAmountTypeToString (
-                                           gncTaxTableEntryGetType (entry))));
-
-    return ret;
-}
-
-static xmlNodePtr
-taxtable_dom_tree_create (GncTaxTable *table)
-{
-    xmlNodePtr ret, entries;
-    GList *list;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_taxtable_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST taxtable_version_string);
-
-    maybe_add_guid(ret, taxtable_guid_string, table);
-    xmlAddChild(ret, text_to_dom_tree (taxtable_name_string,
-                                       gncTaxTableGetName (table)));
-
-    xmlAddChild(ret, int_to_dom_tree (taxtable_refcount_string,
-                                      gncTaxTableGetRefcount (table)));
-    xmlAddChild(ret, int_to_dom_tree (taxtable_invisible_string,
-                                      gncTaxTableGetInvisible (table)));
-
-    /* We should not be our own child */
-    if (gncTaxTableGetChild(table) != table)
-        maybe_add_guid(ret, taxtable_child_string, gncTaxTableGetChild (table));
-
-    maybe_add_guid(ret, taxtable_parent_string, gncTaxTableGetParent (table));
-
-    entries = xmlNewChild (ret, NULL, BAD_CAST taxtable_entries_string, NULL);
-    for (list = gncTaxTableGetEntries (table); list; list = list->next)
-    {
-        GncTaxTableEntry *entry = list->data;
-        xmlAddChild(entries, ttentry_dom_tree_create (entry));
-    }
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct ttentry_pdata
-{
-    GncTaxTableEntry *ttentry;
-    QofBook *book;
-};
-
-static gboolean
-ttentry_acct_handler (xmlNodePtr node, gpointer ttentry_pdata)
-{
-    struct ttentry_pdata *pdata = ttentry_pdata;
-    GncGUID *guid;
-    Account * acc;
-
-    guid = dom_tree_to_guid (node);
-    g_return_val_if_fail (guid, FALSE);
-    acc = xaccAccountLookup (guid, pdata->book);
-    g_free (guid);
-    g_return_val_if_fail (acc, FALSE);
-
-    gncTaxTableEntrySetAccount (pdata->ttentry, acc);
-    return TRUE;
-}
-
-static gboolean
-ttentry_type_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    struct ttentry_pdata *pdata = taxtable_pdata;
-    GncAmountType type;
-    char *str;
-    gboolean ret;
-
-    str = dom_tree_to_text (node);
-    g_return_val_if_fail (str, FALSE);
-
-    ret = gncAmountStringToType (str, &type);
-    g_free (str);
-
-    if (ret)
-        gncTaxTableEntrySetType (pdata->ttentry, type);
-
-    return ret;
-}
-
-static gboolean
-ttentry_amount_handler (xmlNodePtr node, gpointer ttentry_pdata)
-{
-    struct ttentry_pdata *pdata = ttentry_pdata;
-    gnc_numeric* num = dom_tree_to_gnc_numeric(node);
-    g_return_val_if_fail(num, FALSE);
-
-    gncTaxTableEntrySetAmount (pdata->ttentry, *num);
-    g_free(num);
-    return TRUE;
-}
-
-static struct dom_tree_handler ttentry_handlers_v2[] =
-{
-    { ttentry_account_string, ttentry_acct_handler, 0, 0 },
-    { ttentry_type_string, ttentry_type_handler, 1, 0 },
-    { ttentry_amount_string, ttentry_amount_handler, 1, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncTaxTableEntry*
-dom_tree_to_ttentry (xmlNodePtr node, QofBook *book)
-{
-    struct ttentry_pdata ttentry_pdata;
-    gboolean successful;
-
-    ttentry_pdata.ttentry = gncTaxTableEntryCreate ();
-    ttentry_pdata.book = book;
-
-    successful = dom_tree_generic_parse (node, ttentry_handlers_v2,
-                                         &ttentry_pdata);
-
-    if (!successful)
-    {
-        PERR ("failed to parse tax table entry tree");
-        gncTaxTableEntryDestroy (ttentry_pdata.ttentry);
-        ttentry_pdata.ttentry = NULL;
-    }
-
-    return ttentry_pdata.ttentry;
-}
-
-/***********************************************************************/
-
-struct taxtable_pdata
-{
-    GncTaxTable *table;
-    QofBook *book;
-};
-
-static gboolean
-set_parent_child (xmlNodePtr node, struct taxtable_pdata *pdata,
-                  void (*func)(GncTaxTable *, GncTaxTable *))
-{
-    GncGUID *guid;
-    GncTaxTable *table;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    table = gncTaxTableLookup (pdata->book, guid);
-
-    /* Ignore pointers to self */
-    if (table == pdata->table)
-    {
-        PINFO ("found a self-referential parent/child; ignoring.\n");
-        return TRUE;
-    }
-
-    if (!table)
-    {
-        table = gncTaxTableCreate (pdata->book);
-        gncTaxTableBeginEdit (table);
-        gncTaxTableSetGUID (table, guid);
-        gncTaxTableCommitEdit (table);
-    }
-    g_free (guid);
-    g_return_val_if_fail (table, FALSE);
-    func (pdata->table, table);
-
-    return TRUE;
-}
-
-static gboolean
-taxtable_guid_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    struct taxtable_pdata *pdata = taxtable_pdata;
-    GncGUID *guid;
-    GncTaxTable *table;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    table = gncTaxTableLookup (pdata->book, guid);
-    if (table)
-    {
-        gncTaxTableDestroy (pdata->table);
-        pdata->table = table;
-        gncTaxTableBeginEdit (table);
-    }
-    else
-    {
-        gncTaxTableSetGUID(pdata->table, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-taxtable_name_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    struct taxtable_pdata *pdata = taxtable_pdata;
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    gncTaxTableSetName (pdata->table, txt);
-    g_free(txt);
-    return TRUE;
-}
-
-static gboolean
-taxtable_refcount_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    struct taxtable_pdata *pdata = taxtable_pdata;
-    gint64 val;
-
-    dom_tree_to_integer(node, &val);
-    gncTaxTableSetRefcount (pdata->table, val);
-    return TRUE;
-}
-
-static gboolean
-taxtable_invisible_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    struct taxtable_pdata *pdata = taxtable_pdata;
-    gint64 val;
-
-    dom_tree_to_integer(node, &val);
-    if (val)
-        gncTaxTableMakeInvisible (pdata->table);
-    return TRUE;
-}
-
-static gboolean
-taxtable_parent_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    struct taxtable_pdata *pdata = taxtable_pdata;
-    return set_parent_child (node, pdata, gncTaxTableSetParent);
-}
-
-static gboolean
-taxtable_child_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    struct taxtable_pdata *pdata = taxtable_pdata;
-    return set_parent_child (node, pdata, gncTaxTableSetChild);
-}
-
-static gboolean
-taxtable_entries_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    struct taxtable_pdata *pdata = taxtable_pdata;
-    xmlNodePtr mark;
-
-    g_return_val_if_fail (node, FALSE);
-    g_return_val_if_fail (node->xmlChildrenNode, FALSE);
-
-    for (mark = node->xmlChildrenNode; mark; mark = mark->next)
-    {
-        GncTaxTableEntry *entry;
-
-        if (safe_strcmp ("text", (char*)mark->name) == 0)
-            continue;
-
-        if (safe_strcmp (gnc_taxtableentry_string, (char*)mark->name))
-            return FALSE;
-
-        entry = dom_tree_to_ttentry (mark, pdata->book);
-
-        if (entry)
-            gncTaxTableAddEntry (pdata->table, entry);
-        else
-            return FALSE;
-
-    }
-    return TRUE;
-}
-
-static gboolean
-taxtable_slots_handler (xmlNodePtr node, gpointer taxtable_pdata)
-{
-    return TRUE;
-}
-
-static struct dom_tree_handler taxtable_handlers_v2[] =
-{
-    { taxtable_guid_string, taxtable_guid_handler, 1, 0 },
-    { taxtable_name_string, taxtable_name_handler, 1, 0 },
-    { taxtable_refcount_string, taxtable_refcount_handler, 1, 0 },
-    { taxtable_invisible_string, taxtable_invisible_handler, 1, 0 },
-    { taxtable_parent_string, taxtable_parent_handler, 0, 0 },
-    { taxtable_child_string, taxtable_child_handler, 0, 0 },
-    { taxtable_entries_string, taxtable_entries_handler, 1, 0 },
-    { taxtable_slots_string, taxtable_slots_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncTaxTable*
-dom_tree_to_taxtable (xmlNodePtr node, QofBook *book)
-{
-    struct taxtable_pdata taxtable_pdata;
-    gboolean successful;
-
-    taxtable_pdata.table = gncTaxTableCreate (book);
-    taxtable_pdata.book = book;
-    gncTaxTableBeginEdit (taxtable_pdata.table);
-
-    successful = dom_tree_generic_parse (node, taxtable_handlers_v2,
-                                         &taxtable_pdata);
-
-    if (successful)
-        gncTaxTableCommitEdit (taxtable_pdata.table);
-    else
-    {
-        PERR ("failed to parse tax table tree");
-        gncTaxTableDestroy (taxtable_pdata.table);
-        taxtable_pdata.table = NULL;
-    }
-
-    return taxtable_pdata.table;
-}
-
-static gboolean
-gnc_taxtable_end_handler(gpointer data_for_children,
-                         GSList* data_from_children, GSList* sibling_data,
-                         gpointer parent_data, gpointer global_data,
-                         gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncTaxTable *table;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    table = dom_tree_to_taxtable (tree, book);
-    if (table != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, table);
-    }
-
-    xmlFreeNode(tree);
-
-    return table != NULL;
-}
-
-static sixtp *
-taxtable_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_taxtable_end_handler, NULL, NULL);
-}
-
-static void
-do_count (QofInstance * table_p, gpointer count_p)
-{
-    int *count = count_p;
-    (*count)++;
-}
-
-static int
-taxtable_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_taxtable (QofInstance * table_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncTaxTable *table = (GncTaxTable *) table_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-
-    node = taxtable_dom_tree_create (table);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-taxtable_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_taxtable, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-
-static gboolean
-taxtable_is_grandchild (GncTaxTable *table)
-{
-    return (gncTaxTableGetParent(gncTaxTableGetParent(table)) != NULL);
-}
-
-static GncTaxTable *
-taxtable_find_senior (GncTaxTable *table)
-{
-    GncTaxTable *temp, *parent, *gp = NULL;
-
-    temp = table;
-    do
-    {
-        /* See if "temp" is a grandchild */
-        parent = gncTaxTableGetParent(temp);
-        if (!parent)
-            break;
-        gp = gncTaxTableGetParent(parent);
-        if (!gp)
-            break;
-
-        /* Yep, this is a grandchild.  Move up one generation and try again */
-        temp = parent;
-    }
-    while (TRUE);
-
-    /* Ok, at this point temp points to the most senior child and parent
-     * should point to the top taxtable (and gp should be NULL).  If
-     * parent is NULL then we are the most senior child (and have no
-     * children), so do nothing.  If temp == table then there is no
-     * grandparent, so do nothing.
-     *
-     * Do something if parent != NULL && temp != table
-     */
-    g_assert (gp == NULL);
-
-    /* return the most senior table */
-    return temp;
-}
-
-/* build a list of tax tables that are grandchildren or bogus (empty entry list). */
-static void
-taxtable_scrub_cb (QofInstance * table_p, gpointer list_p)
-{
-    GncTaxTable *table = GNC_TAXTABLE(table_p);
-    GList **list = list_p;
-
-    if (taxtable_is_grandchild(table) || gncTaxTableGetEntries(table) == NULL)
-        *list = g_list_prepend(*list, table);
-}
-
-/* for each entry, check the tax tables.  If the tax tables are
- * grandchildren, then fix them to point to the most senior child
- */
-static void
-taxtable_scrub_entries (QofInstance * entry_p, gpointer ht_p)
-{
-    GHashTable *ht = ht_p;
-    GncEntry *entry = GNC_ENTRY(entry_p);
-    GncTaxTable *table, *new_tt;
-    gint32 count;
-
-    table = gncEntryGetInvTaxTable(entry);
-    if (table)
-    {
-        if (taxtable_is_grandchild(table))
-        {
-            PINFO("Fixing i-taxtable on entry %s\n",
-                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(entry))));
-            new_tt = taxtable_find_senior(table);
-            gncEntryBeginEdit(entry);
-            gncEntrySetInvTaxTable(entry, new_tt);
-            gncEntryCommitEdit(entry);
-            table = new_tt;
-        }
-        if (table)
-        {
-            count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
-            count++;
-            g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
-        }
-    }
-
-    table = gncEntryGetBillTaxTable(entry);
-    if (table)
-    {
-        if (taxtable_is_grandchild(table))
-        {
-            PINFO("Fixing b-taxtable on entry %s\n",
-                  guid_to_string(qof_instance_get_guid(QOF_INSTANCE(entry))));
-            new_tt = taxtable_find_senior(table);
-            gncEntryBeginEdit(entry);
-            gncEntrySetBillTaxTable(entry, new_tt);
-            gncEntryCommitEdit(entry);
-            table = new_tt;
-        }
-        if (table)
-        {
-            count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
-            count++;
-            g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
-        }
-    }
-}
-
-static void
-taxtable_scrub_cust (QofInstance * cust_p, gpointer ht_p)
-{
-    GHashTable *ht = ht_p;
-    GncCustomer *cust = GNC_CUSTOMER(cust_p);
-    GncTaxTable *table;
-    gint32 count;
-
-    table = gncCustomerGetTaxTable(cust);
-    if (table)
-    {
-        count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
-        count++;
-        g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
-    }
-}
-
-static void
-taxtable_scrub_vendor (QofInstance * vendor_p, gpointer ht_p)
-{
-    GHashTable *ht = ht_p;
-    GncVendor *vendor = GNC_VENDOR(vendor_p);
-    GncTaxTable *table;
-    gint32 count;
-
-    table = gncVendorGetTaxTable(vendor);
-    if (table)
-    {
-        count = GPOINTER_TO_INT(g_hash_table_lookup(ht, table));
-        count++;
-        g_hash_table_insert(ht, table, GINT_TO_POINTER(count));
-    }
-}
-
-static void
-taxtable_reset_refcount (gpointer key, gpointer value, gpointer notused)
-{
-    GncTaxTable *table = key;
-    gint32 count = GPOINTER_TO_INT(value);
-
-    if (count != gncTaxTableGetRefcount(table) && !gncTaxTableGetInvisible(table))
-    {
-        PWARN("Fixing refcount on taxtable %s (%" G_GINT64_FORMAT " -> %d)\n",
-              guid_to_string(qof_instance_get_guid(QOF_INSTANCE(table))),
-              gncTaxTableGetRefcount(table), count);
-        gncTaxTableSetRefcount(table, count);
-    }
-}
-
-static void
-taxtable_scrub (QofBook *book)
-{
-    GList *list = NULL;
-    GList *node;
-    GncTaxTable *parent, *table;
-    GHashTable *ht = g_hash_table_new(g_direct_hash, g_direct_equal);
-
-    qof_object_foreach (GNC_ID_ENTRY, book, taxtable_scrub_entries, ht);
-    qof_object_foreach (GNC_ID_CUSTOMER, book, taxtable_scrub_cust, ht);
-    qof_object_foreach (GNC_ID_VENDOR, book, taxtable_scrub_vendor, ht);
-    qof_object_foreach (GNC_ID_TAXTABLE, book, taxtable_scrub_cb, &list);
-
-    /* destroy the list of "grandchildren" tax tables */
-    for (node = list; node; node = node->next)
-    {
-        table = node->data;
-
-        PINFO ("deleting grandchild taxtable: %s\n",
-               guid_to_string(qof_instance_get_guid(QOF_INSTANCE(table))));
-
-        /* Make sure the parent has no children */
-        parent = gncTaxTableGetParent(table);
-        gncTaxTableSetChild(parent, NULL);
-
-        /* Destroy this tax table */
-        gncTaxTableBeginEdit(table);
-        gncTaxTableDestroy(table);
-    }
-
-    /* reset the refcounts as necessary */
-    g_hash_table_foreach(ht, taxtable_reset_refcount, NULL);
-
-    g_list_free(list);
-    g_hash_table_destroy(ht);
-}
-
-static gboolean
-taxtable_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return
-        gnc_xml2_write_namespace_decl(out, "taxtable")
-        && gnc_xml2_write_namespace_decl(out, "tte");
-}
-
-void
-gnc_taxtable_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_taxtable_string,
-        taxtable_sixtp_parser_create,
-        NULL,			/* add_item */
-        taxtable_get_count,
-        taxtable_write,
-        taxtable_scrub,
-        taxtable_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-tax-table-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,29 +0,0 @@
-/*
- * gnc-tax-table-xml-v2.h -- tax table xml i/o parser/unparsers
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_TAXTABLE_XML_V2_H
-#define GNC_TAXTABLE_XML_V2_H
-
-void gnc_taxtable_xml_initialize (void);
-
-#endif /* GNC_TAXTABLE_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.c
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.c	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.c	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,489 +0,0 @@
-/********************************************************************\
- * gnc-vendor-xml-v2.c -- vendor xml i/o implementation         *
- *                                                                  *
- * Copyright (C) 2002 Derek Atkins <warlord at MIT.EDU>                *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
-
-#include "config.h"
-
-#include <glib.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "gnc-xml-helper.h"
-
-#include "sixtp.h"
-#include "sixtp-utils.h"
-#include "sixtp-parsers.h"
-#include "sixtp-utils.h"
-#include "sixtp-dom-parsers.h"
-#include "sixtp-dom-generators.h"
-
-#include "gnc-xml.h"
-#include "io-gncxml-gen.h"
-#include "io-gncxml-v2.h"
-
-#include "gncBillTermP.h"
-#include "gncVendorP.h"
-#include "gncTaxTableP.h"
-#include "gnc-vendor-xml-v2.h"
-#include "gnc-address-xml-v2.h"
-#include "xml-helpers.h"
-#include "gnc-bill-term-xml-v2.h"
-
-#define _GNC_MOD_NAME	GNC_ID_VENDOR
-
-static QofLogModule log_module = GNC_MOD_IO;
-
-const gchar *vendor_version_string = "2.0.0";
-
-/* ids */
-#define gnc_vendor_string "gnc:GncVendor"
-#define vendor_name_string "vendor:name"
-#define vendor_guid_string "vendor:guid"
-#define vendor_id_string "vendor:id"
-#define vendor_addr_string "vendor:addr"
-#define vendor_notes_string "vendor:notes"
-#define vendor_terms_string "vendor:terms"
-#define vendor_taxincluded_string "vendor:taxincluded"
-#define vendor_active_string "vendor:active"
-#define vendor_currency_string "vendor:currency"
-#define vendor_taxtable_string "vendor:taxtable"
-#define vendor_taxtableoverride_string "vendor:use-tt"
-#define vendor_slots_string "vendor:slots"
-
-static xmlNodePtr
-vendor_dom_tree_create (GncVendor *vendor)
-{
-    xmlNodePtr ret, kvpnode;
-    GncBillTerm *term;
-    GncTaxTable *taxtable;
-
-    ret = xmlNewNode(NULL, BAD_CAST gnc_vendor_string);
-    xmlSetProp(ret, BAD_CAST "version", BAD_CAST vendor_version_string);
-
-    xmlAddChild(ret, guid_to_dom_tree(vendor_guid_string,
-                                      qof_instance_get_guid (QOF_INSTANCE(vendor))));
-
-    xmlAddChild(ret, text_to_dom_tree(vendor_name_string,
-                                      gncVendorGetName (vendor)));
-
-    xmlAddChild(ret, text_to_dom_tree(vendor_id_string,
-                                      gncVendorGetID (vendor)));
-
-    xmlAddChild(ret, gnc_address_to_dom_tree(vendor_addr_string,
-                gncVendorGetAddr (vendor)));
-
-    maybe_add_string (ret, vendor_notes_string, gncVendorGetNotes (vendor));
-
-    term = gncVendorGetTerms (vendor);
-    if (term)
-        xmlAddChild(ret, guid_to_dom_tree(vendor_terms_string,
-                                          qof_instance_get_guid(QOF_INSTANCE(term))));
-
-    xmlAddChild(ret, text_to_dom_tree(vendor_taxincluded_string,
-                                      gncTaxIncludedTypeToString (
-                                          gncVendorGetTaxIncluded (vendor))));
-
-    xmlAddChild(ret, int_to_dom_tree(vendor_active_string,
-                                     gncVendorGetActive (vendor)));
-
-    xmlAddChild
-    (ret,
-     commodity_ref_to_dom_tree(vendor_currency_string,
-                               gncVendorGetCurrency (vendor)));
-
-    xmlAddChild (ret, int_to_dom_tree (vendor_taxtableoverride_string,
-                                       gncVendorGetTaxTableOverride (vendor)));
-    taxtable = gncVendorGetTaxTable (vendor);
-    if (taxtable)
-        xmlAddChild (ret, guid_to_dom_tree (vendor_taxtable_string,
-                                            qof_instance_get_guid(QOF_INSTANCE(taxtable))));
-
-    kvpnode = kvp_frame_to_dom_tree (vendor_slots_string,
-                                     qof_instance_get_slots (QOF_INSTANCE(vendor)));
-    if (kvpnode) xmlAddChild (ret, kvpnode);
-
-    return ret;
-}
-
-/***********************************************************************/
-
-struct vendor_pdata
-{
-    GncVendor *vendor;
-    QofBook *book;
-};
-
-static gboolean
-set_string(xmlNodePtr node, GncVendor* vendor,
-           void (*func)(GncVendor *vendor, const char *txt))
-{
-    char* txt = dom_tree_to_text(node);
-    g_return_val_if_fail(txt, FALSE);
-
-    func(vendor, txt);
-
-    g_free(txt);
-
-    return TRUE;
-}
-
-static gboolean
-set_boolean(xmlNodePtr node, GncVendor* vendor,
-            void (*func)(GncVendor* vendor, gboolean b))
-{
-    gint64 val;
-    gboolean ret;
-
-    ret = dom_tree_to_integer(node, &val);
-    if (ret)
-        func(vendor, (gboolean)val);
-
-    return ret;
-}
-
-static gboolean
-vendor_name_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-
-    return set_string(node, pdata->vendor, gncVendorSetName);
-}
-
-static gboolean
-vendor_guid_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-    GncGUID *guid;
-    GncVendor *vendor;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail(guid, FALSE);
-    vendor = gncVendorLookup (pdata->book, guid);
-    if (vendor)
-    {
-        gncVendorDestroy (pdata->vendor);
-        pdata->vendor = vendor;
-        gncVendorBeginEdit (vendor);
-    }
-    else
-    {
-        gncVendorSetGUID(pdata->vendor, guid);
-    }
-
-    g_free(guid);
-
-    return TRUE;
-}
-
-static gboolean
-vendor_id_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-
-    return set_string(node, pdata->vendor, gncVendorSetID);
-}
-
-static gboolean
-vendor_notes_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-
-    return set_string(node, pdata->vendor, gncVendorSetNotes);
-}
-
-static gboolean
-vendor_terms_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-    GncGUID *guid;
-    GncBillTerm *term;
-
-    guid = dom_tree_to_guid(node);
-    g_return_val_if_fail (guid, FALSE);
-    term = gnc_billterm_xml_find_or_create(pdata->book, guid);
-    g_assert(term);
-    g_free (guid);
-    gncVendorSetTerms (pdata->vendor, term);
-
-    return TRUE;
-}
-
-static gboolean
-vendor_addr_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-
-    return gnc_dom_tree_to_address (node, gncVendorGetAddr(pdata->vendor));
-}
-
-static gboolean
-vendor_taxincluded_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-    GncTaxIncluded type;
-    char *str;
-    gboolean ret;
-
-    str = dom_tree_to_text (node);
-    g_return_val_if_fail (str, FALSE);
-
-    ret = gncTaxIncludedStringToType (str, &type);
-    g_free (str);
-
-    if (ret)
-        gncVendorSetTaxIncluded(pdata->vendor, type);
-
-    return ret;
-}
-
-static gboolean
-vendor_active_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-    return set_boolean (node, pdata->vendor, gncVendorSetActive);
-}
-
-static gboolean
-vendor_currency_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-    gnc_commodity *com;
-
-    com = dom_tree_to_commodity_ref(node, pdata->book);
-    g_return_val_if_fail (com, FALSE);
-
-    gncVendorSetCurrency (pdata->vendor, com);
-
-    return TRUE;
-}
-
-static gboolean
-vendor_taxtable_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-    GncGUID *guid;
-    GncTaxTable *taxtable;
-
-    guid = dom_tree_to_guid (node);
-    g_return_val_if_fail (guid, FALSE);
-    taxtable = gncTaxTableLookup (pdata->book, guid);
-    if (!taxtable)
-    {
-        taxtable = gncTaxTableCreate (pdata->book);
-        gncTaxTableBeginEdit (taxtable);
-        gncTaxTableSetGUID (taxtable, guid);
-        gncTaxTableCommitEdit (taxtable);
-    }
-    else
-        gncTaxTableDecRef (taxtable);
-
-    gncVendorSetTaxTable (pdata->vendor, taxtable);
-    g_free(guid);
-    return TRUE;
-}
-
-static gboolean
-vendor_taxtableoverride_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-    return set_boolean (node, pdata->vendor, gncVendorSetTaxTableOverride);
-}
-
-static gboolean
-vendor_slots_handler (xmlNodePtr node, gpointer vendor_pdata)
-{
-    struct vendor_pdata *pdata = vendor_pdata;
-    return dom_tree_to_kvp_frame_given (
-               node, qof_instance_get_slots (QOF_INSTANCE(pdata->vendor)));
-
-}
-
-static struct dom_tree_handler vendor_handlers_v2[] =
-{
-    { vendor_name_string, vendor_name_handler, 1, 0 },
-    { vendor_guid_string, vendor_guid_handler, 1, 0 },
-    { vendor_id_string, vendor_id_handler, 1, 0 },
-    { vendor_addr_string, vendor_addr_handler, 1, 0 },
-    { vendor_notes_string, vendor_notes_handler, 0, 0 },
-    { vendor_terms_string, vendor_terms_handler, 0, 0 },
-    { vendor_taxincluded_string, vendor_taxincluded_handler, 1, 0 },
-    { vendor_active_string, vendor_active_handler, 1, 0 },
-    { vendor_currency_string, vendor_currency_handler, 0, 0 }, /* XXX */
-    { "vendor:commodity", vendor_currency_handler, 0, 0 }, /* XXX */
-    { vendor_taxtable_string, vendor_taxtable_handler, 0, 0 },
-    { vendor_taxtableoverride_string, vendor_taxtableoverride_handler, 0, 0 },
-    { vendor_slots_string, vendor_slots_handler, 0, 0 },
-    { NULL, 0, 0, 0 }
-};
-
-static GncVendor*
-dom_tree_to_vendor (xmlNodePtr node, QofBook *book)
-{
-    struct vendor_pdata vendor_pdata;
-    gboolean successful;
-
-    vendor_pdata.vendor = gncVendorCreate(book);
-    vendor_pdata.book = book;
-    gncVendorBeginEdit (vendor_pdata.vendor);
-
-    successful = dom_tree_generic_parse (node, vendor_handlers_v2,
-                                         &vendor_pdata);
-
-    if (successful)
-        gncVendorCommitEdit (vendor_pdata.vendor);
-    else
-    {
-        PERR ("failed to parse vendor tree");
-        gncVendorDestroy (vendor_pdata.vendor);
-        vendor_pdata.vendor = NULL;
-    }
-
-    return vendor_pdata.vendor;
-}
-
-static gboolean
-gnc_vendor_end_handler(gpointer data_for_children,
-                       GSList* data_from_children, GSList* sibling_data,
-                       gpointer parent_data, gpointer global_data,
-                       gpointer *result, const gchar *tag)
-{
-    int successful;
-    GncVendor *vendor;
-    xmlNodePtr tree = (xmlNodePtr)data_for_children;
-    gxpf_data *gdata = (gxpf_data*)global_data;
-    QofBook *book = gdata->bookdata;
-
-    successful = TRUE;
-
-    if (parent_data)
-    {
-        return TRUE;
-    }
-
-    /* OK.  For some messed up reason this is getting called again with a
-       NULL tag.  So we ignore those cases */
-    if (!tag)
-    {
-        return TRUE;
-    }
-
-    g_return_val_if_fail(tree, FALSE);
-
-    vendor = dom_tree_to_vendor(tree, book);
-    if (vendor != NULL)
-    {
-        gdata->cb(tag, gdata->parsedata, vendor);
-    }
-
-    xmlFreeNode(tree);
-
-    return vendor != NULL;
-}
-
-static sixtp *
-vendor_sixtp_parser_create(void)
-{
-    return sixtp_dom_parser_new(gnc_vendor_end_handler, NULL, NULL);
-}
-
-static gboolean
-vendor_should_be_saved (GncVendor *vendor)
-{
-    const char *id;
-
-    /* make sure this is a valid vendor before we save it -- should have an ID */
-    id = gncVendorGetID (vendor);
-    if (id == NULL || *id == '\0')
-        return FALSE;
-
-    return TRUE;
-}
-
-static void
-do_count (QofInstance * vendor_p, gpointer count_p)
-{
-    int *count = count_p;
-    if (vendor_should_be_saved ((GncVendor *)vendor_p))
-        (*count)++;
-}
-
-static int
-vendor_get_count (QofBook *book)
-{
-    int count = 0;
-    qof_object_foreach (_GNC_MOD_NAME, book, do_count, (gpointer) &count);
-    return count;
-}
-
-static void
-xml_add_vendor (QofInstance * vendor_p, gpointer out_p)
-{
-    xmlNodePtr node;
-    GncVendor *vendor = (GncVendor *) vendor_p;
-    FILE *out = out_p;
-
-    if (ferror(out))
-        return;
-    if (!vendor_should_be_saved (vendor))
-        return;
-
-    node = vendor_dom_tree_create (vendor);
-    xmlElemDump(out, NULL, node);
-    xmlFreeNode (node);
-    if (ferror(out) || fprintf(out, "\n") < 0)
-        return;
-}
-
-static gboolean
-vendor_write (FILE *out, QofBook *book)
-{
-    qof_object_foreach (_GNC_MOD_NAME, book, xml_add_vendor, (gpointer) out);
-    return ferror(out) == 0;
-}
-
-static gboolean
-vendor_ns(FILE *out)
-{
-    g_return_val_if_fail(out, FALSE);
-    return gnc_xml2_write_namespace_decl(out, "vendor");
-}
-
-void
-gnc_vendor_xml_initialize (void)
-{
-    static GncXmlDataType_t be_data =
-    {
-        GNC_FILE_BACKEND_VERS,
-        gnc_vendor_string,
-        vendor_sixtp_parser_create,
-        NULL,			/* add_item */
-        vendor_get_count,
-        vendor_write,
-        NULL,			/* scrub */
-        vendor_ns,
-    };
-
-    qof_object_register_backend (_GNC_MOD_NAME,
-                                 GNC_FILE_BACKEND,
-                                 &be_data);
-}

Deleted: gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/gnc-vendor-xml-v2.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,29 +0,0 @@
-/*
- * gnc-vendor-xml-v2.h -- vendor xml i/o parser/unparsers
- *
- * Copyright (C) 2000 Derek Atkins <warlord at MIT.EDU>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, contact:
- *
- * Free Software Foundation           Voice:  +1-617-542-5942
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
- * Boston, MA  02110-1301,  USA       gnu at gnu.org
- */
-
-#ifndef GNC_VENDOR_XML_V2_H
-#define GNC_VENDOR_XML_V2_H
-
-void gnc_vendor_xml_initialize (void);
-
-#endif /* GNC_VENDOR_XML_V2_H */

Deleted: gnucash/trunk/src/business/business-core/xml/xml-helpers.h
===================================================================
--- gnucash/trunk/src/business/business-core/xml/xml-helpers.h	2010-07-12 20:12:22 UTC (rev 19360)
+++ gnucash/trunk/src/business/business-core/xml/xml-helpers.h	2010-07-13 09:55:46 UTC (rev 19361)
@@ -1,34 +0,0 @@
-
-/* xml-helpers.h
- * Miscellaneous bogus helper routines.
- */
-
-static inline void
-maybe_add_int (xmlNodePtr ptr, const char *tag, gint val)
-{
-    if (val)
-        xmlAddChild (ptr, int_to_dom_tree (tag, val));
-}
-
-static inline void
-maybe_add_numeric (xmlNodePtr ptr, const char *tag, gnc_numeric val)
-{
-    if (!gnc_numeric_zero_p (val))
-        xmlAddChild (ptr, gnc_numeric_to_dom_tree (tag, &val));
-}
-
-static inline void
-maybe_add_string (xmlNodePtr ptr, const char *tag, const char *str)
-{
-    if (str && strlen(str) > 0)
-        xmlAddChild (ptr, text_to_dom_tree (tag, str));
-}
-
-static inline void
-maybe_add_guid (xmlNodePtr ptr, const char *tag, QofInstance *inst)
-{
-    if (inst)
-        xmlAddChild (ptr, guid_to_dom_tree (tag,
-                                            qof_instance_get_guid (inst)));
-}
-



More information about the gnucash-changes mailing list