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 <[email protected]>
---
 parse-xml.c | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

diff --git a/parse-xml.c b/parse-xml.c
index 7ee3323..111075b 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++;
        }
 
-- 
1.8.3.2

_______________________________________________
subsurface mailing list
[email protected]
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to