Search code examples
entityelementdtdreusability

Can DTD entities be used to define children of an element?


When defining an element in DTD is it possible to use an entity to replace probable duplication of children elements?

For example instead of defining the following elements:

<!ELEMENT bear (weight, height, power)>
<!ELEMENT human (weight, height, power)>

Could I just replace the definition of the children with a defined entity like that:

<!ELEMENT bear &stats;>
<!ELEMENT human &stats;>
<!ENTITY stats "(weight, height, power)">

If not, what is the way to avoid duplication (in DTDs not Schemas)?


Solution

  • After seeking help from a web specialist I found that the example in the question is ALMOST right. Entities can be used in order to define elements and avoid duplication in a slightly different way (see example below).

    <!ENTITY % stats "(weight, height, power)">
    <!ELEMENT bear %stats;>
    <!ELEMENT human %stats;>