Parameter Entities

 <  Day Day Up  >  


An entity is essentially a macro that allows a short name to be associated with replacement text. Parameter entities define replacement text used in DTD declarations. Syntactically, a parameter entity is distinguished by using the percent (%) symbol. Its general form is shown here:

  <!ENTITY % name "replacement text">  

It is used in DTDs as follows :

  %name;  

Parameter entities are a convenient way to define commonly occurring pieces of a DTD so that changes only need to be made in one place. We see in XHTML a parameter entity to define the core attributes common to most elements.

  <!ENTITY % coreattrs   "id          ID             #IMPLIED   class       CDATA          #IMPLIED   style       %StyleSheet;   #IMPLIED   title       %Text;         #IMPLIED"   >  

Notice that entity %coreattrs further references entities (%StyleSheet; and %Text;) to define values for the style and title attributes. Once defined, the core attributes could be added to an attribute list declaration for an element, as follows:

  <!ATTLIST some-element  %coreattrs;>  

Oftentimes, you will see entities that in turn contain further entities. For example, under HTML 4.0 the coreattrs parameter entity is used with the %i18n and events parameter entities to define the expansion text for an aggregate entity called attrs .

  <!ENTITY % attrs "%coreattrs %i18n %events">  


 <  Day Day Up  >  


HTML & XHTML
HTML & XHTML: The Complete Reference (Osborne Complete Reference Series)
ISBN: 007222942X
EAN: 2147483647
Year: 2003
Pages: 252
Authors: Thomas Powell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net