SVG parser problem

Status
Not open for further replies.

Berkut

Usenet Archive
Joined
Mar 28, 2003
Messages
1
Reaction score
0
Ref: berkut_svg_1
Hello.

I'm trying parser a SVG file with Xerces-C++... A easy SVG file could be:

<?xml version="1.0"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> <svg width="10" height="10"> <polygon id="shape" points="0,3 0,7 3,10 7,10 10,7 10,3 7,0 3,0" style="fill:rgb(0,255,0);stroke:rgb(0,0,0);stroke-width:1"/> </svg>

My first problem is the parser doesn't recognize DOCTYPE so I deleted this section of my file but I think that it isn't a good idea and I'd like to know how solve it.

My second problem is to handle the attributes, for instance "style". Are there methods to get the values 0, 255 and 0 of the property fill:rgb?

The last problem is the parser doesn't accept some elements, for instance:

<image x="178" y="24" width="10" height="10"
xlink:href="puerto_electrico.svg"
transform="translate(99 -3)"/>

Thanks in avance...

Berkut.
 

Dave Beauchemin MVP

Usenet Archive
Joined
Mar 28, 2003
Messages
13
Reaction score
0
Hi,

Regarding your first problem with the DTD, you may want to look into a setting that allows external references to be resolved. I can assure you that this works properly in MSXML. You may also want to include the SVG namespace in your root SVG element (see below).

As for retrieving attribute values, since SVG is an application of XML, you can retrieve the attribute value, but there aren't any methods specific to SVG (that I know of) enabling you to retrieve specific values. Therefore, by querying your SVG document with XPath, you could retrieve the string "fill:rgb(0,255,0);stroke:rgb(0,0,0);stroke-width:1" from the style attribute in your example below, and then you would have to parse it manually to retrieve what you need.

Finally, for the problem with the "elements not being accepted", that's probably because you didn't include a reference to the xlink namespace. Your SVG root element should look something like this (note the inclusion of the SVG namespace by default, and the xlink namespace):

<svg width="10" height="10" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 
Status
Not open for further replies.

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,245
Members
248,133
Latest member
DujonT

Latest Threads

Top