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

📄 rec-xml-20001006

📁 如何实现安全的xml机制
💻
📖 第 1 页 / 共 5 页
字号:
</table> </div> <div class="div2"> <h3><a name="sec-prolog-dtd"></a>2.8 Prolog
and Document Type Declaration</h3> <p>[<a title="XML Declaration" name="dt-xmldecl">Definition</a>:
XML documents should begin with an <b>XML declaration</b> which specifies
the version of XML being used.] For example, the following is a complete XML
document, <a title="Well-Formed" href="#dt-wellformed">well-formed</a> but
not <a title="Validity" href="#dt-valid">valid</a>:</p> <table class="eg"
width="100%" border="1" cellpadding="5" bgcolor="#99ffff">
<tr>
<td><pre>&lt;?xml version="1.0"?> &lt;greeting>Hello, world!&lt;/greeting> </pre></td>
</tr>
</table> <p>and so is this:</p> <table class="eg" width="100%" border="1"
cellpadding="5" bgcolor="#99ffff">
<tr>
<td><pre>&lt;greeting>Hello, world!&lt;/greeting></pre></td>
</tr>
</table> <p>The version number "<code>1.0</code>" should be used to indicate
conformance to this version of this specification; it is an error for a document
to use the value "<code>1.0</code>" if it does not conform to this version
of this specification. It is the intent of the XML working group to give later
versions of this specification numbers other than "<code>1.0</code>", but
this intent does not indicate a commitment to produce any future versions
of XML, nor if any are produced, to use any particular numbering scheme. Since
future versions are not ruled out, this construct is provided as a means to
allow the possibility of automatic version recognition, should it become necessary.
Processors may signal an error if they receive documents labeled with versions
they do not support.</p> <p>The function of the markup in an XML document
is to describe its storage and logical structure and to associate attribute-value
pairs with its logical structures. XML provides a mechanism, the <a title="Document Type Declaration"
href="#dt-doctype">document type declaration</a>, to define constraints on
the logical structure and to support the use of predefined storage units.
[<a title="Validity" name="dt-valid">Definition</a>: An XML document is <b>valid</b>
if it has an associated document type declaration and if the document complies
with the constraints expressed in it.]</p> <p>The document type declaration
must appear before the first <a title="Element" href="#dt-element">element</a>
in the document.</p> <h5>Prolog</h5><table class="scrap"><tbody>
<tr valign="baseline">
<td><a name="NT-prolog"></a>[22]&nbsp;&nbsp;&nbsp;</td>
<td><code>prolog</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code><a href="#NT-XMLDecl">XMLDecl</a>? <a href="#NT-Misc">Misc</a>*
(<a href="#NT-doctypedecl">doctypedecl</a> <a href="#NT-Misc">Misc</a>*)?</code></td>
</tr>
<tr valign="baseline">
<td><a name="NT-XMLDecl"></a>[23]&nbsp;&nbsp;&nbsp;</td>
<td><code>XMLDecl</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code>'&lt;?xml' <a href="#NT-VersionInfo">VersionInfo</a> <a href="#NT-EncodingDecl">EncodingDecl</a>? <a
href="#NT-SDDecl">SDDecl</a>? <a href="#NT-S">S</a>? '?>'</code></td>
</tr>
<tr valign="baseline">
<td><a name="NT-VersionInfo"></a>[24]&nbsp;&nbsp;&nbsp;</td>
<td><code>VersionInfo</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code><a href="#NT-S">S</a> 'version' <a href="#NT-Eq">Eq</a> ("'" <a
href="#NT-VersionNum">VersionNum</a> "'" | '"' <a href="#NT-VersionNum">VersionNum</a>
'"')<i>/*  */</i></code></td>
</tr>
<tr valign="baseline">
<td><a name="NT-Eq"></a>[25]&nbsp;&nbsp;&nbsp;</td>
<td><code>Eq</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code><a href="#NT-S">S</a>? '=' <a href="#NT-S">S</a>?</code></td>
</tr>
<tr valign="baseline">
<td><a name="NT-VersionNum"></a>[26]&nbsp;&nbsp;&nbsp;</td>
<td><code>VersionNum</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code>([a-zA-Z0-9_.:] | '-')+</code></td>
</tr>
<tr valign="baseline">
<td><a name="NT-Misc"></a>[27]&nbsp;&nbsp;&nbsp;</td>
<td><code>Misc</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code><a href="#NT-Comment">Comment</a> | <a href="#NT-PI">PI</a> | <a
href="#NT-S">S</a></code></td>
</tr>
</tbody></table> <p>[<a title="Document Type Declaration" name="dt-doctype">Definition</a>:
The XML <b>document type declaration</b> contains or points to <a title="markup declaration"
href="#dt-markupdecl">markup declarations</a> that provide a grammar for a
class of documents. This grammar is known as a document type definition, or <b>DTD</b>.
The document type declaration can point to an external subset (a special kind
of <a title="External Entity" href="#dt-extent">external entity</a>) containing
markup declarations, or can contain the markup declarations directly in an
internal subset, or can do both. The DTD for a document consists of both subsets
taken together.]</p> <p>[<a title="markup declaration" name="dt-markupdecl">Definition</a>:
 A <b>markup declaration</b> is an <a title="Element Type declaration" href="#dt-eldecl">element
type declaration</a>, an <a title="Attribute-List Declaration" href="#dt-attdecl">attribute-list
declaration</a>, an <a title="entity declaration" href="#dt-entdecl">entity
declaration</a>, or a <a title="Notation Declaration" href="#dt-notdecl">notation
declaration</a>.] These declarations may be contained in whole or in part
within <a title="Parameter entity" href="#dt-PE">parameter entities</a>, as
described in the well-formedness and validity constraints below. For further
information, see <a href="#sec-physical-struct"><b>4 Physical Structures</b></a>.</p> <h5>Document
Type Definition</h5><table class="scrap"><tbody>
<tr valign="baseline">
<td><a name="NT-doctypedecl"></a>[28]&nbsp;&nbsp;&nbsp;</td>
<td><code>doctypedecl</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code>'&lt;!DOCTYPE' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a>
(<a href="#NT-S">S</a> <a href="#NT-ExternalID">ExternalID</a>)? <a href="#NT-S">S</a>?
('[' (<a href="#NT-markupdecl">markupdecl</a> | <a href="#NT-DeclSep">DeclSep</a>)*
']' <a href="#NT-S">S</a>?)? '>'</code></td>
<td><a href="#vc-roottype">[VC: Root Element Type]</a></td>
</tr>
<tr valign="baseline">
<td></td>
<td></td>
<td></td>
<td></td>
<td><a href="#ExtSubset">[WFC: External Subset]</a></td>
</tr>
<tr valign="baseline">
<td></td>
<td></td>
<td></td>
<td></td>
<td><i>/*  */</i></td>
</tr>
<tr valign="baseline">
<td><a name="NT-DeclSep"></a>[28a]&nbsp;&nbsp;&nbsp;</td>
<td><code>DeclSep</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code><a href="#NT-PEReference">PEReference</a> | <a href="#NT-S">S</a></code></td>
<td><a href="#PE-between-Decls">[WFC: PE Between Declarations]</a></td>
</tr>
<tr valign="baseline">
<td></td>
<td></td>
<td></td>
<td></td>
<td><i>/*  */</i></td>
</tr>
<tr valign="baseline">
<td><a name="NT-markupdecl"></a>[29]&nbsp;&nbsp;&nbsp;</td>
<td><code>markupdecl</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code><a href="#NT-elementdecl">elementdecl</a> | <a href="#NT-AttlistDecl">AttlistDecl</a>
| <a href="#NT-EntityDecl">EntityDecl</a> | <a href="#NT-NotationDecl">NotationDecl</a>
| <a href="#NT-PI">PI</a> | <a href="#NT-Comment">Comment</a> </code></td>
<td><a href="#vc-PEinMarkupDecl">[VC: Proper Declaration/PE Nesting]</a></td>
</tr>
<tr valign="baseline">
<td></td>
<td></td>
<td></td>
<td></td>
<td><a href="#wfc-PEinInternalSubset">[WFC: PEs in Internal Subset]</a></td>
</tr>
</tbody></table> <p>Note that it is possible to construct a well-formed document
containing a <a href="#NT-doctypedecl">doctypedecl</a> that neither points
to an external subset nor contains an internal subset.</p> <p>The markup declarations
may be made up in whole or in part of the <a title="Replacement Text" href="#dt-repltext">replacement
text</a> of <a title="Parameter entity" href="#dt-PE">parameter entities</a>.
The productions later in this specification for individual nonterminals (<a
href="#NT-elementdecl">elementdecl</a>, <a href="#NT-AttlistDecl">AttlistDecl</a>,
and so on) describe the declarations <em>after</em> all the parameter entities
have been <a title="Include" href="#dt-include">included</a>.</p> <p>Parameter
entity references are recognized anywhere in the DTD (internal and external
subsets and external parameter entities), except in literals, processing instructions,
comments, and the contents of ignored conditional sections (see <a href="#sec-condition-sect"><b>3.4
Conditional Sections</b></a>). They are also recognized in entity value literals.
The use of parameter entities in the internal subset is restricted as described
below.</p> <div class="constraint"><p class="prefix"><a name="vc-roottype"></a><b>Validity
constraint: Root Element Type</b></p><p>The <a href="#NT-Name">Name</a> in
the document type declaration must match the element type of the <a title="Root Element"
href="#dt-root">root element</a>.</p> </div> <div class="constraint"><p class="prefix"><a
name="vc-PEinMarkupDecl"></a><b>Validity constraint: Proper Declaration/PE
Nesting</b></p> <p>Parameter-entity <a title="Replacement Text" href="#dt-repltext">replacement
text</a> must be properly nested with markup declarations. That is to say,
if either the first character or the last character of a markup declaration
(<a href="#NT-markupdecl">markupdecl</a> above) is contained in the replacement
text for a <a title="Parameter-entity reference" href="#dt-PERef">parameter-entity
reference</a>, both must be contained in the same replacement text.</p> </div> <div
class="constraint"><p class="prefix"><a name="wfc-PEinInternalSubset"></a><b>Well-formedness
constraint: PEs in Internal Subset</b></p><p>In the internal DTD subset, <a
title="Parameter-entity reference" href="#dt-PERef">parameter-entity references</a>
can occur only where markup declarations can occur, not within markup declarations.
(This does not apply to references that occur in external parameter entities
or to the external subset.)</p> </div> <div class="constraint"><p class="prefix"><a
name="ExtSubset"></a><b>Well-formedness constraint: External Subset</b></p><p>The
external subset, if any, must match the production for <a href="#NT-extSubset">extSubset</a>.</p> </div> <div
class="constraint"><p class="prefix"><a name="PE-between-Decls"></a><b>Well-formedness
constraint: PE Between Declarations</b></p><p>The replacement text of a parameter
entity reference in a <a href="#NT-DeclSep">DeclSep</a> must match the production <a
href="#NT-extSubsetDecl">extSubsetDecl</a>.</p> </div> <p>Like the internal
subset, the external subset and any external parameter entities referenced
in a <a href="#NT-DeclSep">DeclSep</a> must consist of a series of complete
markup declarations of the types allowed by the non-terminal symbol <a href="#NT-markupdecl">markupdecl</a>,
interspersed with white space or <a title="Parameter-entity reference" href="#dt-PERef">parameter-entity
references</a>. However, portions of the contents of the external subset or
of these  external parameter entities may conditionally be ignored by using
the <a title="conditional section" href="#dt-cond-section">conditional section</a>
construct; this is not allowed in the internal subset.</p> <h5>External Subset</h5><table
class="scrap"><tbody>
<tr valign="baseline">
<td><a name="NT-extSubset"></a>[30]&nbsp;&nbsp;&nbsp;</td>
<td><code>extSubset</code></td>
<td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
<td><code><a href="#NT-TextDecl">TextDecl</a>? <a href="#NT-extSubsetDecl">extSubsetDecl</a></code></td>

⌨️ 快捷键说明

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