Use stylesheet transformations to output HTML, for example
This commit is contained in:
29
src/xslt.c
Normal file
29
src/xslt.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user