Advanced DTD: Entities, Mixed Content, and Limitations
Unit 2âĸCLO02
Learning Objectives
Course Learning Outcomes
CLO02
Course Outcomes
CO02
âšī¸
Introduction
This topic is about reuse and realism. Entities keep repeated text consistent, mixed content supports text with inline tags, and ID/IDREF mimic primary/foreign keys. You also learn where DTDs fall short so you can justify XSD.
Study tracker
Mark what you have completed for this topic.
0% done
The Basics
Entity toolkit
- General entity: reusable text inside XML instances.
- Parameter entity: reusable fragments inside the DTD itself.
Mixed content
Allows text with inline elements, e.g., paragraphs that contain <b> and <i>.
Technical Details
Patterns to remember
General entity
<!ENTITY company "ACME Pvt Ltd">
...
<name>&company;</name>
Parameter entity
<!ENTITY % commonAttrs "id ID #REQUIRED created CDATA #IMPLIED">
<!ATTLIST book %commonAttrs;>
Mixed content
<!ELEMENT p (#PCDATA|b|i)*>
Limitations
- No native data ranges or regex patterns.
- Poor namespace story.
- Not written in XML, so tooling reuse is limited.
Examples
Sample with 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>
Self-check
Real-World Use
Try it
- Add a general entity for your institute name and reuse it in two elements.
- Create a paragraph element that allows bold/italic mixed with text.
- Add ID/IDREF to link a book to a publisher element.
đ For exams
Exam cues
- Difference between general and parameter entities.
- Mixed content syntax and why the * is required.
- Three crisp limitations of DTD vs XSD.
⨠Key points
Takeaways
- Entities reduce duplication; parameter entities keep DTDs DRY.
- Mixed content is essential for narrative text with inline markup.
- Use XSD when you need types, namespaces, and stricter constraints.