Use stylesheet transformations to output HTML, for example

This commit is contained in:
David Baer
2015-08-11 15:33:08 -04:00
parent cfc0ba7e9a
commit 10927bee25
19 changed files with 725 additions and 92 deletions

29
src/xslt.c Normal file
View File

@@ -0,0 +1,29 @@
#include <string.h>
#include <libxml/tree.h>
#include <libxslt/xslt.h>
#include <libxslt/transform.h>
#include "options.h"
xmlDocPtr
applyStyleSheet(xmlDocPtr document, const char* styleSheetName) {
int l = strlen(styleSheetName) + 5;
char *t = malloc(l), *styleSheetFileName = NULL;
xsltStylesheetPtr xsl = NULL;
xmlDocPtr res = NULL;
strlcpy(t, styleSheetName, l);
strlcat(t, ".xsl", l);
styleSheetFileName = OptionsDataFile(t);
free(t);
fprintf(stderr, "Loading stylesheet %s ...\n", styleSheetFileName);
xmlSubstituteEntitiesDefault(1);
xmlLoadExtDtdDefaultValue = 1;
xsl = xsltParseStylesheetFile(styleSheetFileName);
res = xsltApplyStylesheet(xsl, document, NULL);
free(styleSheetFileName);
xsltFreeStylesheet(xsl);
return res;
}