diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2013-09-29 15:44:38 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-10-02 08:49:52 -0700 |
commit | ba5b5c3952f7de974f75162c99de51b5f572a078 (patch) | |
tree | 6e6bdf18216e221719b0e5c026c905f8d34b7bc7 /parse-xml.c | |
parent | adefc8805a7474e6f0baca476df33f7ab8ea38c8 (diff) | |
download | subsurface-ba5b5c3952f7de974f75162c99de51b5f572a078.tar.gz |
Initial code to import CSV log files
This patch implements basic functionality to import CSV formatted log
profiles to Subsurface. The import includes time, depth and temperature
from AP Logviewer based on one sample log file I have received. It is
assumed that dive time is the first parameter and depth second.
Temperature is given as a parameter from C source (hard coded currently
to field 15) but we should have a GUI implemented for selecting the
wanted fields.
The two different sample logs of CSV dive log export I have received use
tabulator as field separator. I assume the possible GUI should have
option for the FS as well to be given as parameter to the XSLT.
[Dirk Hohndel: small fix to the error string malloc]
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/parse-xml.c b/parse-xml.c index 370388f4f..195eafeb9 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1915,6 +1915,7 @@ static struct xslt_files { { "UDDF", "uddf.xslt" }, { "profile", "udcf.xslt" }, { "Divinglog", "DivingLog.xslt" }, + { "csv", "csv2xml.xslt" }, { NULL, } }; @@ -1925,6 +1926,7 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, char **error) xsltStylesheetPtr xslt = NULL; xmlNode *root_element = xmlDocGetRootElement(doc); char *attribute; + char *params[3]; while ((info->root) && (strcasecmp(root_element->name, info->root) != 0)) { info++; @@ -1946,9 +1948,28 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, char **error) parser_error(error, _("Can't open stylesheet (%s)/%s"), xslt_path, info->file); return doc; } - transformed = xsltApplyStylesheet(xslt, doc, NULL); + + /* + * params is only used for CSV import, but it does not + * hurt if we supply unused parameters for other + * transforms as well. + * + * We should have a GUI set the parameters but currently + * we just have PoC how parameters would be handled. + * + * (Field 9 is temperature for XP5 import, field 15 + * is temperature for AP Logviewer. + */ + + params[0] = strdup("tempField"); + params[1] = strdup("15"); + params[2] = NULL; + + transformed = xsltApplyStylesheet(xslt, doc, (const char **)params); xmlFreeDoc(doc); xsltFreeStylesheet(xslt); + free(params[0]); + free(params[1]); return transformed; } return doc; |