VirtualBox

source: vbox/trunk/src/libs/libxslt-1.1.22/doc/tutorial/libxslt_tutorial.c@ 7590

Last change on this file since 7590 was 7296, checked in by vboxsync, 17 years ago

Added libxslt-1.1.22 sources.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 2.5 KB
Line 
1<![CDATA[
2/*
3 * libxslt_tutorial.c: demo program for the XSL Transformation 1.0 engine
4 *
5 * based on xsltproc.c, by Daniel.Veillard@imag.fr
6 * by John Fleck
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, MA 02139, USA.
21 *
22 */
23
24#include <string.h>
25#include <libxml/xmlmemory.h>
26#include <libxml/debugXML.h>
27#include <libxml/HTMLtree.h>
28#include <libxml/xmlIO.h>
29#include <libxml/DOCBparser.h>
30#include <libxml/xinclude.h>
31#include <libxml/catalog.h>
32#include <libxslt/xslt.h>
33#include <libxslt/xsltInternals.h>
34#include <libxslt/transform.h>
35#include <libxslt/xsltutils.h>
36
37
38
39extern int xmlLoadExtDtdDefaultValue;
40
41static void usage(const char *name) {
42 printf("Usage: %s [options] stylesheet file [file ...]\n", name);
43 printf(" --param name value : pass a (parameter,value) pair\n");
44
45}
46
47int
48main(int argc, char **argv) {
49 int i;
50 const char *params[16 + 1];
51 int nbparams = 0;
52 xsltStylesheetPtr cur = NULL;
53 xmlDocPtr doc, res;
54
55 if (argc <= 1) {
56 usage(argv[0]);
57 return(1);
58 }
59
60
61 for (i = 1; i < argc; i++) {
62 if (argv[i][0] != '-')
63 break;
64 if ((!strcmp(argv[i], "-param")) ||
65 (!strcmp(argv[i], "--param"))) {
66 i++;
67 params[nbparams++] = argv[i++];
68 params[nbparams++] = argv[i];
69 if (nbparams >= 16) {
70 fprintf(stderr, "too many params\n");
71 return (1);
72 }
73 } else {
74 fprintf(stderr, "Unknown option %s\n", argv[i]);
75 usage(argv[0]);
76 return (1);
77 }
78 }
79
80 params[nbparams] = NULL;
81 xmlSubstituteEntitiesDefault(1);
82 xmlLoadExtDtdDefaultValue = 1;
83 cur = xsltParseStylesheetFile((const xmlChar *)argv[i]);
84 i++;
85 doc = xmlParseFile(argv[i]);
86 res = xsltApplyStylesheet(cur, doc, params);
87 xsltSaveResultToFile(stdout, res, cur);
88
89 xsltFreeStylesheet(cur);
90 xmlFreeDoc(res);
91 xmlFreeDoc(doc);
92
93 xsltCleanupGlobals();
94 xmlCleanupParser();
95 return(0);
96
97}
98]]>
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette