References in default attribute values

Joe English jenglish at crl.com
Fri Mar 14 19:49:56 GMT 1997


richard at cogsci.ed.ac.uk wrote:

> If a default for an attribute value contains an entity reference, must
> the entity be declared before attribute list declaration?  I cannot
> see such a requirement, and I find this surprising since there *is*
> such a requirement for (parameter) references in entity declarations.


I'm not positive about the rules in XML, but in SGML
it _is_ necessary for the general entity declaration 
to appear first, as near as I can tell.  (SGMLS agrees)

By productions [143], [147], [33], and [34], the default
value in an attribute definition is parsed as replaceable
character data, which means that general entity references
are recognized and replaced, and the rule that entities
must be declared before they are referenced applies.

[ Another, erm, interesting fact is that parameter entity
references are _not_ replaced in attribute value literals
in ATTLIST declarations.  E.g.:

	<!ENTITY % e1 "foo">
	<!ENTITY % e2 "%e1;"		-- %e1; is expanded here -->
	<!ATTLIST %e1;			-- and here -->
	    A1 CDATA #FIXED %e1;	-- and here --
	    A2 CDATA #FIXED "%e1;"	-- but not here! --
	>

I've been fooled by this more than once... ]


--Joe English

  jenglish at crl.com


[143] attribute definition (11.3, 421:1) =
        ( attribute name [144],
          +ps [65],
          declared value [145],
          +ps [65],
          default value [147] )

[147] default value (11.3.4, 425:1) =
        ( ( ?( rni ("#"),
               "FIXED",
               +ps [65] ),
            attribute value specification [33] )
        | ( rni ("#"),
            ( "REQUIRED"
            | "CURRENT"
            | "CONREF"
            | "IMPLIED" ) ) )

[33] attribute value specification (7.9.3, 331:1) =
        ( attribute value [35]
        | attribute value literal [34] )

[34] attribute value literal (7.9.3, 331:4) =
        ( ( lit ("\""),
            replaceable character data [46],
            lit ("\"") )
        | ( lita ("'"),
            replaceable character data [46],
            lita ("'") ) )

xml-dev: A list for W3C XML Developers
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To unsubscribe, send to majordomo at ic.ac.uk the following message;
unsubscribe xml-dev
List coordinator, Henry Rzepa (rzepa at ic.ac.uk)




More information about the Xml-dev mailing list