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 <[email protected]> --- dive.h | 1 + save-xml.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dive.h b/dive.h index 4978f4f..70d6f53 100644 --- a/dive.h +++ b/dive.h @@ -36,6 +36,7 @@ static inline char *copy_string(const char *s) #include <libxml/tree.h> #include <libxslt/transform.h> +#include <libxslt/xsltutils.h> #include "sha1.h" #include "units.h" diff --git a/save-xml.c b/save-xml.c index 0a76753..20714c3 100644 --- a/save-xml.c +++ b/save-xml.c @@ -618,18 +618,20 @@ int export_dives_xslt(const char *filename, const bool selected, const char *exp return report_error("Failed to open export conversion stylesheet"); transformed = xsltApplyStylesheet(xslt, doc, NULL); - xsltFreeStylesheet(xslt); xmlFreeDoc(doc); /* Write the transformed export to file */ f = subsurface_fopen(filename, "w"); - if (!f) - return report_error("Failed to open %s for writing (%s)", filename, strerror(errno)); - - xmlDocFormatDump(f, transformed, 1); + int res = 0; + if (f) { + xsltSaveResultToFile(f, transformed, xslt); + fclose(f); + /* Check write errors? */ + } else { + res = report_error("Failed to open %s for writing (%s)", filename, strerror(errno)); + } + xsltFreeStylesheet(xslt); xmlFreeDoc(transformed); - fclose(f); - /* Check write errors? */ - return 0; + return res; } -- 1.8.5.5 _______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
