In this paper, we propose to apply compilation techniques to Documents Type Definition (DTD). At the syntactic level, we create a context free grammar, denoted GDT D , for the set of all DTDs in order to generate them. The semantic level is defined by using attributes. Each nonterminal of GDT D is assigned a set of attributes and for each production of GDT D a set of attribute equations is defined. This DTD compilation process can be used in different domains. In this article, we provide an attribute grammar that can be used to eliminate unnecessary parentheses in element declarations in a DTD. In addition, the DTD compilation process can be applied to the domain of model conversion. It makes it possible to split the model conversion into two steps: the syntactic transformation step, which consists of rewriting the source DTD in terms of XML syntax, and the second step of the effective conversion algorithm, which can be easily expressed by an Extensible Stylesheet Language Transformation (XSLT).