⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dtd_attributes.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
字号:
<!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>DTD Attributes</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" />

<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>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>


<h1>DTD - Attributes</h1>

<a href="dtd_elements.asp"><img alt="back" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="dtd_el_vs_attr.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>

<hr />
<p class="intro">In a DTD, attributes are declared with an ATTLIST declaration.</p>
<hr />
<h2>Declaring Attributes</h2>
<p>An
attribute declaration has the following syntax:</p>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre>&lt;!ATTLIST element-name attribute-name attribute-type default-value&gt;</pre><pre>DTD example:</pre>
	<pre>&lt;!ATTLIST payment type CDATA &quot;check&quot;&gt;</pre>
	<pre>XML example:</pre>
	<pre>&lt;payment type=&quot;check&quot; /&gt;</pre></td></tr>
</table>

<p>The <b>attribute-type</b> can be one of the following:</p>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr>
<th width="25%" align="left">Type</th>
<th width="75%" align="left">Description</th>
</tr>
<tr>
<td><p>CDATA</p></td>
<td><p>The value is character data</p></td>
</tr>
<tr>
<td><p>(<i>en1</i>|<i>en2</i>|..)</p></td>
<td><p>The value must be one from an enumerated list</p></td>
</tr>
<tr>
<td><p>ID</p></td>
<td><p>The value is a unique id </p></td>
</tr>
<tr>
<td><p>IDREF</p></td>
<td><p>The value is the id of another element</p></td>
</tr>
<tr>
<td><p>IDREFS</p></td>
<td><p>The value is a list of other ids</p></td>
</tr>
<tr>
<td><p>NMTOKEN</p></td>
<td><p>The value is a valid XML name</p></td>
</tr>
<tr>
<td><p>NMTOKENS</p></td>
<td><p>The value is a list of valid XML names</p></td>
</tr>
<tr>
<td><p>ENTITY</p></td>
<td><p>The value is an entity </p></td>
</tr>
<tr>
<td><p>ENTITIES</p></td>
<td><p>The value is a list of entities</p></td>
</tr>
<tr>
<td><p>NOTATION</p></td>
<td><p>The value is a name of a notation</p></td>
</tr>
<tr>
<td><p>xml:</p></td>
<td><p>The value is a predefined xml value</p></td>
</tr>
</table>

<p>The <b>default-value</b> can be one of the following:</p>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr>
<th width="25%" align="left">Value</th>
<th width="75%" align="left">Explanation</th>
</tr>
<tr>
<td><p><i>value</i></p></td>
<td><p>The  default value of the attribute</p></td>
</tr>
<tr>
<td><p>#REQUIRED</p></td>
<td><p>The attribute is required</p></td>
</tr>
<tr>
<td><p>#IMPLIED</p></td>
<td><p>The attribute is not required</p></td>
</tr>
<tr>
<td><p>#FIXED <i>value</i></p></td>
<td><p>The attribute value is fixed</p></td>
</tr>
</table>
<br />

<hr />
<h2>A Default Attribute Value</h2>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre>DTD:
&lt;!ELEMENT square EMPTY&gt;
&lt;!ATTLIST square width CDATA &quot;0&quot;&gt;</pre>
	<pre>Valid XML:
&lt;square width=&quot;100&quot; /&gt;</pre></td></tr>
</table>

<p>In the example above, the &quot;square&quot; element is defined to be an empty element with
a &quot;width&quot; attribute of&nbsp; type CDATA. If no width is specified, it has a default
value of 0.</p>

<hr />
<h2>#REQUIRED</h2>

<h3>Syntax</h3>

<table border="1" width="100%" class="ex" cellspacing="0" id="table1">
<tr><td width="100%"><pre>&lt;!ATTLIST element-name attribute-name attribute-type #REQUIRED&gt;</pre></td></tr>
</table>

<h3>Example</h3>

<table border="1" width="100%" class="ex" cellspacing="0" id="table2">
<tr><td width="100%"><pre>DTD:
&lt;!ATTLIST person number CDATA #REQUIRED&gt;</pre><pre>Valid XML:
&lt;person number=&quot;5677&quot; /&gt;</pre><pre>Invalid XML:
&lt;person /&gt;</pre></td></tr>
</table>

<p>Use the #REQUIRED keyword if you don't have an option for a default value, but
still want to force the attribute to be present.</p>

<hr />
<h2>#IMPLIED</h2>

<h3>Syntax</h3>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre>&lt;!ATTLIST element-name attribute-name attribute-type #IMPLIED&gt;</pre></td></tr>
</table>

<h3>Example</h3>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre>DTD:
&lt;!ATTLIST contact fax CDATA #IMPLIED&gt;</pre><pre>Valid XML:
&lt;contact fax=&quot;555-667788&quot; /&gt;</pre><pre>Valid XML:
&lt;contact /&gt;</pre></td></tr>
</table>

<p>Use the #IMPLIED keyword if you don't want to force the author to include an
attribute, and you don't have an option for a default value.</p>

<hr />
<h2>#FIXED</h2>

<h3>Syntax</h3>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre>&lt;!ATTLIST element-name attribute-name attribute-type #FIXED &quot;value&quot;&gt;</pre></td></tr>
</table>

<h3>Example</h3>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre>DTD:
&lt;!ATTLIST sender company CDATA #FIXED &quot;Microsoft&quot;&gt;</pre><pre>Valid XML:
&lt;sender company=&quot;Microsoft&quot; /&gt;</pre><pre>Invalid XML:
&lt;sender company=&quot;W3Schools&quot; /&gt;</pre></td></tr>
</table>

<p>Use the #FIXED keyword when you want an attribute to have a fixed value
without allowing the author to change it. If an author includes another value,
the XML parser will return an error.</p>

<hr />
<h2>Enumerated Attribute Values</h2>

<h3>Syntax</h3>

<table border="1" width="100%" class="ex" cellspacing="0">
<tr><td width="100%"><pre>&lt;!ATTLIST element-name attribute-name (en1|en2|..) default-value&gt;</pre></td></tr>
</table>

<h3>Example</h3>

<table border="1" width="100%" class="ex" cellspacing="0" id="table3">
<tr><td width="100%">
	<pre>DTD:
&lt;!ATTLIST payment type (check|cash) &quot;cash&quot;&gt;</pre>
	<pre>XML example:
&lt;payment type=&quot;check&quot; /&gt;
or
&lt;payment type=&quot;cash&quot; /&gt;</pre></td></tr>
</table>

<p>Use enumerated attribute values when you want the attribute value to be one of
a fixed set of legal values.</p>

<hr />

<a href="dtd_elements.asp"><img alt="back" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="dtd_el_vs_attr.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -