Entity-declarations and CDATA

Falk, Alexander falk at icon.at
Thu Jul 8 12:31:40 BST 1999


Hi,

in a previous message on Wednesday, July 7th, Frank Korf
[mailto:Frank.Korf at memi.com] wrote:

> I tried to use an entity-declaration as follows:
> 
> <!ENTITY trtd "<BEGIN><![CDATA[<TR><TD WIDTH=100%>]]></BEGIN>">
> 
> Neither Internet Explorer nor XML Spy do accept this. It's hard to
> understand what Internet Explorer really means with its error messages
> in german language, but XML Spy is unhappy about the "%". I can't
> see why this shoult not be allowed - but if not, how should I write
> it? AFAIK, Entities must not be resolved within a CDATA-Section, so I
> can't write it as an entity.

The problem is hidden in the order of interpretation that is being defined
by the XML Specs:

1) inside the DECLARATION of your entity trtd the word CDATA is not being
interpreted as anything special (and therefore the % inside is really NOT
allowed as a single character, because it is reserved for starting a
PE-Reference)

2) whenever your are USING your entity trtd in your document later on, the
CDATA section will be interpreted as such and therefore the % would be
allowed there

So the question becomse: how do I really have to write the % into the entity
declaration? The solution is to rewrite it like this:

<!ENTITY trtd "<BEGIN><![CDATA[<TR><TD WIDTH=100&#x25;>]]></BEGIN>">

This works, because the XML Specs clearly state, that character references
(such as &#x25; for the % sign) have to be resolved BEFORE the entity is
declared. And thus the entity ends up being declared exactly as you intended
to and later on is resolved correctly whenever you are using it in your
document.

I hope this helps, to clarify this rather tricky detail of the XML Specs -
and I also would like to add that both IE and XML Spy are doing the right
thing here ;)

Kind regards,

Alexander Falk

... Icon Informations-Systeme GmbH - makers of XML Spy -
http://www.xmlspy.com
... ALEXANDER FALK
... President, CEO
... http://www.icon.at/falk

-----Original Message-----
From: Frank Korf [mailto:Frank.Korf at memi.com]
Sent: Wednesday, July 07, 1999 11:07 PM

I tried to use an entity-declaration as follows:

<!ENTITY trtd "<BEGIN><![CDATA[<TR><TD WIDTH=100%>]]></BEGIN>">

Neither Internet Explorer nor XML Spy do accept this. It's hard to
understand what Internet Explorer really means with its error messages
in german language, but XML Spy is unhappy about the "%". I can't
see why this shoult not be allowed - but if not, how should I write
it? AFAIK, Entities must not be resolved within a CDATA-Section, so I
can't write it as an entity.

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list