Re: parameter entity expansion

>Date: Tue, 11 Aug 1998 14:22:17 -0400
>From: "Richard L. Goerwitz III" <richard@goon.stg.brown.edu>

>Just as
>
>  <!ENTITY % firstpart "<!ELEMENT">
>  
>is invalid, so also should
>
>  <!ENTITY % firstpart "'start">

The first declaration is not, in itself, invalid.

>Wording:
>
>  Parameter entities may not expand to partial quoted strings
>  such as "'start" or "end&#39;".
>
>The reason it would be a bad idea to allow "'start" or "end&#39;"
>is that people will try things like:
>
>  <!ENTITY % firstpart "'start">
>  <!ENTITY % lastpart "end'">
>  <!ENTITY bothparts %firstpart;%lastpart;>

The example shown is illegal in SGML and should, I believe, be
illegal in XML; I need to consult the spec to see whether the current
wording effectively forbids it or not.  Note, however, that the
following example is legal SGML and should, I believe, be legal in
XML:

  <!ENTITY % firstpart "'start">
  <!ENTITY % lastpart "end'">
  <!ENTITY bothparts "%firstpart;%lastpart;">
  <!ENTITY legal     %bothparts; >

When the work group discussed the constraints on parameter entities,
the discussion made clear that although token-pasting of the kind
shown in this example can be confusing and error-prone, it is
nevertheless necessary for some things which the work group was 
loath to forbid.

>Does this make sense?

I think so.

-C. M. Sperberg-McQueen

Received on Tuesday, 11 August 1998 15:08:58 UTC