mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-02 23:20:20 +00:00
Suppress XML preamble in CSV export
To obey <xsl:output omit-xml-declaration="yes"/> element one should rely on libxslt to do its job instead of writing document himself. Discussion on this subject can be found at http://comments.gmane.org/gmane.comp.gnome.lib.xslt/3839 Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
32a76671ed
commit
b87a602265
2 changed files with 11 additions and 9 deletions
1
dive.h
1
dive.h
|
@ -36,6 +36,7 @@ static inline char *copy_string(const char *s)
|
||||||
|
|
||||||
#include <libxml/tree.h>
|
#include <libxml/tree.h>
|
||||||
#include <libxslt/transform.h>
|
#include <libxslt/transform.h>
|
||||||
|
#include <libxslt/xsltutils.h>
|
||||||
|
|
||||||
#include "sha1.h"
|
#include "sha1.h"
|
||||||
#include "units.h"
|
#include "units.h"
|
||||||
|
|
19
save-xml.c
19
save-xml.c
|
@ -594,7 +594,7 @@ int export_dives_xslt(const char *filename, const bool selected, const char *exp
|
||||||
xmlDoc *doc;
|
xmlDoc *doc;
|
||||||
xsltStylesheetPtr xslt = NULL;
|
xsltStylesheetPtr xslt = NULL;
|
||||||
xmlDoc *transformed;
|
xmlDoc *transformed;
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
if (!filename)
|
if (!filename)
|
||||||
return report_error("No filename for export");
|
return report_error("No filename for export");
|
||||||
|
@ -618,18 +618,19 @@ int export_dives_xslt(const char *filename, const bool selected, const char *exp
|
||||||
return report_error("Failed to open export conversion stylesheet");
|
return report_error("Failed to open export conversion stylesheet");
|
||||||
|
|
||||||
transformed = xsltApplyStylesheet(xslt, doc, NULL);
|
transformed = xsltApplyStylesheet(xslt, doc, NULL);
|
||||||
xsltFreeStylesheet(xslt);
|
|
||||||
xmlFreeDoc(doc);
|
xmlFreeDoc(doc);
|
||||||
|
|
||||||
/* Write the transformed export to file */
|
/* Write the transformed export to file */
|
||||||
f = subsurface_fopen(filename, "w");
|
f = subsurface_fopen(filename, "w");
|
||||||
if (!f)
|
if (f) {
|
||||||
return report_error("Failed to open %s for writing (%s)", filename, strerror(errno));
|
xsltSaveResultToFile(f, transformed, xslt);
|
||||||
|
fclose(f);
|
||||||
xmlDocFormatDump(f, transformed, 1);
|
/* Check write errors? */
|
||||||
|
} else {
|
||||||
|
res = report_error("Failed to open %s for writing (%s)", filename, strerror(errno));
|
||||||
|
}
|
||||||
|
xsltFreeStylesheet(xslt);
|
||||||
xmlFreeDoc(transformed);
|
xmlFreeDoc(transformed);
|
||||||
|
|
||||||
fclose(f);
|
return res;
|
||||||
/* Check write errors? */
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue