How to choose between DTD and XSD

前端 未结 7 2135
南旧
南旧 2020-12-02 10:37

I want to use either a DTD or an XSD to describe my XML document. I\'ve read that XSDs are better than DTDs since they support namespaces and data types, and that DTDs are o

7条回答
  •  遥遥无期
    2020-12-02 11:09

    There is an IMHO very important issue to use a DTD (maybe together with a XSD if you need in-deep-validation):

    In DTD you can define your own entities eg:

    
    

    In your document you can wherevever needed simply code &MyName; instead typing all this stuff.

    Furthermore assume you have a XML-like file (maybe produced by some other application) that consists of a lot of similar tags but no root-tag, eg:

     
    
      Erstes Buch
    
    ...
    
      Fünftes Buch
    
    

    Assume this file is named "Booklist.TXT",

    Now you can code your master-xml:

     
    
    ]
    
    
    ... some prefix-stuff as needed ...
    &AllBooks; 
    ... some post stuff es needed ...
    
    

    and whenever you need the books in another context you only must code the surrounding xml and habe not to touch or copy the booklist itself, furthermore you can maintenance it in one single place and have all changes in any document.

提交回复
热议问题