Is it possible to have more than one DTD in an XML file?

Thomas BROYER

You cannot have more than one DOCTYPE declaration in an XML document, but one document can "call" several DTD's using external parameter entities.

 

Example:

Let's say you have some document with a «svg:svg» root element and its associated DTD, and another document with a «mml:math» root element and its associated DTD.

Now you want to have a single document with, say, a «bar» root element with allowed children any of «svg:svg» or «mml:math» and their subtrees as declared in the two DTD's mentionned above.

The solution is to "import" the DTD's in the "bar DTD":

<!ELEMENT bar (svg:svg | mml:math)+>
<!ENTITY % svg SYSTEM "svg.dtd">
%svg;
<!ENTITY % mml SYSTEM "mml.svg">
%mml;
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact