---
title: "DTD or Schema"
author: "zzy1943"
date: "2010-04-06T10:12:44Z"
tags: ["XML"]
categories: ["编程语言"]
slug: "dtd-or-schema"
draft: false
lastmod: "2010-04-06T10:12:44Z"
id: 634188
url: "https://zzy1943.iteye.com/blog/634188"
---

XML   schemas   provide   the   following   advantages   over   XML   DTDs:  
 1   XML   schemas   support   rich   data   typing,   which   enables   you   to   constrain   element  
  contents   to   specific   values   or   types   of   data.  
 2   XML   schemas   support   XML   namespaces,   which   allow   you   to   combine   different  
  XML   vocabularies   within   a   document.  
 3   XML   schemas   are   expressed   in   XML   syntax,   so   that   you   can   create   and  
  modify   your   XML   schemas   with   the   tools   you   use   to   create   and   modify  
  your   other   XML   documents.  
   
  Advantages   of   XML   DTDs  
  XML   DTDs   offer   the   following   advantages   over   XML   schemas:  
 1   XML   DTDs   use   a   much   simpler   (although   much   less   feature-rich)   syntax.  
 2   XML   DTDs   are   far   less   verbose   than   XML   schemas.   Most   DTD   files   are   far  
  fewer   lines   than   an   equivalent   XML   schema   file.  
 3   At   least   initially,   XML   DTDs   are   more   widely   supported   by   tools   that   create,  
  process,   and   validate   XML   documents   (because   XML   DTDs   have   been   around  
  longer   than   XML   schemas).

XML DTD 和XML Schema 各有所长，如果应用对XML的要求比较低，那就用DTD，如果应用对XML的要求很高，数据很复杂，那么选择Schema会比较好