DTD Building Blocks
The main building blocks and elements XML and HTML documents.
XML document Building Blocks
All XML documents (and HTML documents) by following simple building blocks components:
- Elements
- Attributes
- Entities
- PCDATA
- CDATA
element
The main elements are the building blocks of XML and HTML documents.
Examples of HTML elements are "body" and "table". Examples of XML element is "note" and "message". Element can contain text, other elements or is empty. Examples of empty HTML elements are "hr", "br" and "img".
Example:
<message>some text</message>
Property can provide additional information about the element.
Properties are always placed in the start tag of an element. Property always in the form of name / value pairs. The following "img" element has additional information about the source file:
Name of the element is "img". Name attribute is "src". Value of the property is "computer.gif". Since the element itself is empty, it is a "/" Off.
entity
Entity is used to define normal text variables. Entity reference is a reference to an entity.
Most students are aware of this HTML entity references: "& nbsp;". This "no off-line space" entity in HTML is used to insert an extra space in a document.
When the document is XML parser, the entity will be expanded.
Application entity | character |
---|---|
& Lt; | < |
& Gt; | > |
& Amp; | & |
& Quot; | " |
& Apos; | ' |
PCDATA
PCDATA means parsed character data (parsed character data).
The character data can be thought of as a text XML element start tag and end tags.
PCDATA is text will be parsed by a parser. These texts will be parser checks entities and tags.
Text tag will be marked as processed, and entities will be expanded.
However, parsed character data should not contain any &, <or> characters; requires & amp;, & lt; and & gt; entity to replace them, respectively.
CDATA
CDATA means character data (character data).
CDATA is text will not be parsed by a parser. In these text labels will not be treated as a tag, which entities will not be expanded.