📄 dtd_intro.asp
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Introduction to DTD</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<link rel="stylesheet" type="text/css" href="../stdtheme.css" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<a name="top"></a>
<table cellpadding="0" cellspacing="0" width="100%" bgcolor="#808080">
<tr>
<td width="234" valign="top">
<a href="../default.htm"><img src="../images/w3default80.jpg" border="0" alt="W3Schools" /></a>
</td>
<th valign="middle" align="left" class="right">
<iframe style="background-color:#808080" src="../banners/bannerframe.asp@adpartner=aspall2" height="90" width="728"
marginwidth="0" marginheight="0" frameborder="0" scrolling="no">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>
<br /></th>
</tr>
</table>
<table style="margin-left:1px" width="800px" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="137" class="content" valign="top"><br />
<a class="left" href="../default.asp" target="_top">
<img src="../images/homeicon.gif" border="0" alt="home" /></a>
<a class="left" href="../default.asp" target="_top">
<b>HOME</b></a>
<br /><br />
<b>DTD Tutorial</b><br />
<a class="left" target="_top" href="default.asp" >DTD HOME</a><br />
<a class="left" target="_top" href="dtd_intro.asp" style='font-weight:bold;'>DTD Introduction</a><br />
<a class="left" target="_top" href="dtd_building.asp" >DTD Building Blocks</a><br />
<a class="left" target="_top" href="dtd_elements.asp" >DTD Elements</a><br />
<a class="left" target="_top" href="dtd_attributes.asp" >DTD Attributes</a><br />
<a class="left" target="_top" href="dtd_el_vs_attr.asp" >DTD Elements vs Attr</a><br />
<a class="left" target="_top" href="dtd_entities.asp" >DTD Entities</a><br />
<a class="left" target="_top" href="dtd_validation.asp" >DTD Validation</a><br />
<a class="left" target="_top" href="dtd_examples.asp" >DTD Examples</a><br />
<a class="left" target="_top" href="dtd_summary.asp" >DTD Summary</a><br />
<br />
<b>Selected Reading</b><br />
<a class="left" target="_top" href="../browsers/browsers_stats.asp">Web Statistics</a><br />
<a class="left" target="_top" href="../site/site_glossary.asp">Web Glossary</a><br />
<a class="left" target="_top" href="../hosting/default.asp">Web Hosting</a><br />
<a class="left" target="_top" href="../quality/default.asp">Web Quality</a><br /><br />
<a class="left" target="_top" href="../forum/default.asp">W3Schools Forum</a><br /><br />
<a class="left" target="_top" href="../about/about_helping.asp">Helping W3Schools</a><br /><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3440800076797949";
/*LeftLinkUnit*/
google_ad_slot = "4854527104";
google_ad_width = 120;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="../../pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
<td valign="top">
<table style="border: 1px solid gray" width="100%" bgcolor="#FFFFFF" border="0" cellpadding="5" cellspacing="0">
<tr>
<td>
<h1>Introduction to DTD</h1>
<a href="default.asp"><img alt="back" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="dtd_building.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<hr />
<p class="intro">A Document Type Definition (DTD) defines the legal building blocks of an XML
document. It defines the document structure with a list of legal elements and
attributes.</p>
<p class="intro">A DTD
can be declared inline inside an XML document, or as an external reference.</p>
<hr />
<h2>Internal DTD Declaration</h2>
<p>If the DTD is declared inside the XML file, it should be wrapped in a DOCTYPE
definition with the following syntax:</p>
<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre><!DOCTYPE root-element [element-declarations]></pre></td></tr>
</table>
<p>Example XML document with an internal DTD:</p>
<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre><?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note></pre></td></tr>
</table>
<br />
<a target="_blank" href="note_in_dtd.xml">Open
the XML file above in your browser</a>, and select view source or view page
source to view the DTD.<p>The DTD above is interpreted like this:<br />
<b><br />
!DOCTYPE note</b> defines that the root element of this document is <b>note.<br />
</b><b>!ELEMENT note</b> defines that the <b>note</b> element contains
four elements: "to,from,heading,body".<br />
<b>!ELEMENT to</b> defines the <b>to</b> element to be of
the type "#PCDATA".<br />
<b>!ELEMENT from</b> defines the <b>from</b> element to be of the
type "#PCDATA".<br />
<b>!ELEMENT heading</b> defines the <b>heading</b> element to be of the
type "#PCDATA".<br />
<b>!ELEMENT body</b> defines the <b>body</b> element to be of the
type "#PCDATA".</p>
<hr />
<h2>External DTD Declaration</h2>
<p>If the DTD is declared in an external file, it should be wrapped in a DOCTYPE
definition with the following syntax:</p>
<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre><!DOCTYPE root-element SYSTEM "filename"></pre></td></tr>
</table>
<p>This is the same XML document as above, but with an external DTD (<a target="_blank" href="note_ex_dtd.xml">Open
it</a>, and select view source):</p>
<table width="100%" border="1" class="ex" cellspacing="0">
<tr>
<td>
<pre><?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note> </pre>
</td>
</tr>
</table>
<p>And this is the file "note.dtd" which contains the DTD:</p>
<table width="100%" border="1" class="ex" cellspacing="0">
<tr>
<td>
<pre><!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)></pre>
</td>
</tr>
</table>
<br />
<hr />
<h2>Why Use a DTD?</h2>
<p>With a DTD, each of your XML files can carry a description of its own format.
</p>
<p>With a DTD,
independent groups of people can agree to use a standard DTD for interchanging
data.
</p>
<p>Your application can use a standard DTD to verify that the data you
receive from the outside world is valid.
</p>
<p>You can also use a DTD to verify your own data.
</p>
<hr />
<a href="default.asp"><img alt="back" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="dtd_building.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<br />
<hr />
<!-- **** SPOTLIGHTS 1 **** -->
<iframe src="../banners/aspallframe.asp" height="110" width="485"
marginwidth="0" marginheight="0" frameborder="0" scrolling="no">
Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>
<hr />
<!-- **** SPOTLIGHTS 2 **** -->
<h2><a target="_blank" href="../../www.altova.com/ref/@s=w3s_spotlight&q=xmlspy">
Altova
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -