Use stylesheet transformations to output HTML, for example
This commit is contained in:
57
src/main.c
57
src/main.c
@@ -2,73 +2,38 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <libxml/tree.h>
|
||||
#include "options.h"
|
||||
#include "sermon.h"
|
||||
#include "xml.h"
|
||||
#include "xslt.h"
|
||||
|
||||
extern int yyparse(Sermon *);
|
||||
extern FILE* yyin;
|
||||
|
||||
void usage(const char* progname) {
|
||||
fprintf(stderr, "Usage: %s [-h] FILE\n"
|
||||
"\n"
|
||||
" -h Display help message\n"
|
||||
"\n"
|
||||
" FILE sermon file to scan\n", progname);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
Sermon sermon;
|
||||
xmlDocPtr document;
|
||||
xmlDocPtr document, transformed;
|
||||
int i = 0, block = 0, normal = 0;
|
||||
const char* progname = argv[0], *filename = NULL;
|
||||
while (++i < argc) {
|
||||
if (strcmp(argv[i], "-h") == 0) { usage(progname); exit(0); }
|
||||
else if ((argv[i][0] == '-') && (argv[i][1] != '\0')) {
|
||||
fprintf(stderr, "Unknown option: %s\n", argv[i]);
|
||||
}
|
||||
else {
|
||||
filename = argv[i];
|
||||
}
|
||||
}
|
||||
if (!filename) {
|
||||
usage(progname);
|
||||
exit(1);
|
||||
}
|
||||
InitOptions(argc, argv);
|
||||
InitSermon(&sermon);
|
||||
if (strcmp(filename, "-") == 0) {
|
||||
if (strcmp(options.inputFileName, "-") == 0) {
|
||||
yyin = stdin;
|
||||
} else {
|
||||
yyin = fopen(argv[1], "rt");
|
||||
yyin = fopen(options.inputFileName, "rt");
|
||||
}
|
||||
yyparse(&sermon);
|
||||
/*
|
||||
printf("Parsed sermon.\n");
|
||||
printf("TITLE=%s\n", sermon.sermonTitle ? sermon.sermonTitle : "none");
|
||||
printf("AUTHOR=%s\n", sermon.sermonAuthor ? sermon.sermonAuthor : "none");
|
||||
printf("DATE=%s\n", sermon.sermonDate ? sermon.sermonDate : "none");
|
||||
printf("OCCASION=%s\n", sermon.sermonOccasion ? sermon.sermonOccasion : "none");
|
||||
printf("TEXT=%s\n", sermon.sermonText ? sermon.sermonText : "none");
|
||||
printf("\nThere are %d paragraphs", sermon.numParagraphs);
|
||||
for (i = 0; i < sermon.numParagraphs; i++) {
|
||||
if (sermon.sermonParagraphs[i].paraType == PARA_DEFAULT) normal++;
|
||||
else if (sermon.sermonParagraphs[i].paraType == PARA_BLOCKQUOTE) block++;
|
||||
}
|
||||
printf(" (%d regular, %d blockquote)\n", normal, block);
|
||||
printf("\nThere are %d references.\n", sermon.numReferences);
|
||||
for (i = 0; i < sermon.numReferences; i++) {
|
||||
printf(" - %s: %s\n", sermon.sermonReferences[i].refId, sermon.sermonReferences[i].refText);
|
||||
}
|
||||
printf("\n");
|
||||
*/
|
||||
|
||||
document = sermonToXmlDoc(&sermon);
|
||||
printXML(document);
|
||||
transformed = applyStyleSheet(document, "html5");
|
||||
printXML(transformed);
|
||||
xmlFreeDoc(document);
|
||||
xmlFreeDoc(transformed);
|
||||
|
||||
/* clean up, clean up, everybody, everywhere! */
|
||||
FreeSermon(&sermon);
|
||||
if (strcmp(filename, "-") != 0) {
|
||||
if (strcmp(options.inputFileName, "-") != 0) {
|
||||
fclose(yyin);
|
||||
}
|
||||
FreeOptions();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user