Batik - parsing a SVG [message #221581] |
Wed, 16 August 2006 09:21 |
Eclipse User |
|
|
|
Originally posted by: dscholz.htwm.de
Hello,
I have an SVG-File and for example I want to parse a path. I know there
are Parsers in Batik like the PathParser but I don't know exactly how tu
use it. Here are some lines of code where I try to use the PathParser:
PathParser pp = new PathParser();
PHandler ph = new PHandler();
pp.setPathHandler(ph);
File file = null;
FileReader freader;
BufferedReader bufreader;
try {
file = new File("test.svg");
freader = new FileReader(file);
bufreader = new BufferedReader(freader);
bufreader.mark((int)file.length() + 1);
String line = bufreader.readLine();
do {
System.out.println(line);
line = bufreader.readLine();
} while (line != null);
bufreader.reset();
pp.parse(bufreader);
freader.close();
bufreader.close();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
I check the input of the file by printing the lines of the SVG (XML) to
the console which is correct. I also can view the SVG without problems but
when pp.parse(...) is called I got the following errors:
org.apache.batik.parser.ParseException: Unexpected character (code: 60).
at org.apache.batik.parser.AbstractParser.reportError(Unknown Source)
at org.apache.batik.parser.PathParser.doParse(Unknown Source)
at org.apache.batik.parser.AbstractParser.parse(Unknown Source)
Does anybody know how to use the Parsers? Thanks for your help and hints
in advance.
|
|
|
Powered by
FUDForum. Page generated in 0.03330 seconds