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>
24 #include <libxslt/xsltconfig.h>
25 #include <libxslt/xslt.h>
26 #include <libxslt/imports.h>
28 #include "gdome_xslt.h"
30 #define OUTPUT_FILE "../../test_files/output.xml"
31 #define CORRECT_OUTPUT_FILE "../../test_files/output.xml.correct"
33 GdomeDocument* loadDocument(GdomeDOMImplementation *domimpl, char *uri)
38 doc = gdome_di_createDocFromURI(domimpl, uri, GDOME_LOAD_PARSING, &exc);
41 "DOMImplementation.createDocFromURI: failed\n\tException #%d\n",
48 /* // old version: use gdome serialization
49 int saveDocument(GdomeDOMImplementation *domimpl, GdomeDocument* doc, char *uri)
53 if (!gdome_di_saveDocToFile (domimpl, doc, uri, GDOME_SAVE_STANDARD, &exc)) {
55 "DOMImplementation.saveDocToFile: failed\n\tException #%d\n",
64 /* new version, use libxslt serialization */
65 int saveDocument(char* fname, GdomeDocument* result, xsltStylesheetPtr style) {
66 return saveResultToFilename(fname, result, style, 0);
72 GdomeDOMImplementation *domimpl;
75 xsltStylesheetPtr style_libxslt;
76 GdomeDocument *output;
78 const char* params[] = {"parameter1", "'value1'",
79 "parameter2", "'value2'",
80 "parameter3", "'value3'",
83 domimpl = gdome_di_mkref();
85 if (!(input = loadDocument(domimpl, "../../test_files/input.xml"))) return 1;
86 if (!(style = loadDocument(domimpl, "../../test_files/stylesheet.xsl"))) return 1;
88 style_libxslt = processStylesheet(style);
90 output = applyStylesheet(input, style_libxslt, params);
92 /* if (!(saveDocument(domimpl, output, "../../test_files/output.xml"))) return 1; */
93 bytes = saveDocument("../../test_files/output.xml", output, style_libxslt);
95 xsltFreeStylesheet(style_libxslt);
96 gdome_di_freeDoc (domimpl, input, &exc);
97 gdome_di_freeDoc (domimpl, style, &exc);
98 gdome_di_freeDoc (domimpl, output, &exc);
99 gdome_di_unref (domimpl, &exc);
101 printf("The test was successful iff %s is equal to %s\n",
103 CORRECT_OUTPUT_FILE);