2 * xsltproc.c: user program for the XSL Transformation 1.0 engine
4 * See Copyright for the status of this software.
9 #include "libxslt/libxslt.h"
10 #include "libexslt/exslt.h"
15 #ifdef HAVE_SYS_TIME_H
21 #ifdef HAVE_SYS_STAT_H
33 #include <libxml/xmlmemory.h>
34 #include <libxml/debugXML.h>
35 #include <libxml/HTMLtree.h>
36 #include <libxml/xmlIO.h>
37 #ifdef LIBXML_XINCLUDE_ENABLED
38 #include <libxml/xinclude.h>
40 #ifdef LIBXML_CATALOG_ENABLED
41 #include <libxml/catalog.h>
43 #include <libxml/parser.h>
44 #include <libxml/parserInternals.h>
45 #include <libxml/uri.h>
47 #include <libxslt/xslt.h>
48 #include <libxslt/xsltInternals.h>
49 #include <libxslt/transform.h>
50 #include <libxslt/xsltutils.h>
51 #include <libxslt/extensions.h>
52 #include <libxslt/security.h>
54 #include <libexslt/exsltconfig.h>
56 #if defined(WIN32) && !defined (__CYGWIN__)
57 #if defined(_MSC_VER) || defined(__MINGW32__)
59 #define gettimeofday(p1,p2)
60 #define snprintf _snprintf
63 #if defined(HAVE_SYS_TIME_H)
65 #elif defined(HAVE_TIME_H)
70 #ifdef HAVE_SYS_TIMEB_H
71 #include <sys/timeb.h>
75 static int repeat
= 0;
76 static int timing
= 0;
77 static int dumpextensions
= 0;
78 static int novalid
= 0;
79 static int nodtdattr
= 0;
81 static int nodict
= 0;
82 #ifdef LIBXML_HTML_ENABLED
85 static char *encoding
= NULL
;
86 static int load_trace
= 0;
87 #ifdef LIBXML_XINCLUDE_ENABLED
88 static int xinclude
= 0;
89 static int xincludestyle
= 0;
91 static int profile
= 0;
93 #define MAX_PARAMETERS 64
96 static int options
= XSLT_PARSE_OPTIONS
;
97 static const char *params
[MAX_PARAMETERS
+ 1];
98 static int nbparams
= 0;
99 static xmlChar
*strparams
[MAX_PARAMETERS
+ 1];
100 static int nbstrparams
= 0;
101 static xmlChar
*paths
[MAX_PATHS
+ 1];
102 static int nbpaths
= 0;
103 static char *output
= NULL
;
104 static int errorno
= 0;
105 static const char *writesubtree
= NULL
;
108 * Entity loading control and customization.
111 void parsePath(const xmlChar
*path
) {
117 if (nbpaths
>= MAX_PATHS
) {
118 fprintf(stderr
, "MAX_PATHS reached: too many paths\n");
122 while ((*cur
== ' ') || (*cur
== ':'))
125 while ((*cur
!= 0) && (*cur
!= ' ') && (*cur
!= ':'))
128 paths
[nbpaths
] = xmlStrndup(path
, cur
- path
);
129 if (paths
[nbpaths
] != NULL
)
136 xmlExternalEntityLoader defaultEntityLoader
= NULL
;
138 static xmlParserInputPtr
139 xsltprocExternalEntityLoader(const char *URL
, const char *ID
,
140 xmlParserCtxtPtr ctxt
) {
141 xmlParserInputPtr ret
;
142 warningSAXFunc warning
= NULL
;
145 const char *lastsegment
= URL
;
146 const char *iter
= URL
;
151 lastsegment
= iter
+ 1;
156 if ((ctxt
!= NULL
) && (ctxt
->sax
!= NULL
)) {
157 warning
= ctxt
->sax
->warning
;
158 ctxt
->sax
->warning
= NULL
;
161 if (defaultEntityLoader
!= NULL
) {
162 ret
= defaultEntityLoader(URL
, ID
, ctxt
);
165 ctxt
->sax
->warning
= warning
;
169 "Loaded URL=\"%s\" ID=\"%s\"\n",
170 URL
? URL
: "(null)",
176 for (i
= 0;i
< nbpaths
;i
++) {
179 newURL
= xmlStrdup((const xmlChar
*) paths
[i
]);
180 newURL
= xmlStrcat(newURL
, (const xmlChar
*) "/");
181 newURL
= xmlStrcat(newURL
, (const xmlChar
*) lastsegment
);
182 if (newURL
!= NULL
) {
183 ret
= defaultEntityLoader((const char *)newURL
, ID
, ctxt
);
186 ctxt
->sax
->warning
= warning
;
190 "Loaded URL=\"%s\" ID=\"%s\"\n",
200 if (warning
!= NULL
) {
201 ctxt
->sax
->warning
= warning
;
203 warning(ctxt
, "failed to load external entity \"%s\"\n", URL
);
205 warning(ctxt
, "failed to load external entity \"%s\"\n", ID
);
211 * Internal timing routines to remove the necessity to have unix-specific
214 #ifndef HAVE_GETTIMEOFDAY
215 #ifdef HAVE_SYS_TIMEB_H
216 #ifdef HAVE_SYS_TIME_H
220 my_gettimeofday(struct timeval
*tvp
, void *tzp
)
222 struct timeb timebuffer
;
226 tvp
->tv_sec
= timebuffer
.time
;
227 tvp
->tv_usec
= timebuffer
.millitm
* 1000L;
231 #define HAVE_GETTIMEOFDAY 1
232 #define gettimeofday my_gettimeofday
234 #endif /* HAVE_FTIME */
235 #endif /* HAVE_SYS_TIME_H */
236 #endif /* HAVE_SYS_TIMEB_H */
237 #endif /* !HAVE_GETTIMEOFDAY */
239 #if defined(HAVE_GETTIMEOFDAY)
240 static struct timeval begin
, endtime
;
242 * startTimer: call where you want to start timing
244 static void startTimer(void)
246 gettimeofday(&begin
,NULL
);
249 * endTimer: call where you want to stop timing and to print out a
250 * message about the timing performed; format is a printf
253 static void endTimer(const char *format
, ...)
258 gettimeofday(&endtime
, NULL
);
259 msec
= endtime
.tv_sec
- begin
.tv_sec
;
261 msec
+= (endtime
.tv_usec
- begin
.tv_usec
) / 1000;
263 #ifndef HAVE_STDARG_H
264 #error "endTimer required stdarg functions"
266 va_start(ap
, format
);
267 vfprintf(stderr
,format
,ap
);
270 fprintf(stderr
, " took %ld ms\n", msec
);
272 #elif defined(HAVE_TIME_H)
274 * No gettimeofday function, so we have to make do with calling clock.
275 * This is obviously less accurate, but there's little we can do about
278 #ifndef CLOCKS_PER_SEC
279 #define CLOCKS_PER_SEC 100
282 clock_t begin
, endtime
;
283 static void startTimer(void)
287 static void endTimer(char *format
, ...)
293 msec
= ((endtime
-begin
) * 1000) / CLOCKS_PER_SEC
;
295 #ifndef HAVE_STDARG_H
296 #error "endTimer required stdarg functions"
298 va_start(ap
, format
);
299 vfprintf(stderr
,format
,ap
);
301 fprintf(stderr
, " took %ld ms\n", msec
);
305 * We don't have a gettimeofday or time.h, so we just don't do timing
307 static void startTimer(void)
313 static void endTimer(char *format
, ...)
316 * We cannot do anything because we don't have a timing function
319 va_start(ap
, format
);
320 vfprintf(stderr
,format
,ap
);
322 fprintf(stderr
, " was not timed\n", msec
);
324 /* We don't have gettimeofday, time or stdarg.h, what crazy world is
334 * allow writes only on a subtree specified on the command line
337 xsltSubtreeCheck(xsltSecurityPrefsPtr sec ATTRIBUTE_UNUSED
,
338 xsltTransformContextPtr ctxt ATTRIBUTE_UNUSED
,
339 const char *value ATTRIBUTE_UNUSED
) {
342 if (writesubtree
== NULL
)
347 len
= xmlStrlen(BAD_CAST writesubtree
);
348 ret
= xmlStrncmp(BAD_CAST writesubtree
, BAD_CAST value
, len
);
355 xsltProcess(xmlDocPtr doc
, xsltStylesheetPtr cur
, const char *filename
) {
357 xsltTransformContextPtr ctxt
;
360 #ifdef LIBXML_XINCLUDE_ENABLED
366 #if LIBXML_VERSION >= 20603
367 ret
= xmlXIncludeProcessFlags(doc
, XSLT_PARSE_OPTIONS
);
369 ret
= xmlXIncludeProcess(doc
);
372 endTimer("XInclude processing %s", filename
);
383 if (output
== NULL
) {
387 for (j
= 1; j
< repeat
; j
++) {
388 res
= xsltApplyStylesheet(cur
, doc
, params
);
391 #ifdef LIBXML_HTML_ENABLED
393 doc
= htmlReadFile(filename
, encoding
, options
);
396 doc
= xmlReadFile(filename
, encoding
, options
);
399 ctxt
= xsltNewTransformContext(cur
, doc
);
402 xsltSetCtxtParseOptions(ctxt
, options
);
403 #ifdef LIBXML_XINCLUDE_ENABLED
408 res
= xsltApplyStylesheetUser(cur
, doc
, params
, NULL
,
411 res
= xsltApplyStylesheetUser(cur
, doc
, params
, NULL
,
414 if (ctxt
->state
== XSLT_STATE_ERROR
)
416 else if (ctxt
->state
== XSLT_STATE_STOPPED
)
418 xsltFreeTransformContext(ctxt
);
421 endTimer("Applying stylesheet %d times", repeat
);
423 endTimer("Applying stylesheet");
427 fprintf(stderr
, "no result for %s\n", filename
);
434 #ifdef LIBXML_DEBUG_ENABLED
436 xmlDebugDumpDocument(stdout
, res
);
439 if (cur
->methodURI
== NULL
) {
442 xsltSaveResultToFile(stdout
, res
, cur
);
444 endTimer("Saving result");
447 (cur
->method
, (const xmlChar
*) "xhtml")) {
448 fprintf(stderr
, "non standard output xhtml\n");
451 xsltSaveResultToFile(stdout
, res
, cur
);
453 endTimer("Saving result");
456 "Unsupported non standard output %s\n",
461 #ifdef LIBXML_DEBUG_ENABLED
468 ctxt
= xsltNewTransformContext(cur
, doc
);
471 xsltSetCtxtParseOptions(ctxt
, options
);
472 #ifdef LIBXML_XINCLUDE_ENABLED
476 ctxt
->maxTemplateDepth
= xsltMaxDepth
;
477 ctxt
->maxTemplateVars
= xsltMaxVars
;
480 ret
= xsltRunStylesheetUser(cur
, doc
, params
, output
,
481 NULL
, NULL
, stderr
, ctxt
);
483 ret
= xsltRunStylesheetUser(cur
, doc
, params
, output
,
484 NULL
, NULL
, NULL
, ctxt
);
488 else if (ctxt
->state
== XSLT_STATE_ERROR
)
490 else if (ctxt
->state
== XSLT_STATE_STOPPED
)
492 xsltFreeTransformContext(ctxt
);
494 endTimer("Running stylesheet and saving result");
499 static void usage(const char *name
) {
500 printf("Usage: %s [options] stylesheet file [file ...]\n", name
);
501 printf(" Options:\n");
502 printf("\t--version or -V: show the version of libxml and libxslt used\n");
503 printf("\t--verbose or -v: show logs of what's happening\n");
504 printf("\t--output file or -o file: save to a given file\n");
505 printf("\t--timing: display the time used\n");
506 printf("\t--repeat: run the transformation 20 times\n");
507 #ifdef LIBXML_DEBUG_ENABLED
508 printf("\t--debug: dump the tree of the result instead\n");
510 printf("\t--dumpextensions: dump the registered extension elements and functions to stdout\n");
511 printf("\t--novalid skip the DTD loading phase\n");
512 printf("\t--nodtdattr do not default attributes from the DTD\n");
513 printf("\t--noout: do not dump the result\n");
514 printf("\t--maxdepth val : increase the maximum depth (default %d)\n", xsltMaxDepth
);
515 printf("\t--maxvars val : increase the maximum variables (default %d)\n", xsltMaxVars
);
516 printf("\t--maxparserdepth val : increase the maximum parser depth\n");
517 #ifdef LIBXML_HTML_ENABLED
518 printf("\t--html: the input document is(are) an HTML file(s)\n");
520 printf("\t--encoding: the input document character encoding\n");
521 printf("\t--param name value : pass a (parameter,value) pair\n");
522 printf("\t value is an UTF8 XPath expression.\n");
523 printf("\t string values must be quoted like \"'string'\"\n or");
524 printf("\t use stringparam to avoid it\n");
525 printf("\t--stringparam name value : pass a (parameter, UTF8 string value) pair\n");
526 printf("\t--path 'paths': provide a set of paths for resources\n");
527 printf("\t--nonet : refuse to fetch DTDs or entities over network\n");
528 printf("\t--nowrite : refuse to write to any file or resource\n");
529 printf("\t--nomkdir : refuse to create directories\n");
530 printf("\t--writesubtree path : allow file write only with the path subtree\n");
531 #ifdef LIBXML_CATALOG_ENABLED
532 printf("\t--catalogs : use SGML catalogs from $SGML_CATALOG_FILES\n");
533 printf("\t otherwise XML Catalogs starting from \n");
534 printf("\t file:///etc/xml/catalog are activated by default\n");
536 #ifdef LIBXML_XINCLUDE_ENABLED
537 printf("\t--xinclude : do XInclude processing on document input\n");
538 printf("\t--xincludestyle : do XInclude processing on stylesheets\n");
540 printf("\t--load-trace : print trace of all external entites loaded\n");
541 printf("\t--profile or --norman : dump profiling informations \n");
542 printf("\nProject libxslt home page: http://xmlsoft.org/XSLT/\n");
543 printf("To report bugs and get help: http://xmlsoft.org/XSLT/bugs.html\n");
547 main(int argc
, char **argv
)
550 xsltStylesheetPtr cur
= NULL
;
551 xmlDocPtr doc
, style
;
552 xsltSecurityPrefsPtr sec
= NULL
;
563 sec
= xsltNewSecurityPrefs();
564 xsltSetDefaultSecurityPrefs(sec
);
565 defaultEntityLoader
= xmlGetExternalEntityLoader();
566 xmlSetExternalEntityLoader(xsltprocExternalEntityLoader
);
568 for (i
= 1; i
< argc
; i
++) {
569 if (!strcmp(argv
[i
], "-"))
572 if (argv
[i
][0] != '-')
574 #ifdef LIBXML_DEBUG_ENABLED
575 if ((!strcmp(argv
[i
], "-debug")) || (!strcmp(argv
[i
], "--debug"))) {
579 if ((!strcmp(argv
[i
], "-v")) ||
580 (!strcmp(argv
[i
], "-verbose")) ||
581 (!strcmp(argv
[i
], "--verbose"))) {
582 xsltSetGenericDebugFunc(stderr
, NULL
);
583 } else if ((!strcmp(argv
[i
], "-o")) ||
584 (!strcmp(argv
[i
], "-output")) ||
585 (!strcmp(argv
[i
], "--output"))) {
587 #if defined(WIN32) || defined (__CYGWIN__)
588 output
= xmlCanonicPath(argv
[i
]);
591 output
= (char *) xmlStrdup((xmlChar
*) argv
[i
]);
592 } else if ((!strcmp(argv
[i
], "-V")) ||
593 (!strcmp(argv
[i
], "-version")) ||
594 (!strcmp(argv
[i
], "--version"))) {
595 printf("Using libxml %s, libxslt %s and libexslt %s\n",
596 xmlParserVersion
, xsltEngineVersion
, exsltLibraryVersion
);
598 ("xsltproc was compiled against libxml %d, libxslt %d and libexslt %d\n",
599 LIBXML_VERSION
, LIBXSLT_VERSION
, LIBEXSLT_VERSION
);
600 printf("libxslt %d was compiled against libxml %d\n",
601 xsltLibxsltVersion
, xsltLibxmlVersion
);
602 printf("libexslt %d was compiled against libxml %d\n",
603 exsltLibexsltVersion
, exsltLibxmlVersion
);
604 } else if ((!strcmp(argv
[i
], "-repeat"))
605 || (!strcmp(argv
[i
], "--repeat"))) {
610 } else if ((!strcmp(argv
[i
], "-novalid")) ||
611 (!strcmp(argv
[i
], "--novalid"))) {
613 } else if ((!strcmp(argv
[i
], "-nodtdattr")) ||
614 (!strcmp(argv
[i
], "--nodtdattr"))) {
616 } else if ((!strcmp(argv
[i
], "-noout")) ||
617 (!strcmp(argv
[i
], "--noout"))) {
619 #ifdef LIBXML_HTML_ENABLED
620 } else if ((!strcmp(argv
[i
], "-html")) ||
621 (!strcmp(argv
[i
], "--html"))) {
624 } else if ((!strcmp(argv
[i
], "-encoding")) ||
625 (!strcmp(argv
[i
], "--encoding"))) {
626 encoding
= argv
[++i
];
627 } else if ((!strcmp(argv
[i
], "-timing")) ||
628 (!strcmp(argv
[i
], "--timing"))) {
630 } else if ((!strcmp(argv
[i
], "-profile")) ||
631 (!strcmp(argv
[i
], "--profile"))) {
633 } else if ((!strcmp(argv
[i
], "-nodict")) ||
634 (!strcmp(argv
[i
], "--nodict"))) {
636 } else if ((!strcmp(argv
[i
], "-norman")) ||
637 (!strcmp(argv
[i
], "--norman"))) {
639 } else if ((!strcmp(argv
[i
], "-nonet")) ||
640 (!strcmp(argv
[i
], "--nonet"))) {
641 defaultEntityLoader
= xmlNoNetExternalEntityLoader
;
642 } else if ((!strcmp(argv
[i
], "-nowrite")) ||
643 (!strcmp(argv
[i
], "--nowrite"))) {
644 xsltSetSecurityPrefs(sec
, XSLT_SECPREF_WRITE_FILE
,
646 xsltSetSecurityPrefs(sec
, XSLT_SECPREF_CREATE_DIRECTORY
,
648 xsltSetSecurityPrefs(sec
, XSLT_SECPREF_WRITE_NETWORK
,
650 } else if ((!strcmp(argv
[i
], "-nomkdir")) ||
651 (!strcmp(argv
[i
], "--nomkdir"))) {
652 xsltSetSecurityPrefs(sec
, XSLT_SECPREF_CREATE_DIRECTORY
,
654 } else if ((!strcmp(argv
[i
], "-writesubtree")) ||
655 (!strcmp(argv
[i
], "--writesubtree"))) {
657 writesubtree
= argv
[i
];
658 xsltSetSecurityPrefs(sec
, XSLT_SECPREF_WRITE_FILE
,
660 } else if ((!strcmp(argv
[i
], "-path")) ||
661 (!strcmp(argv
[i
], "--path"))) {
663 parsePath(BAD_CAST argv
[i
]);
664 #ifdef LIBXML_CATALOG_ENABLED
665 } else if ((!strcmp(argv
[i
], "-catalogs")) ||
666 (!strcmp(argv
[i
], "--catalogs"))) {
667 const char *catalogs
;
669 catalogs
= getenv("SGML_CATALOG_FILES");
670 if (catalogs
== NULL
) {
671 fprintf(stderr
, "Variable $SGML_CATALOG_FILES not set\n");
673 xmlLoadCatalogs(catalogs
);
676 #ifdef LIBXML_XINCLUDE_ENABLED
677 } else if ((!strcmp(argv
[i
], "-xinclude")) ||
678 (!strcmp(argv
[i
], "--xinclude"))) {
680 } else if ((!strcmp(argv
[i
], "-xincludestyle")) ||
681 (!strcmp(argv
[i
], "--xincludestyle"))) {
683 xsltSetXIncludeDefault(1);
685 } else if ((!strcmp(argv
[i
], "-load-trace")) ||
686 (!strcmp(argv
[i
], "--load-trace"))) {
688 } else if ((!strcmp(argv
[i
], "-param")) ||
689 (!strcmp(argv
[i
], "--param"))) {
691 params
[nbparams
++] = argv
[i
++];
692 params
[nbparams
++] = argv
[i
];
693 if (nbparams
>= MAX_PARAMETERS
) {
694 fprintf(stderr
, "too many params increase MAX_PARAMETERS \n");
697 } else if ((!strcmp(argv
[i
], "-stringparam")) ||
698 (!strcmp(argv
[i
], "--stringparam"))) {
699 const xmlChar
*string
;
703 params
[nbparams
++] = argv
[i
++];
704 string
= (const xmlChar
*) argv
[i
];
705 if (xmlStrchr(string
, '"')) {
706 if (xmlStrchr(string
, '\'')) {
708 "stringparam contains both quote and double-quotes !\n");
711 value
= xmlStrdup((const xmlChar
*)"'");
712 value
= xmlStrcat(value
, string
);
713 value
= xmlStrcat(value
, (const xmlChar
*)"'");
715 value
= xmlStrdup((const xmlChar
*)"\"");
716 value
= xmlStrcat(value
, string
);
717 value
= xmlStrcat(value
, (const xmlChar
*)"\"");
720 params
[nbparams
++] = (const char *) value
;
721 strparams
[nbstrparams
++] = value
;
722 if (nbparams
>= MAX_PARAMETERS
) {
723 fprintf(stderr
, "too many params increase MAX_PARAMETERS \n");
726 } else if ((!strcmp(argv
[i
], "-maxdepth")) ||
727 (!strcmp(argv
[i
], "--maxdepth"))) {
731 if (sscanf(argv
[i
], "%d", &value
) == 1) {
733 xsltMaxDepth
= value
;
735 } else if ((!strcmp(argv
[i
], "-maxvars")) ||
736 (!strcmp(argv
[i
], "--maxvars"))) {
740 if (sscanf(argv
[i
], "%d", &value
) == 1) {
744 } else if ((!strcmp(argv
[i
], "-maxparserdepth")) ||
745 (!strcmp(argv
[i
], "--maxparserdepth"))) {
749 if (sscanf(argv
[i
], "%d", &value
) == 1) {
751 xmlParserMaxDepth
= value
;
753 } else if ((!strcmp(argv
[i
],"-dumpextensions"))||
754 (!strcmp(argv
[i
],"--dumpextensions"))) {
757 fprintf(stderr
, "Unknown option %s\n", argv
[i
]);
762 params
[nbparams
] = NULL
;
765 options
= XML_PARSE_NOENT
| XML_PARSE_NOCDATA
;
767 options
= XML_PARSE_NOENT
| XML_PARSE_DTDLOAD
| XML_PARSE_NOCDATA
;
769 options
|= XML_PARSE_NODICT
;
772 * Register the EXSLT extensions and the test module
775 xsltRegisterTestModule();
778 xsltDebugDumpExtensions(NULL
);
780 for (i
= 1; i
< argc
; i
++) {
781 if ((!strcmp(argv
[i
], "-maxdepth")) ||
782 (!strcmp(argv
[i
], "--maxdepth"))) {
785 } else if ((!strcmp(argv
[i
], "-maxparserdepth")) ||
786 (!strcmp(argv
[i
], "--maxparserdepth"))) {
789 } else if ((!strcmp(argv
[i
], "-o")) ||
790 (!strcmp(argv
[i
], "-output")) ||
791 (!strcmp(argv
[i
], "--output"))) {
794 } else if ((!strcmp(argv
[i
], "-encoding")) ||
795 (!strcmp(argv
[i
], "--encoding"))) {
798 } else if ((!strcmp(argv
[i
], "-writesubtree")) ||
799 (!strcmp(argv
[i
], "--writesubtree"))) {
802 } else if ((!strcmp(argv
[i
], "-path")) ||
803 (!strcmp(argv
[i
], "--path"))) {
807 if ((!strcmp(argv
[i
], "-param")) || (!strcmp(argv
[i
], "--param"))) {
811 if ((!strcmp(argv
[i
], "-stringparam")) ||
812 (!strcmp(argv
[i
], "--stringparam"))) {
816 if ((argv
[i
][0] != '-') || (strcmp(argv
[i
], "-") == 0)) {
819 style
= xmlReadFile((const char *) argv
[i
], NULL
, options
);
821 endTimer("Parsing stylesheet %s", argv
[i
]);
822 #ifdef LIBXML_XINCLUDE_ENABLED
827 #if LIBXML_VERSION >= 20603
828 xmlXIncludeProcessFlags(style
, XSLT_PARSE_OPTIONS
);
830 xmlXIncludeProcess(style
);
833 endTimer("XInclude processing %s", argv
[i
]);
839 fprintf(stderr
, "cannot parse %s\n", argv
[i
]);
843 cur
= xsltLoadStylesheetPI(style
);
845 /* it is an embedded stylesheet */
846 xsltProcess(style
, cur
, argv
[i
]);
847 xsltFreeStylesheet(cur
);
851 cur
= xsltParseStylesheetDoc(style
);
853 if (cur
->errors
!= 0) {
870 if ((cur
!= NULL
) && (cur
->errors
== 0)) {
871 for (; i
< argc
; i
++) {
875 #ifdef LIBXML_HTML_ENABLED
877 doc
= htmlReadFile(argv
[i
], encoding
, options
);
880 doc
= xmlReadFile(argv
[i
], encoding
, options
);
882 fprintf(stderr
, "unable to parse %s\n", argv
[i
]);
887 endTimer("Parsing document %s", argv
[i
]);
888 xsltProcess(doc
, cur
, argv
[i
]);
893 xsltFreeStylesheet(cur
);
894 for (i
= 0;i
< nbstrparams
;i
++)
895 xmlFree(strparams
[i
]);
898 xsltFreeSecurityPrefs(sec
);
899 xsltCleanupGlobals();