Re: <!ENTITY amp "&38;">

Richard L. Goerwitz (richard@goon.stg.brown.edu)
Wed, 02 Dec 1998 09:26:27 -0500


David Brownell wrote:
>
> Richard Tobin wrote:

> > > the file play.dtd contains the tag <!ENTITY amp "&#38;">
> >
> > This is not entirely surprising, since that file is dated 31 Jan 98
> >
> > IE 5 appears to be within its rights not to detect the error
>
> This is one of those areas where the XML spec gives too much (IMHO)
> leeway in terms of error reporting. While I think IE5 is doing a
> legal thing here, there's not much reason not to fully recover from
> this error in all cases, since "amp" is predefined and the original
> definition trumps the others. Most other parsers in fact adopt a
> rather different legal way to handle this error: ignore it totally!

Okay. <!ENTITY amp "&#38;"> is not an error, because built-in entities
are already defined, by definition. And so this (duplicate) definition
ought to be ignored. Even if it isn't ignored, it doesn't matter. As
long as it never gets expanded, <!ENTITY amp "&#38;"> isn't an error.
(And it won't get expanded, because the entity's replacement text will
already have been interned via the built-in definition).

Just for the record, STG's validator flags <!ENTITY amp "&#38;"> as an
error. Why? Because it is superfluous and misleading. Even in cases
where the entity isn't built-in (e.g., <!ENTITY AMP "&#38;">), and the
entity isn't used in the text anywhere, we still flag it as an error.
Why? Because again, such a definition is at best superfluous, and at
worse misleading in the sense that it may produce errors in document +
DTD combinations where the DTD was thought to be clean.

Just for fun, try typing

<!DOCTYPE xxx [
<!ENTITY amp "&#38;">
<!ELEMENT xxx EMPTY>
]>
<xxx/>

into our validator (http://www.stg.brown.edu/service/xmlvalid/). You
will see both warning messages (about [incompatible] entity redefini-
tions) and error messages (about <!ENTITY amp "&#38;"> having an in-
valid expansion - even though it's never actually used in the document
below).

Our early expansion of entities for the purpose of error correction is
a bit fascist, but the point is to encourage the writing of DTDs that
actually make sense.

-- 

Richard Goerwitz PGP key fingerprint: C1 3E F4 23 7C 33 51 8D 3B 88 53 57 56 0D 38 A0 For more info (mail, phone, fax no.): finger richard@goon.stg.brown.edu