X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=parse-xml.c;h=64d79e02288a9e145d6bb6e6824fd47b4a2c0fcd;hb=61f3114fce0c188b989270a33e476db52b81e810;hp=bc4d4c54661aeb1db4d2462e49625ce8b5997174;hpb=6fa702bcbd95d909bfe4d17a0039005caabab141;p=ext%2Fsubsurface.git diff --git a/parse-xml.c b/parse-xml.c index bc4d4c5..64d79e0 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1532,14 +1532,29 @@ static xsltStylesheetPtr get_stylesheet(const char *name) return NULL; } +static struct xslt_files { + const char *root; + const char *file; +} xslt_files[] = { + { "SUUNTO", "SuuntoSDM.xslt" }, + { "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);