diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2011-11-16 07:12:43 +0200 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-21 11:33:52 -0800 |
commit | 5a046d94ea808963b5e6a5d740d360815b0def6d (patch) | |
tree | 6b768d23f283bf6d342606d0f44835cf4bd9068d /parse-xml.c | |
parent | f09266897bfc5983646819d79cf2e3b5160c501e (diff) | |
download | subsurface-5a046d94ea808963b5e6a5d740d360815b0def6d.tar.gz |
Support for importing multiple XSLT formats
Have information of multiple XSLT files on an array for importing
"alien" formatted XML dive log files. Adding support for new XSLT
requires updating the array and adding the XSLT file (provided the
format can be identified by root element of the XML).
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/parse-xml.c b/parse-xml.c index bc4d4c546..38be728da 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -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); |