Bug in Elementtree/Expat

Discussion in 'Python' started by alainpoint@yahoo.fr, May 17, 2005.

Guest

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>

Advertisements

Guest

Thanks for the tip. It indeed solves the problem.
Most examples in the book do not include such a declaration and yet are
properly rendered by Internet Explorer.
Is it mandatory and why is it that Expat crashes on it?

<> wrote in message news:...
> Most examples in the book do not include such a declaration and yet are
> properly rendered by Internet Explorer.
> Is it mandatory and why is it that Expat crashes on it?

It's not mandatory but it's probably good practice to make the document
self-contained. The xlink prefix is defined in the DTD but Expat, as a
nonvalidating parser, won't fetch it.

Guest

"""
> Most examples in the book do not include such a declaration and yet
are
> properly rendered by Internet Explorer.
> Is it mandatory and why is it that Expat crashes on it?

It's not mandatory but it's probably good practice to make the document
self-contained. The xlink prefix is defined in the DTD but Expat, as a
nonvalidating parser, won't fetch it.
"""

Important clarification:

The decision whether or not to read the external DTD subset is separate
from the decision whether or not to validate. Expat does not validate,
but it does read the external subset, if you tell it to. There are
other uses for reading the external subset, such as entity resolution.
And you can have validation constructs in the internal DTD subset (IOW
right in the XML source file itself), and expat will not do anything
with them because it does not validate.

This may seem a subtle distinction, but it lies behind a lot of user
confusion in practice. The XML WG really should have simplified such
matters (IIRC SGML compatability was a big obstruction to doing so).

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!