Quackit Logo
HTML
CSS
Scripting
Database
Hosting
Design
XML

Print Version

DTD Parameter Entities

In the previous lesson we created a General Entity Reference. There is also another type of entity known as a Parameter Entity Reference. This is an entity that is used within the DTD itself. In other words, you can create an entity that can be used within your DTD declarations themselves.

Syntax

When creating a parameter entity, you need to insert a percentage sign (%) between ENTITY, and the name of the entity:

<!ENTITY % name definition>

You can also declare external parameter entities. You do this using the following syntax:

Private:

<!ENTITY % name SYSTEM uri>

Public:

<!ENTITY % name PUBLIC FPI uri>

Example

Here's an example of an internal parameter entity. In this example, the second line is the actual declaration for the "author" element.

This is quite a simplistic example. In reality, you would use parameter entities to represent text that you need to repeat many times within your DTD. For example, multiple elements might share the same text in their declarations. In this case, a parameter reference could be used instead of repeating the same text.

<!ENTITY % author "<!ELEMENT author EMPTY">
%author;

Enjoy this website?

  • Share
  • Add this page to your Favorites
  • Link to this page (copy/paste into your own website or blog):
  • Link to Quackit using one of these banner ads.
  • Help support Quackit by making a donation

Oh, and thank you for supporting Quackit!

© Copyright 2000 - 2010 Quackit.com