<!DOCTYPE doc [
<!ENTITY & "&amp;">
]>

I do not think this is legal.
(1) Recursive entitity declaration
(2) &amp; is predefined, & is reserved as entity prefix.

I do not think that You can redefine the XML grammar by defining "&" or "<"
as entities. In summary, You do not need the DOCTYPE at all. (I haven't read
the spec recently, I may be wrong).

Then, to my understanding,

<doc:p>&</doc:p> should be <p>&</p> because doc: is a namespace prefix, not
a DOCTYPE prefix.
<p>&</p> should be <p>&amp;</p> (cf. above)

Therefore, You have the same problem for elements and attributes.

We do have the same problem and solve it by transforming all strings by our
class XMLEscaper or (where elements may use CDATA when it must preserve
whitespace and linefeeds) before generating XML. I would be surprised if
there existed some magic avoiding this step. [EMAIL PROTECTED] has proposed
this magic to the JDOM list such that Java strings can be passed in and out
of elements and attributes without worry. Dunno what happened to this
proposition. JDOM *is* the place where this problem should be fixed.

Bye,
Falk


Reply via email to