2001-01-07 14:01:28 +00:00
|
|
|
/*
|
|
|
|
* xsltproc.c: user program for the XSL Transformation 1.0 engine
|
|
|
|
*
|
|
|
|
* See Copyright for the status of this software.
|
|
|
|
*
|
|
|
|
* Daniel.Veillard@imag.fr
|
|
|
|
*/
|
|
|
|
|
2001-05-22 14:59:48 +00:00
|
|
|
#include <libxml/xmlversion.h>
|
|
|
|
#include <libxslt/xsltconfig.h>
|
|
|
|
#ifdef HAVE_STRING_H
|
2001-01-07 15:17:08 +00:00
|
|
|
#include <string.h>
|
2001-05-22 14:59:48 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
2001-02-05 18:29:06 +00:00
|
|
|
#include <sys/time.h>
|
2001-05-22 14:59:48 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2001-02-05 18:29:06 +00:00
|
|
|
#include <unistd.h>
|
2001-05-22 14:59:48 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STDLIB_H
|
|
|
|
#include <stdlib.h>
|
|
|
|
#endif
|
2001-01-07 15:17:08 +00:00
|
|
|
#include <libxml/xmlmemory.h>
|
2001-01-11 20:13:26 +00:00
|
|
|
#include <libxml/debugXML.h>
|
2001-01-18 15:13:25 +00:00
|
|
|
#include <libxml/HTMLtree.h>
|
2001-05-09 10:32:15 +00:00
|
|
|
#include <libxml/xmlIO.h>
|
2001-05-04 17:11:06 +00:00
|
|
|
#ifdef LIBXML_DOCB_ENABLED
|
|
|
|
#include <libxml/DOCBparser.h>
|
|
|
|
#endif
|
2001-04-11 12:30:25 +00:00
|
|
|
#ifdef LIBXML_XINCLUDE_ENABLED
|
|
|
|
#include <libxml/xinclude.h>
|
|
|
|
#endif
|
2001-05-22 14:59:48 +00:00
|
|
|
#ifdef LIBXML_CATALOG_ENABLED
|
|
|
|
#include <libxml/catalog.h>
|
|
|
|
#endif
|
2001-01-07 14:01:28 +00:00
|
|
|
#include <libxslt/xslt.h>
|
|
|
|
#include <libxslt/xsltInternals.h>
|
2001-01-11 20:13:26 +00:00
|
|
|
#include <libxslt/transform.h>
|
2001-01-17 13:29:19 +00:00
|
|
|
#include <libxslt/xsltutils.h>
|
2001-01-07 14:01:28 +00:00
|
|
|
|
2001-06-23 15:41:55 +00:00
|
|
|
#ifdef WIN32
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
#include <winsock2.h>
|
|
|
|
#pragma comment(lib, "ws2_32.lib")
|
|
|
|
#define gettimeofday(p1,p2)
|
|
|
|
#endif /* _MS_VER */
|
|
|
|
#else /* WIN32 */
|
|
|
|
#include <sys/time.h>
|
|
|
|
#endif /* WIN32 */
|
|
|
|
|
2001-02-05 18:29:06 +00:00
|
|
|
extern int xmlLoadExtDtdDefaultValue;
|
|
|
|
|
2001-01-07 14:01:28 +00:00
|
|
|
static int debug = 0;
|
2001-01-18 15:13:25 +00:00
|
|
|
static int repeat = 0;
|
2001-02-05 18:29:06 +00:00
|
|
|
static int timing = 0;
|
2001-02-18 14:47:20 +00:00
|
|
|
static int novalid = 0;
|
|
|
|
static int noout = 0;
|
2001-05-04 17:11:06 +00:00
|
|
|
#ifdef LIBXML_DOCB_ENABLED
|
|
|
|
static int docbook = 0;
|
|
|
|
#endif
|
2001-04-28 12:22:22 +00:00
|
|
|
#ifdef LIBXML_HTML_ENABLED
|
|
|
|
static int html = 0;
|
|
|
|
#endif
|
2001-04-11 12:30:25 +00:00
|
|
|
#ifdef LIBXML_XINCLUDE_ENABLED
|
|
|
|
static int xinclude = 0;
|
|
|
|
#endif
|
2001-05-09 10:32:15 +00:00
|
|
|
static int nonet;
|
|
|
|
static xmlExternalEntityLoader defaultLoader = NULL;
|
|
|
|
|
|
|
|
static xmlParserInputPtr
|
|
|
|
xsltNoNetExternalEntityLoader(const char *URL, const char *ID,
|
|
|
|
xmlParserCtxtPtr ctxt) {
|
|
|
|
if (URL != NULL) {
|
|
|
|
if ((!xmlStrncasecmp((const xmlChar *) URL,
|
|
|
|
(const xmlChar *) "ftp://", 6)) ||
|
|
|
|
(!xmlStrncasecmp((const xmlChar *) URL,
|
|
|
|
(const xmlChar *) "http://", 7))) {
|
|
|
|
fprintf(stderr, "Attempt to load network entity %s \n", URL);
|
|
|
|
if (nonet)
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (defaultLoader != NULL) {
|
|
|
|
return(defaultLoader(URL, ID, ctxt));
|
|
|
|
}
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usage(const char *name) {
|
|
|
|
printf("Usage: %s [options] stylesheet file [file ...]\n", name);
|
|
|
|
printf(" Options:\n");
|
2001-05-19 20:33:55 +00:00
|
|
|
printf(" --version or -V: show the version of libxml and libxslt used\n");
|
2001-05-09 10:32:15 +00:00
|
|
|
printf(" --verbose or -v: show logs of what's happening\n");
|
2001-06-25 13:35:30 +00:00
|
|
|
printf(" --output file or -o file: save to a given file\n");
|
2001-05-09 10:32:15 +00:00
|
|
|
printf(" --timing: display the time used\n");
|
|
|
|
printf(" --repeat: run the transformation 20 times\n");
|
|
|
|
printf(" --debug: dump the tree of the result instead\n");
|
|
|
|
printf(" --novalid: skip the Dtd loading phase\n");
|
|
|
|
printf(" --noout: do not dump the result\n");
|
|
|
|
printf(" --maxdepth val : increase the maximum depth\n");
|
|
|
|
#ifdef LIBXML_HTML_ENABLED
|
|
|
|
printf(" --html: the input document is(are) an HTML file(s)\n");
|
|
|
|
#endif
|
|
|
|
#ifdef LIBXML_DOCB_ENABLED
|
|
|
|
printf(" --docbook: the input document is SGML docbook\n");
|
|
|
|
#endif
|
2001-05-19 20:33:55 +00:00
|
|
|
printf(" --param name value : pass a (parameter,value) pair\n");
|
2001-05-09 10:32:15 +00:00
|
|
|
printf(" --nonet refuse to fetch DTDs or entities over network\n");
|
|
|
|
printf(" --warnnet warn against fetching over the network\n");
|
2001-05-22 14:59:48 +00:00
|
|
|
#ifdef LIBXML_CATALOG_ENABLED
|
|
|
|
printf(" --catalogs : use the catalogs from $SGML_CATALOG_FILES\n");
|
|
|
|
#endif
|
2001-05-23 12:14:10 +00:00
|
|
|
#ifdef LIBXML_XINCLUDE_ENABLED
|
|
|
|
printf(" --xinclude : do XInclude processing on document intput\n");
|
|
|
|
#endif
|
2001-05-09 10:32:15 +00:00
|
|
|
}
|
2001-01-07 14:01:28 +00:00
|
|
|
|
|
|
|
int
|
2001-06-25 10:58:40 +00:00
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2001-01-07 15:17:08 +00:00
|
|
|
int i;
|
2001-01-22 10:52:35 +00:00
|
|
|
xsltStylesheetPtr cur = NULL;
|
2001-01-11 20:13:26 +00:00
|
|
|
xmlDocPtr doc, res;
|
2001-02-05 18:29:06 +00:00
|
|
|
struct timeval begin, end;
|
2001-03-25 20:10:09 +00:00
|
|
|
const char *params[16 + 1];
|
|
|
|
int nbparams = 0;
|
2001-06-25 10:58:40 +00:00
|
|
|
const char *output = NULL;
|
2001-01-07 14:01:28 +00:00
|
|
|
|
2001-02-18 14:47:20 +00:00
|
|
|
if (argc <= 1) {
|
2001-06-25 10:58:40 +00:00
|
|
|
usage(argv[0]);
|
|
|
|
return (1);
|
2001-02-18 14:47:20 +00:00
|
|
|
}
|
2001-05-07 20:55:45 +00:00
|
|
|
xmlInitMemory();
|
2001-06-25 10:58:40 +00:00
|
|
|
LIBXML_TEST_VERSION defaultLoader = xmlGetExternalEntityLoader();
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if (!strcmp(argv[i], "-"))
|
|
|
|
break;
|
2001-05-09 10:32:15 +00:00
|
|
|
|
2001-06-25 10:58:40 +00:00
|
|
|
if (argv[i][0] != '-')
|
|
|
|
continue;
|
2001-02-18 14:47:20 +00:00
|
|
|
#ifdef LIBXML_DEBUG_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) {
|
|
|
|
debug++;
|
|
|
|
} else
|
2001-02-18 14:47:20 +00:00
|
|
|
#endif
|
2001-06-25 10:58:40 +00:00
|
|
|
if ((!strcmp(argv[i], "-v")) ||
|
|
|
|
(!strcmp(argv[i], "-verbose")) ||
|
|
|
|
(!strcmp(argv[i], "--verbose"))) {
|
|
|
|
xsltSetGenericDebugFunc(stderr, NULL);
|
|
|
|
} else if ((!strcmp(argv[i], "-o")) ||
|
|
|
|
(!strcmp(argv[i], "-output")) ||
|
|
|
|
(!strcmp(argv[i], "--output"))) {
|
|
|
|
i++;
|
|
|
|
output = argv[i++];
|
|
|
|
} else if ((!strcmp(argv[i], "-V")) ||
|
|
|
|
(!strcmp(argv[i], "-version")) ||
|
|
|
|
(!strcmp(argv[i], "--version"))) {
|
|
|
|
printf("Using libxml %s and libxslt %s\n",
|
|
|
|
xmlParserVersion, xsltEngineVersion);
|
|
|
|
printf
|
|
|
|
("xsltproc was compiled against libxml %d and libxslt %d\n",
|
|
|
|
LIBXML_VERSION, LIBXSLT_VERSION);
|
|
|
|
printf("libxslt %d was compiled against libxml %d\n",
|
|
|
|
xsltLibxsltVersion, xsltLibxmlVersion);
|
|
|
|
} else if ((!strcmp(argv[i], "-repeat"))
|
|
|
|
|| (!strcmp(argv[i], "--repeat"))) {
|
|
|
|
if (repeat == 0)
|
|
|
|
repeat = 20;
|
|
|
|
else
|
|
|
|
repeat = 100;
|
|
|
|
} else if ((!strcmp(argv[i], "-novalid")) ||
|
|
|
|
(!strcmp(argv[i], "--novalid"))) {
|
|
|
|
novalid++;
|
|
|
|
} else if ((!strcmp(argv[i], "-noout")) ||
|
|
|
|
(!strcmp(argv[i], "--noout"))) {
|
|
|
|
noout++;
|
2001-05-04 17:11:06 +00:00
|
|
|
#ifdef LIBXML_DOCB_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
} else if ((!strcmp(argv[i], "-docbook")) ||
|
|
|
|
(!strcmp(argv[i], "--docbook"))) {
|
|
|
|
docbook++;
|
2001-05-04 17:11:06 +00:00
|
|
|
#endif
|
2001-04-28 12:22:22 +00:00
|
|
|
#ifdef LIBXML_HTML_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
} else if ((!strcmp(argv[i], "-html")) ||
|
|
|
|
(!strcmp(argv[i], "--html"))) {
|
|
|
|
html++;
|
2001-04-28 12:22:22 +00:00
|
|
|
#endif
|
2001-06-25 10:58:40 +00:00
|
|
|
} else if ((!strcmp(argv[i], "-timing")) ||
|
|
|
|
(!strcmp(argv[i], "--timing"))) {
|
|
|
|
timing++;
|
|
|
|
} else if ((!strcmp(argv[i], "-warnnet")) ||
|
|
|
|
(!strcmp(argv[i], "--warnnet"))) {
|
|
|
|
xmlSetExternalEntityLoader(xsltNoNetExternalEntityLoader);
|
|
|
|
} else if ((!strcmp(argv[i], "-nonet")) ||
|
|
|
|
(!strcmp(argv[i], "--nonet"))) {
|
|
|
|
xmlSetExternalEntityLoader(xsltNoNetExternalEntityLoader);
|
|
|
|
nonet = 1;
|
2001-05-22 14:59:48 +00:00
|
|
|
#ifdef LIBXML_CATALOG_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
} else if ((!strcmp(argv[i], "-catalogs")) ||
|
|
|
|
(!strcmp(argv[i], "--catalogs"))) {
|
|
|
|
const char *catalogs;
|
2001-05-22 14:59:48 +00:00
|
|
|
|
2001-06-25 10:58:40 +00:00
|
|
|
catalogs = getenv("SGML_CATALOG_FILES");
|
|
|
|
if (catalogs == NULL) {
|
|
|
|
fprintf(stderr, "Variable $SGML_CATALOG_FILES not set\n");
|
|
|
|
} else {
|
|
|
|
xmlLoadCatalogs(catalogs);
|
|
|
|
}
|
2001-05-22 14:59:48 +00:00
|
|
|
#endif
|
2001-04-11 12:30:25 +00:00
|
|
|
#ifdef LIBXML_XINCLUDE_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
} else if ((!strcmp(argv[i], "-xinclude")) ||
|
|
|
|
(!strcmp(argv[i], "--xinclude"))) {
|
|
|
|
xinclude++;
|
|
|
|
xsltSetXIncludeDefault(1);
|
2001-04-11 12:30:25 +00:00
|
|
|
#endif
|
2001-06-25 10:58:40 +00:00
|
|
|
} else if ((!strcmp(argv[i], "-param")) ||
|
|
|
|
(!strcmp(argv[i], "--param"))) {
|
|
|
|
i++;
|
|
|
|
params[nbparams++] = argv[i++];
|
|
|
|
params[nbparams++] = argv[i];
|
|
|
|
if (nbparams >= 16) {
|
|
|
|
fprintf(stderr, "too many params\n");
|
|
|
|
return (1);
|
|
|
|
}
|
|
|
|
} else if ((!strcmp(argv[i], "-maxdepth")) ||
|
|
|
|
(!strcmp(argv[i], "--maxdepth"))) {
|
|
|
|
int value;
|
|
|
|
|
|
|
|
i++;
|
|
|
|
if (sscanf(argv[i], "%d", &value) == 1) {
|
|
|
|
if (value > 0)
|
|
|
|
xsltMaxDepth = value;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fprintf(stderr, "Unknown option %s\n", argv[i]);
|
|
|
|
usage(argv[0]);
|
|
|
|
return (1);
|
|
|
|
}
|
2001-01-07 14:01:28 +00:00
|
|
|
}
|
2001-03-25 20:10:09 +00:00
|
|
|
params[nbparams] = NULL;
|
2001-01-07 14:01:28 +00:00
|
|
|
xmlSubstituteEntitiesDefault(1);
|
2001-06-25 10:58:40 +00:00
|
|
|
if (novalid == 0) /* TODO XML_DETECT_IDS | XML_COMPLETE_ATTRS */
|
|
|
|
xmlLoadExtDtdDefaultValue = 6;
|
2001-02-18 14:47:20 +00:00
|
|
|
else
|
2001-06-25 10:58:40 +00:00
|
|
|
xmlLoadExtDtdDefaultValue = 0;
|
|
|
|
for (i = 1; i < argc; i++) {
|
|
|
|
if ((!strcmp(argv[i], "-maxdepth")) ||
|
|
|
|
(!strcmp(argv[i], "--maxdepth"))) {
|
|
|
|
i++;
|
|
|
|
continue;
|
|
|
|
} else if ((!strcmp(argv[i], "-o")) ||
|
|
|
|
(!strcmp(argv[i], "-output")) ||
|
|
|
|
(!strcmp(argv[i], "--output"))) {
|
|
|
|
i++;
|
2001-03-25 20:10:09 +00:00
|
|
|
continue;
|
|
|
|
}
|
2001-06-25 10:58:40 +00:00
|
|
|
if ((!strcmp(argv[i], "-param")) || (!strcmp(argv[i], "--param"))) {
|
|
|
|
i += 2;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ((argv[i][0] != '-') || (strcmp(argv[i], "-") == 0)) {
|
|
|
|
if (timing)
|
|
|
|
gettimeofday(&begin, NULL);
|
|
|
|
cur = xsltParseStylesheetFile((const xmlChar *) argv[i]);
|
|
|
|
if (timing) {
|
|
|
|
long msec;
|
|
|
|
|
|
|
|
gettimeofday(&end, NULL);
|
|
|
|
msec = end.tv_sec - begin.tv_sec;
|
|
|
|
msec *= 1000;
|
|
|
|
msec += (end.tv_usec - begin.tv_usec) / 1000;
|
|
|
|
fprintf(stderr, "Parsing stylesheet %s took %ld ms\n",
|
|
|
|
argv[i], msec);
|
|
|
|
}
|
|
|
|
if (cur != NULL) {
|
|
|
|
if (cur->indent == 1)
|
|
|
|
xmlIndentTreeOutput = 1;
|
|
|
|
else
|
|
|
|
xmlIndentTreeOutput = 0;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
2001-01-07 14:01:28 +00:00
|
|
|
}
|
2001-04-30 17:33:47 +00:00
|
|
|
if ((cur != NULL) && (cur->errors == 0)) {
|
2001-06-25 10:58:40 +00:00
|
|
|
for (; i < argc; i++) {
|
|
|
|
if (timing)
|
|
|
|
gettimeofday(&begin, NULL);
|
2001-04-28 12:22:22 +00:00
|
|
|
#ifdef LIBXML_HTML_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
if (html)
|
|
|
|
doc = htmlParseFile(argv[i], NULL);
|
|
|
|
else
|
2001-05-04 17:11:06 +00:00
|
|
|
#endif
|
2001-05-12 07:45:23 +00:00
|
|
|
#ifdef LIBXML_DOCB_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
if (docbook)
|
|
|
|
doc = docbParseFile(argv[i], NULL);
|
|
|
|
else
|
2001-04-28 12:22:22 +00:00
|
|
|
#endif
|
2001-06-25 10:58:40 +00:00
|
|
|
doc = xmlParseFile(argv[i]);
|
|
|
|
if (doc == NULL) {
|
|
|
|
fprintf(stderr, "unable to parse %s\n", argv[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (timing) {
|
|
|
|
long msec;
|
|
|
|
|
|
|
|
gettimeofday(&end, NULL);
|
|
|
|
msec = end.tv_sec - begin.tv_sec;
|
|
|
|
msec *= 1000;
|
|
|
|
msec += (end.tv_usec - begin.tv_usec) / 1000;
|
|
|
|
fprintf(stderr, "Parsing document %s took %ld ms\n",
|
|
|
|
argv[i], msec);
|
|
|
|
}
|
2001-04-11 12:30:25 +00:00
|
|
|
#ifdef LIBXML_XINCLUDE_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
if (xinclude) {
|
|
|
|
if (timing)
|
|
|
|
gettimeofday(&begin, NULL);
|
|
|
|
xmlXIncludeProcess(doc);
|
|
|
|
if (timing) {
|
|
|
|
long msec;
|
|
|
|
|
|
|
|
gettimeofday(&end, NULL);
|
|
|
|
msec = end.tv_sec - begin.tv_sec;
|
|
|
|
msec *= 1000;
|
|
|
|
msec += (end.tv_usec - begin.tv_usec) / 1000;
|
|
|
|
fprintf(stderr, "XInclude processing %s took %ld ms\n",
|
|
|
|
argv[i], msec);
|
|
|
|
}
|
|
|
|
}
|
2001-04-11 12:30:25 +00:00
|
|
|
#endif
|
2001-06-25 10:58:40 +00:00
|
|
|
if (timing)
|
|
|
|
gettimeofday(&begin, NULL);
|
|
|
|
if (output == NULL) {
|
|
|
|
if (repeat) {
|
|
|
|
int j;
|
|
|
|
|
|
|
|
for (j = 1; j < repeat; j++) {
|
|
|
|
res = xsltApplyStylesheet(cur, doc, params);
|
|
|
|
xmlFreeDoc(res);
|
|
|
|
xmlFreeDoc(doc);
|
2001-05-08 14:24:04 +00:00
|
|
|
#ifdef LIBXML_HTML_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
if (html)
|
|
|
|
doc = htmlParseFile(argv[i], NULL);
|
|
|
|
else
|
2001-05-08 14:24:04 +00:00
|
|
|
#endif
|
2001-05-12 07:45:23 +00:00
|
|
|
#ifdef LIBXML_DOCB_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
if (docbook)
|
|
|
|
doc = docbParseFile(argv[i], NULL);
|
|
|
|
else
|
2001-05-08 14:24:04 +00:00
|
|
|
#endif
|
2001-06-25 10:58:40 +00:00
|
|
|
doc = xmlParseFile(argv[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res = xsltApplyStylesheet(cur, doc, params);
|
|
|
|
if (timing) {
|
|
|
|
long msec;
|
2001-02-18 14:47:20 +00:00
|
|
|
|
2001-06-25 10:58:40 +00:00
|
|
|
gettimeofday(&end, NULL);
|
|
|
|
msec = end.tv_sec - begin.tv_sec;
|
|
|
|
msec *= 1000;
|
|
|
|
msec += (end.tv_usec - begin.tv_usec) / 1000;
|
|
|
|
if (repeat)
|
|
|
|
fprintf(stderr,
|
|
|
|
"Applying stylesheet %d times took %ld ms\n",
|
|
|
|
repeat, msec);
|
|
|
|
else
|
|
|
|
fprintf(stderr,
|
|
|
|
"Applying stylesheet took %ld ms\n", msec);
|
|
|
|
}
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
if (res == NULL) {
|
|
|
|
fprintf(stderr, "no result for %s\n", argv[i]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (noout) {
|
|
|
|
xmlFreeDoc(res);
|
|
|
|
continue;
|
|
|
|
}
|
2001-01-11 20:13:26 +00:00
|
|
|
#ifdef LIBXML_DEBUG_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
if (debug)
|
|
|
|
xmlDebugDumpDocument(stdout, res);
|
|
|
|
else {
|
2001-01-11 20:13:26 +00:00
|
|
|
#endif
|
2001-06-25 10:58:40 +00:00
|
|
|
if (cur->methodURI == NULL) {
|
|
|
|
if (timing)
|
|
|
|
gettimeofday(&begin, NULL);
|
|
|
|
xsltSaveResultToFile(stdout, res, cur);
|
|
|
|
if (timing) {
|
|
|
|
long msec;
|
|
|
|
|
|
|
|
gettimeofday(&end, NULL);
|
|
|
|
msec = end.tv_sec - begin.tv_sec;
|
|
|
|
msec *= 1000;
|
|
|
|
msec += (end.tv_usec - begin.tv_usec) / 1000;
|
|
|
|
fprintf(stderr, "Saving result took %ld ms\n",
|
|
|
|
msec);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (xmlStrEqual
|
|
|
|
(cur->method, (const xmlChar *) "xhtml")) {
|
|
|
|
fprintf(stderr, "non standard output xhtml\n");
|
|
|
|
if (timing)
|
|
|
|
gettimeofday(&begin, NULL);
|
|
|
|
xsltSaveResultToFile(stdout, res, cur);
|
|
|
|
if (timing) {
|
|
|
|
long msec;
|
|
|
|
|
|
|
|
gettimeofday(&end, NULL);
|
|
|
|
msec = end.tv_sec - begin.tv_sec;
|
|
|
|
msec *= 1000;
|
|
|
|
msec +=
|
|
|
|
(end.tv_usec - begin.tv_usec) / 1000;
|
|
|
|
fprintf(stderr,
|
|
|
|
"Saving result took %ld ms\n",
|
|
|
|
msec);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
fprintf(stderr,
|
|
|
|
"Unsupported non standard output %s\n",
|
|
|
|
cur->method);
|
|
|
|
}
|
|
|
|
}
|
2001-02-13 17:09:27 +00:00
|
|
|
#ifdef LIBXML_DEBUG_ENABLED
|
2001-06-25 10:58:40 +00:00
|
|
|
}
|
2001-02-13 17:09:27 +00:00
|
|
|
#endif
|
2001-01-11 20:13:26 +00:00
|
|
|
|
2001-06-25 10:58:40 +00:00
|
|
|
xmlFreeDoc(res);
|
|
|
|
} else {
|
|
|
|
xsltRunStylesheet(cur, doc, params, output, NULL, NULL);
|
|
|
|
if (timing) {
|
|
|
|
long msec;
|
|
|
|
|
|
|
|
gettimeofday(&end, NULL);
|
|
|
|
msec = end.tv_sec - begin.tv_sec;
|
|
|
|
msec *= 1000;
|
|
|
|
msec += (end.tv_usec - begin.tv_usec) / 1000;
|
|
|
|
fprintf(stderr,
|
|
|
|
"Running stylesheet and saving result took %ld ms\n",
|
|
|
|
msec);
|
|
|
|
}
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
xsltFreeStylesheet(cur);
|
2001-01-22 18:39:41 +00:00
|
|
|
}
|
2001-01-07 14:01:28 +00:00
|
|
|
xmlCleanupParser();
|
|
|
|
xmlMemoryDump();
|
2001-06-25 10:58:40 +00:00
|
|
|
return (0);
|
2001-01-07 14:01:28 +00:00
|
|
|
}
|
|
|
|
|