DTD online tuto...login
DTD online tutorial document
author:php.cn  update time:2022-04-20 15:01:34

DTD building blocks


DTD - XML Building Module


The main elements of the building module are XML and HTML documents.


XML document building blocks

All XML documents (as well as HTML documents) are composed of the following simple building blocks:

  • Elements

  • Attributes

  • Entities

  • PCDATA

  • CDATA


##Elements

Elements are the

main building blocks of XML and HTML documents.

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

Example:

<body>some text</body>

The <message>some text</message>


attribute provides

extra information about the element.

Attributes are always placed in the opening tag of an element. Properties always appear in

name/value pairs. The following "img" element holds additional information about the source file:

<img src="../style/images/computer.gif" />
The name of the element is "img". The name of the attribute is "src". The value of the property is "computer.gif". Since the element itself is empty, it is closed with a " /".


Entity

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

Most students know this HTML entity reference: " ". The "no wrapping space" entity is used in HTML to insert an extra space in a document.

Entities are expanded when the document is parsed by the XML parser.

##Entity Application<>&"##''

PCDATA

PCDATA means parsed character data.

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

PCDATA is the text that will be parsed by the parser. These texts will be checked by the parser for entities and tags.

Tags in text will be treated as tags, and entities will be expanded.

However, the character data being parsed should not contain any &, < or > characters; they need to be replaced with &, < and > entities respectively.


CDATA

CDATA means character data.

CDATA is text that will not be parsed by the parser. Tags in these texts will not be treated as tags, and entities within them will not be expanded.

Characters
<
>
&
"