1 /* This file is a test for the XSLT engine working on Gdome documents.
3 * Copyright (C) 2002 Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 * For more information, please send an email to <sacerdot@cs.unibo.it>
23 #include <libgdome/gdome.h>
24 #include <libxslt/xsltconfig.h>
25 #include <libxslt/xslt.h>
26 #include <libxslt/imports.h>
28 #include "gdome_xslt.h"
30 GdomeDocument* loadDocument(GdomeDOMImplementation *domimpl, char *uri)
35 doc = gdome_di_createDocFromURI(domimpl, uri, GDOME_LOAD_PARSING, &exc);
38 "DOMImplementation.createDocFromURI: failed\n\tException #%d\n",
45 int saveDocument(GdomeDOMImplementation *domimpl, GdomeDocument* doc, char *uri)
49 if (!gdome_di_saveDocToFile (domimpl, doc, uri, GDOME_SAVE_STANDARD, &exc)) {
51 "DOMImplementation.saveDocToFile: failed\n\tException #%d\n",
62 GdomeDOMImplementation *domimpl;
65 xsltStylesheetPtr style_libxslt;
66 GdomeDocument *output;
68 const char* params[] = {"parameter1", "'value1'",
69 "parameter2", "'value2'",
70 "parameter3", "'value3'",
73 domimpl = gdome_di_mkref();
75 if (!(input = loadDocument(domimpl, "../../test_files/input.xml"))) return 1;
76 if (!(style = loadDocument(domimpl, "../../test_files/stylesheet.xsl"))) return 1;
78 style_libxslt = processStylesheet(style);
80 output = applyStylesheet(input, style_libxslt, params);
82 if (!(saveDocument(domimpl, output, "../../test_files/output.xml"))) return 1;
84 xsltFreeStylesheet(style_libxslt);
85 gdome_di_freeDoc (domimpl, input, &exc);
86 gdome_di_freeDoc (domimpl, style, &exc);
87 gdome_di_freeDoc (domimpl, output, &exc);
88 gdome_di_unref (domimpl, &exc);
90 printf("The test was successful iff ../../test_files/output.xml.correct is\n");
91 printf("equal to ../../test_files/output.xml\n");