Work on adding namespace declarations.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5487 57a11ea4-9604-0410-9ed3-97b8803252fd
zzzoldfeatures/g2-gog-integ
Dave Peticolas 25 years ago
parent d10d7a7d38
commit ecc9f2e4ce

@ -763,13 +763,37 @@ write_schedXactions( FILE *out, GNCBook *book )
} while ( (schedXactions = schedXactions->next) );
}
static void
write_namespace_decl (FILE *out, const char *namespace)
{
g_return_if_fail (namespace);
fprintf(out, " xmlns:%s=\"\"", namespace);
}
static void
write_v2_header (FILE *out)
{
fprintf(out, "<?xml version=\"1.0\"?>\n");
fprintf(out, "<" GNC_V2_STRING);
/*
write_namespace_decl (out, "cd");
write_namespace_decl (out, "gnc");
write_namespace_decl (out, "act");
write_namespace_decl (out, "cmdty");
write_namespace_decl (out, "trn");
write_namespace_decl (out, "ts");
write_namespace_decl (out, "split");
write_namespace_decl (out, "sx");
*/
fprintf(out, ">\n");
}
gboolean
gnc_book_write_to_xml_filehandle_v2(GNCBook *book, FILE *out)
{
if (!out) return FALSE;
fprintf(out, "<?xml version=\"1.0\"?>\n");
fprintf(out, "<" GNC_V2_STRING ">\n");
write_v2_header (out);
write_counts(out,
"commodity",
@ -800,6 +824,30 @@ gnc_book_write_to_xml_filehandle_v2(GNCBook *book, FILE *out)
return TRUE;
}
gboolean
gnc_book_write_accounts_to_xml_filehandle_v2(GNCBook *book, FILE *out)
{
if (!out) return FALSE;
write_v2_header (out);
write_counts(out,
"commodity",
gnc_commodity_table_get_size(
gnc_book_get_commodity_table(book)),
"account",
xaccGroupGetNumSubAccounts(gnc_book_get_group(book)),
NULL);
write_commodities(out, book);
write_accounts(out, book);
fprintf(out, "</" GNC_V2_STRING ">\n\n");
return TRUE;
}
gboolean
gnc_book_write_to_xml_file_v2(GNCBook *book, const char *filename)
{

@ -83,10 +83,14 @@ gboolean gnc_session_load_from_xml_file_v2(
GNCSession *session,
void (*countcallback)(const char *type, load_counter count));
/* write all account info to a file */
/* write all book info to a file */
gboolean gnc_book_write_to_xml_filehandle_v2(GNCBook *book, FILE *fh);
gboolean gnc_book_write_to_xml_file_v2(GNCBook *book, const char *filename);
/* write just the commodities and accounts to a file */
gboolean gnc_book_write_accounts_to_xml_filehandle_v2(GNCBook *book,
FILE *out);
/* The is_gncxml_file() routine checks to see if the first few
* chars of the file look like gnc-xml data.
*/

@ -55,7 +55,7 @@
#include "gnc-menu-extensions.h"
#include "gnc-ui.h"
#include "gnucash.h"
#include "io-utils.h"
#include "io-gncxml-v2.h"
#include "mainwindow-account-tree.h"
#include "option-util.h"
#include "top-level.h"
@ -394,33 +394,11 @@ gnc_main_window_file_export_cb(GtkWidget * widget, gpointer data)
return;
}
ok = FALSE;
ok = gnc_book_write_accounts_to_xml_filehandle_v2 (gnc_get_current_book (),
file);
do
{
rc = fputs ("<?xml version=\"1.0\"?>\n", file);
if (rc == EOF)
break;
rc = fputs ("<gnc-v2>\n", file);
if (rc == EOF)
break;
write_commodities (file, gnc_get_current_book ());
write_accounts (file, gnc_get_current_book ());
rc = fputs ("<\\gnc-v2>\n", file);
if (rc == EOF)
break;
write_emacs_trailer (file);
rc = fclose (file);
if (rc != 0)
break;
ok = TRUE;
} while (FALSE);
if (fclose (file) != 0)
ok = FALSE;
if (!ok)
{

Loading…
Cancel
Save