mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-31 22:53:23 +00:00
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>
This commit is contained in:
parent
f09266897b
commit
5a046d94ea
1 changed files with 16 additions and 2 deletions
18
parse-xml.c
18
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);
|
||||
|
|
Loading…
Add table
Reference in a new issue