Your support for our advertisers helps cover the cost of hosting, research, and maintenance of this FAQ

The XML FAQ — Frequently-Asked Questions about the Extensible Markup Language

Section 4: Developers

Q 4.20: How do I include one DTD (or fragment) in another?

Use a parameter entity, same as for SGML

This works exactly the same as for SGML. First you declare the entity you want to include, and then you reference it by name as a parameter entity:

<!ENTITY % mylists SYSTEM "dtds/listfrag.ent"> 

Such declarations traditionally go all together towards the top of the main DTD file, where they can be managed and maintained, but this is not essential so long as they are declared before they are used. You use Parameter Entity Syntax for this (the percent sign) because the file is to be included at DTD compile time, not when the document instance itself is parsed.

Note that a URI is compulsory in XML as the System Identifier for all external file references: standard rules for dereferencing URIs apply (assume the same method, server, and directory as the containing document). A Formal Public Identifier can also be used, following the same rules as elsewhere.