SVG::Parser issue with top level comments
Hi Peter,
In testing out use of SVG::Parser with SVG documents created by Inkscape I found an issue. Inkscape (as well as other SVG editors like Sodipodi) insert a comment at the top level indicating the app that made it, but SVG::Parser appears to not like top level comments.
I.e., for a document like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <!-- Created with Inkscape ("http://www.inkscape.org/") --> <svg id="svg1" ...> ... </svg>
I get the following from running it through SVG::Parser 0.97:
Can't call method "comment" on an undefined value at /usr/lib/perl5/site_perl/5.8.0/SVG/Parser/Expat.pm line 225.
When I change line 225 from this:
$parent->comment($data);
to this:
if ($parent) { $parent->comment($data); }
The problem goes away. For my purpose, dropping comments is fine; I imagine there is probably a better solution, and would love to hear it.
(I'm writing a validator for checking presence and validity of RDF metadata within an SVG file, for the Open Clip Art Library project, http://www.openclipart.org.)
Hope this helps!
Bryce
On Sat, 2004-06-12 at 01:55, Bryce Harrington wrote:
When I change line 225 from this:
$parent->comment($data);
to this:
if ($parent) { $parent->comment($data); }
The problem goes away. For my purpose, dropping comments is fine; I imagine there is probably a better solution, and would love to hear it.
Inkscape actually currently drops top-level comments the same way, for the same reasons (unless I fixed it recently and forgot -- but I don't recall figuring out the proper way to deal with it).
Having checked, such comments are definitely valid, though:
http://www.w3.org/TR/2004/REC-xml-20040204/#NT-prolog
-mental
participants (2)
-
Bryce Harrington
-
MenTaLguY