Types of DTD declaration

DTD declarations section you can define different elements, attributes, entity, notation rules. Well structured XML (include DTD) document follow the DTD specified rules.

  • Element declaration Specifies the name of the tag that you use to build XML document.

  • Attributes declaration Specifies the attributes that you use inside element.

  • Entity declaration Specifies the pieces of text that are represent as a specific entity name.
    XML ENTITY use to represent specific character that are difficult to write in standard keyboard. You can access defined entity in several times.

  • Notation declaration Specifies the format type of non XML files like audio, image file.


Types of DTD declaration

Types of DTD declaration

Notation declaration

General syntax of notation declaration,

<!NOTATION notation_name PUBLIC url>
<!NOTATION notation_name SYSTEM url>

Here, notation_name is name to identify declared notation. PUBLIC is keyword to specify the publisher URL. SYSTEM is keyword to specify URL for limited access.

Step for Notation Declaration

Step.1 Declare the notation

<!NOTATION GIF SYSTEM "image/gif">
<!NOTATION JPG SYSTEM "image/jpeg">
<!NOTATION PNG SYSTEM "image/png">

Step.2 Declare the entity

<!ENTITY image_path SYSTEM "images/logo.png" NDATA (GIF | JPG | PNG)>

Step.3 Declare the entity type attributes

<!ATTLIST img src ENTITY #REQUIRED>

Step.4 Adding attribute to XML Element

<img src="image_path" />