]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/gdome_xslt/C++/test/main.cc
ocaml 3.09 transition
[helm.git] / helm / DEVEL / gdome_xslt / C++ / test / main.cc
1 /* This file is a test for the XSLT engine working on Gdome documents.
2  *
3  * Copyright (C) 2002 Claudio Sacerdoti Coen <sacerdot@cs.unibo.it>
4  * 
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.
9  * 
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.
14  * 
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
18  *
19  * For more information, please send an email to <sacerdot@cs.unibo.it>
20  */
21
22 #include <string>
23 #include <iostream>
24 #include "GdomeSmartDOMXSLT.hh"
25
26 namespace DOM = GdomeSmartDOM;
27 namespace DOMX = GdomeSmartDOMExt;
28
29 #define OUTPUT_FILE             "../../test_files/output.xml"
30 #define CORRECT_OUTPUT_FILE     "../../test_files/output.xml.correct"
31
32 int
33 main(void)
34 {
35    int bytes;
36    DOM::DOMImplementation di;
37    std::vector< std::pair<DOM::GdomeString, DOM::GdomeString> > params;
38
39    params.push_back(std::make_pair(DOM::GdomeString("parameter1"), DOM::GdomeString("'value1'")));
40    params.push_back(std::make_pair(DOM::GdomeString("parameter2"), DOM::GdomeString("'value2'")));
41    params.push_back(std::make_pair(DOM::GdomeString("parameter3"), DOM::GdomeString("'value3'")));
42
43    DOM::Document input = di.createDocumentFromURI("../../test_files/input.xml");
44    DOM::Document style = di.createDocumentFromURI("../../test_files/stylesheet.xsl");
45
46    DOMX::XSLTStylesheet style_libxslt(style);
47    DOM::Document output = style_libxslt.apply(input, params);
48    style_libxslt.save(output, OUTPUT_FILE);
49
50    std::cout << "The test was successful iff " << OUTPUT_FILE << " is equal to " << CORRECT_OUTPUT_FILE << std::endl;
51
52    return 0;
53 }