Bug in Elementtree/Expat

Fredrik Lundh fredrik at pythonware.com
Tue May 17 10:40:52 EDT 2005


alainpoint at yahoo.fr wrote:

> I use Elementtree to parse an elementary SVG file (in fact, it is one
> of the examples in the "SVG essentials" book). More precisely, it is
> the fig0201.svg file in the second chapter.
> The contents of the file are as follows (i hope it will be rendered
> correctly):
> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN"
>    "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
> <svg width="200" height="200">
> <title>Default User Coordinates</title>
> <desc>Shows a rectangle on a grid in default user coordinates</desc>
> <image xlink:href="default_ruler.svg" x="0" y="0" width="200"
> height="200"/>
> <g transform="translate(40,40)">
> <rect x="10" y="10" width="50" height="30"style="stroke: black; fill:
> none;"/>
> </g>
> </svg>
>

> xml.parsers.expat.ExpatError: unbound prefix: line 6, column 1

> The problem seems to lie with the xlink:href tag. If i remove the xlink
> namespace, it then does not produce a traceback.

so where in that file do you see an xlink declaration?

(elementtree doesn't fetch external DTD:s, so putting in the DTD file
doesn't really help).

adding

    xmlns:xlink="http://www.w3.org/1999/xlink"

to the "svg" element should make the problem go away.

</F> 






More information about the Python-list mailing list