A
alainpoint
Hello,
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>
The parsing fails in the following way:
Traceback (most recent call last):
File "C:\privatedata\myapp.py", line 60, in ?
root = ElementTree(file=infile).getroot()
File "c:\python23\lib\site-packages\elementtree\ElementTree.py", line
554, in __init__
self.parse(file)
File "c:\python23\lib\site-packages\elementtree\ElementTree.py", line
594, in parse
parser.feed(data)
File "c:\python23\lib\site-packages\elementtree\ElementTree.py", line
1171, in feed
self._parser.Parse(data, 0)
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.
Thank you for helping
Alain
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>
The parsing fails in the following way:
Traceback (most recent call last):
File "C:\privatedata\myapp.py", line 60, in ?
root = ElementTree(file=infile).getroot()
File "c:\python23\lib\site-packages\elementtree\ElementTree.py", line
554, in __init__
self.parse(file)
File "c:\python23\lib\site-packages\elementtree\ElementTree.py", line
594, in parse
parser.feed(data)
File "c:\python23\lib\site-packages\elementtree\ElementTree.py", line
1171, in feed
self._parser.Parse(data, 0)
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.
Thank you for helping
Alain