diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2014-02-08 14:00:54 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-02-08 07:12:35 -0800 |
commit | 361f8ede76f451a383550387e29f63173149c887 (patch) | |
tree | 0e4e80178a64a01f7f8b3a38d9a8f7b643b27787 /parse-xml.c | |
parent | 0ac8ab307085d297a7615eb7385314762b144bce (diff) | |
download | subsurface-361f8ede76f451a383550387e29f63173149c887.tar.gz |
Check XML attribute to detect correct XSLT
Very few dive log files can be identified by the name of the root
element in the XML log. As same element names are used between different
software, we need to use attributes as well to identify correct XSLT to
convert the log to Subsurface format. I would not be surprised if at
some point we'll just have to present a dialog to the user and ask which
software is in use...but this is enough for now.
This also adds the shearwater.xslt to the list.
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 | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/parse-xml.c b/parse-xml.c index 7ee3323c5..111075bfa 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1902,19 +1902,21 @@ void parse_xml_exit(void) static struct xslt_files { const char *root; const char *file; + const char *attribute; } xslt_files[] = { - { "SUUNTO", "SuuntoSDM.xslt" }, - { "Dive", "SuuntoDM4.xslt" }, - { "JDiveLog", "jdivelog2subsurface.xslt" }, - { "dives", "MacDive.xslt" }, - { "DIVELOGSDATA", "divelogs.xslt" }, - { "uddf", "uddf.xslt" }, - { "UDDF", "uddf.xslt" }, - { "profile", "udcf.xslt" }, - { "Divinglog", "DivingLog.xslt" }, - { "csv", "csv2xml.xslt" }, - { "sensuscsv", "sensuscsv.xslt" }, - { "manualcsv", "manualcsv2xml.xslt" }, + { "SUUNTO", "SuuntoSDM.xslt", NULL }, + { "Dive", "SuuntoDM4.xslt", "xmlns" }, + { "Dive", "shearwater.xslt", "version" }, + { "JDiveLog", "jdivelog2subsurface.xslt", NULL }, + { "dives", "MacDive.xslt", NULL }, + { "DIVELOGSDATA", "divelogs.xslt", NULL }, + { "uddf", "uddf.xslt", NULL }, + { "UDDF", "uddf.xslt", NULL }, + { "profile", "udcf.xslt", NULL }, + { "Divinglog", "DivingLog.xslt", NULL }, + { "csv", "csv2xml.xslt", NULL }, + { "sensuscsv", "sensuscsv.xslt", NULL }, + { "manualcsv", "manualcsv2xml.xslt", NULL }, { NULL, } }; @@ -1926,7 +1928,12 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params, char **err xmlNode *root_element = xmlDocGetRootElement(doc); char *attribute; - while ((info->root) && (strcasecmp(root_element->name, info->root) != 0)) { + while (info->root) { + if ((strcasecmp(root_element->name, info->root) == 0)) + if (info->attribute == NULL) + break; + else if (xmlGetProp(root_element, info->attribute) != NULL) + break; info++; } |