Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

DTD building blocks


May 28, 2021 DTD


Table of contents


DTD - XML Building Blocks


The main building blocks for XML and HTML documents are element tags. In this section, we'll cover these building blocks.


XML document building blocks

All XML documents (and HTML documents) consist of the following simple building blocks:

  • Elements
  • Property
  • Entity
  • PCDATA
  • Cdata

Elements

Elements are the primary building blocks for XML and HTML documents.

Examples of HTML elements are "body" and "table". E xamples of XML elements are "note" and "message". E lements can contain text, other elements, or are empty. Examples of empty HTML elements are "hr," "br," and "img."

Instance:

<body>some text</body>

<message>some text</message>

Properties provide additional information about elements.

The property is always placed in the start label of an element. P roperties always appear in pairs as names/values. The following "img" element has additional information about the source file:

<img src="computer.gif" />

The name of the element is "img". T he name of the property is "src". T he value of the property is "computer .gif". Because the element itself is empty, it is closed by a "/".


Entity

In XML, some characters are of special significance, for example, we use slt; to represent the starter of a label.

An entity is a variable used to define normal text. An entity reference is a reference to an entity.

Most students understand this HTML entity reference: "." This "no-fold space" entity is used in HTML to insert an extra space into a document.

When a document is parsed by an XML parser, the entity is expanded.

The entity reference Character
< <
&gt; >
&amp; &
&quot; "
&apos; '

PCDATA

PCDATA means parsed character data.

Think of character data as text between the start and end labels of an XML element.

PCDATA is the text that is parsed by the parser. The text is checked by the parser for entities as well as tags.

Labels in the text are treated as tags, and entities are expanded.

However, the parsed character data should not contain any characters; 、 &lt; a nd the entities to replace them separately.


Cdata

CDATA means character data.

CDATA is text that is not parsed by the parser. Labels in these texts are not treated as tags, and the entities in them are not expanded.

That's what you know about DTD building blocks, and if you want to learn more about HTML tags, please refer to the HTML Reference Manual on this site!