~centralelyon2010/inkscape/imagelinks2

« back to all changes in this revision

Viewing changes to src/dom/work/testodf.cpp

  • Committer: ishmal
  • Date: 2006-04-12 13:25:21 UTC
  • Revision ID: ishmal@users.sourceforge.net-20060412132521-5ynoezpwbzq4d1c3
Add new rearranged /dom directory

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * Phoebe DOM Implementation.
 
3
 *
 
4
 * This is a C++ approximation of the W3C DOM model, which follows
 
5
 * fairly closely the specifications in the various .idl files, copies of
 
6
 * which are provided for reference.  Most important is this one:
 
7
 *
 
8
 * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/idl-definitions.html
 
9
 *
 
10
 * Authors:
 
11
 *   Bob Jamison
 
12
 *
 
13
 * Copyright (C) 2005 Bob Jamison
 
14
 *
 
15
 *  This library is free software; you can redistribute it and/or
 
16
 *  modify it under the terms of the GNU Lesser General Public
 
17
 *  License as published by the Free Software Foundation; either
 
18
 *  version 2.1 of the License, or (at your option) any later version.
 
19
 *
 
20
 *  This library is distributed in the hope that it will be useful,
 
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
23
 *  Lesser General Public License for more details.
 
24
 *
 
25
 *  You should have received a copy of the GNU Lesser General Public
 
26
 *  License along with this library; if not, write to the Free Software
 
27
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
28
 */
 
29
 
 
30
 
 
31
 
 
32
#include "svg/svglsimpl.h"
 
33
#include "io/uristream.h"
 
34
 
 
35
 
 
36
using namespace org::w3c::dom;
 
37
 
 
38
 
 
39
bool doTest(char *filename)
 
40
{
 
41
 
 
42
    svg::SVGDOMImplementationLSImpl domImpl;
 
43
    ls::LSInput input  = domImpl.createLSInput();
 
44
    ls::LSParser &parser = domImpl.createLSParser(0, "");
 
45
 
 
46
 
 
47
    printf("######## PARSE ######################################\n");
 
48
    Document *doc;
 
49
    try
 
50
        {
 
51
        io::UriInputStream ins(filename);
 
52
        input.setByteStream(&ins);
 
53
        doc = parser.parse(input);
 
54
        ins.close();
 
55
        }
 
56
    catch (io::StreamException &e)
 
57
        {
 
58
        printf("could not open input stream %s\n", filename);
 
59
        return false;
 
60
        }
 
61
 
 
62
    if (!doc)
 
63
        {
 
64
        printf("parsing failed\n");
 
65
        return false;
 
66
        }
 
67
 
 
68
    return true;
 
69
    //### OUTPUT
 
70
    printf("######## SERIALIZE ##################################\n");
 
71
    ls::LSSerializer &serializer = domImpl.createLSSerializer();
 
72
    ls::LSOutput output = domImpl.createLSOutput();
 
73
    io::StdWriter writer;
 
74
    output.setCharacterStream(&writer);
 
75
    serializer.write(doc, output);
 
76
 
 
77
 
 
78
    delete doc;
 
79
    return true;
 
80
}
 
81
 
 
82
 
 
83
 
 
84
 
 
85
 
 
86
int main(int argc, char **argv)
 
87
{
 
88
    if (argc!=2)
 
89
       {
 
90
       printf("usage: %s xmlfile\n", argv[0]);
 
91
       return 0;
 
92
       }
 
93
    doTest(argv[1]);
 
94
    return 0;
 
95
}
 
96
 
 
97
 
 
98