Re: Is markup allowed in attribute values?

At 08:01 PM 6/26/96 -0500, Murray Altheim wrote:
>First, note that not all attributes are declared CDATA. I'm not sure what
>you mean by "sometimes" entities. Most HTML attributes can contain
>entities; the question is whether or not they will be processed (ie.,

I'm getting confused by this discussion, so let me see if I can clarify.
_ALL_ SGML/HTML attributes may have entity references in them. _ALL_
SGML/HTML attributes allow entity expansion/processing/replacement (choose
your favourite term). Whenever I feel I am in danger of forgetting this, I
try to parse a sample document I made months ago to test an SGML editor's

<!ELEMENT ROOT o o (foo, bar, baz, blart ) >

<!-- Elements to test out different attribute types -->
<!ELEMENT foo  - o EMPTY >
<!ELEMENT bar  - o EMPTY >
<!ATTLIST bar     id ID      #IMPLIED>
<!ELEMENT baz  - o EMPTY >
<!ATTLIST baz     cd CDATA   #IMPLIED>
<!ELEMENT blart  - o EMPTY >
<!ATTLIST blart     nm NAME   #IMPLIED>

<!-- Entities to replace -->
<!ENTITY nument CDATA "123">
<!ENTITY ident  CDATA "anid">
<!ENTITY cdataent CDATA "Some Cdata">
<foo num="&nument">
<bar id="&ident;">
<baz cd="&cdataent;">
<blart nm="&nment;">

This document _will_ validate correctly (try it!) because the entities _are_
replaced. The reason many people believe that they are not is because of the
unfortunate overloading of the keyword "CDATA" in different contexts. In
attributes it means that the content is "character data". But that
"character data" behaves as "replacable character data" does in element
content context.

So, as I understand it, entity markup is _always_ allowed in attributes.
Less than and greater than symbols are _never_ interpreted as markup within
attributes (just as they are not in "replacable character data) so it is
impossible to put elements in attributes although it is possible (in fact
quite easy) to put less than and greater than characters in attributes.

 Paul Prescod

Received on Thursday, 27 June 1996 10:41:05 UTC