Advanced DTD: Entities, Mixed Content, and Limitations
Unit 2âĸCLO02
Learning Objectives
Course Learning Outcomes
CLO02
Course Outcomes
CO02
âšī¸
Introduction
Advanced DTD topics include entities for reuse and mixed content models. At the same time, DTD has major limitations: weak typing and limited constraint support. Understanding these strengths and limits helps you justify XSD in modern applications.
The Basics
Entities
Entities define reusable fragments.
- General entities: used in XML content
- Parameter entities: used inside the DTD
Mixed content
Mixed content allows text interleaved with inline elements.
Technical Details
General entity example
<!ENTITY company "ACME Pvt Ltd">
Usage:
<name>&company;</name>
Parameter entity example
<!ENTITY % commonAttrs "id ID #REQUIRED created CDATA #IMPLIED">
<!ATTLIST book %commonAttrs;>
Mixed content pattern
<!ELEMENT p (#PCDATA|b|i)*>
DTD limitations
- limited datatypes
- weak constraints (no ranges/patterns)
- not XML syntax
- weak namespace integration
Examples
Example: mixed content
<!DOCTYPE doc [
<!ELEMENT doc (p+)>
<!ELEMENT p (#PCDATA|b|i)*>
<!ELEMENT b (#PCDATA)>
<!ELEMENT i (#PCDATA)>
]>
<doc>
<p>XML is <b>structured</b> and <i>portable</i>.</p>
</doc>
Real-World Use
Practical
- Add general entities for repeated organization name.
- Add one parameter entity to share attributes.
- Create one mixed-content element (e.g.,
p).
đ For exams
Exam
- Define entity.
- Explain mixed content with DTD syntax.
- Compare DTD and XSD with at least 6 points.
⨠Key points
Takeaways
- Entities support reuse and modularity.
- Mixed content uses
(#PCDATA|...)*. - XSD addresses many DTD limitations.