]> git.tdb.fi Git - ext/subsurface.git/blobdiff - parse-xml.c
Support for importing multiple XSLT formats
[ext/subsurface.git] / parse-xml.c
index bc4d4c54661aeb1db4d2462e49625ce8b5997174..38be728da55ffd4c719d0c84080bb06df8199df6 100644 (file)
@@ -1532,14 +1532,28 @@ static xsltStylesheetPtr get_stylesheet(const char *name)
        return NULL;
 }
 
+static struct xslt_files {
+       const char *root;
+       const char *file;
+} xslt_files[] = {
+       { "JDiveLog", "jdivelog2subsurface.xslt" },
+       { NULL, }
+};
+
 xmlDoc *test_xslt_transforms(xmlDoc *doc)
 {
+       struct xslt_files *info = xslt_files;
        xmlDoc *transformed;
        xsltStylesheetPtr xslt = NULL;
        xmlNode *root_element = xmlDocGetRootElement(doc);
-       if (strcasecmp(root_element->name, "JDiveLog") == 0) {
+
+       while ((info->root) && (strcasecmp(root_element->name, info->root) != 0)) {
+               info++;
+       }
+
+       if (info->root) {
                xmlSubstituteEntitiesDefault(1);
-               xslt = get_stylesheet("jdivelog2subsurface.xslt");
+               xslt = get_stylesheet(info->file);
                if (xslt == NULL)
                        return doc;
                transformed = xsltApplyStylesheet(xslt, doc, NULL);