SGML: CDATA as Declared Value of Attribute

SGML: CDATA as Declared Value of Attribute

A CTS question from Carolyn Gordon (whether entity references in an attribute's value are recognized and replaced), and the answer, from C. M. Sperberg-McQueen.


From: "Carolyn Gordon" <care@ucla.edu>
Newsgroups: comp.text.sgml
Subject: CDATA as Declared Value of Attribute
Date: 4 Dec 1996 21:39:37 GMT
Organization: UCLA Library

I was taught that when CDATA is used as the declared value of an attribute,
entity references used in the attribute's value in a document instance
_are_ replaced (much like RCDATA in the declared content of an element).

However, when I look this issue up in the SGML Handbook, the definition of
CDATA being used in either situation points to the same definition of
character data.

What am I misunderstanding?

===========================================================================

From: cmsmcq@uic.edu (C M Sperberg-McQueen)
Newsgroups: comp.text.sgml
Subject: Re: CDATA as Declared Value of Attribute
Date: 5 Dec 1996 01:23:23 GMT
Organization: University of Illinois at Chicago

Carolyn Gordon (care@ucla.edu) wrote:
: I was taught that when CDATA is used as the declared value of an attribute,
: entity references used in the attribute's value in a document instance
: _are_ replaced (much like RCDATA in the declared content of an element).

You were taught right.

: However, when I look this issue up in the SGML Handbook, the definition of
: CDATA being used in either situation points to the same definition of
: character data.

: What am I misunderstanding?

It's not just you; I once stumped a team of extremely sharp SGML users
and computer scientists by asking them (a) are entity references expanded
when given in the value of an attribute? and (b) please prove it.

Everyone was fine on (a), it was (b) we had trouble with; we kept proving
they *aren't* expanded.

Eventually I spent three or four hours working it all out by trying to
prove in an airtight fashion that they are, or are not, expanded.
You can find the results at 

  http://www.uic.edu/~cmsmcq/misc/attributes.and.entities.html
  
I hope that will make it clear (a) why the answer is what you think it
is, and (b) why it's not so easy to find in the standard.

Perhaps the revision will improve the clarity of the text on this
point.

-C. M. Sperberg-McQueen