1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html lang="EN"><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Extensible Markup Language (XML) 1.0 (Second Edition) -- Review Version</title><style type="text/css">
3code           { font-family: monospace; }
4
5div.constraint,
6div.issue,
7div.note,
8div.notice     { margin-left: 2em; }
9
10dt.label       { display: run-in; }
11
12li p           { margin-top: 0.3em;
13                 margin-bottom: 0.3em; }
14      
15div.diff-add  { background-color: yellow }
16div.diff-del  { text-decoration: line-through }
17div.diff-chg  { background-color: lime }
18div.diff-off  {  }
19
20span.diff-add { background-color: yellow }
21span.diff-del { text-decoration: line-through }
22span.diff-chg { background-color: lime }
23span.diff-off {  }
24
25td.diff-add   { background-color: yellow }
26td.diff-del   { text-decoration: line-through }
27td.diff-chg   { background-color: lime }
28td.diff-off   {  }
29</style><link rel="stylesheet" type="text/css" href="W3C-REC.css"></head><body>
30
31<div class="head"><p><a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" height="48" width="72"></a></p>
32<h1>Extensible Markup Language (XML) 1.0 (Second Edition)</h1>
33<h2>W3C Recommendation 6 October 2000</h2><dl><dt>This version:</dt><dd><a href="http://www.w3.org/TR/2000/REC-xml-20001006">http://www.w3.org/TR/2000/REC-xml-20001006</a>
34(<a href="http://www.w3.org/TR/2000/REC-xml-20001006.html">XHTML</a>, <a href="http://www.w3.org/TR/2000/REC-xml-20001006.xml">XML</a>, <a href="http://www.w3.org/TR/2000/REC-xml-20001006.pdf">PDF</a>, <a href="http://www.w3.org/TR/2000/REC-xml-20001006-review.html">XHTML
35review version</a> with color-coded revision indicators)</dd><dt>Latest version:</dt><dd><a href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</a></dd><dt>Previous versions:</dt><dd><a href="http://www.w3.org/TR/2000/WD-xml-2e-20000814"> http://www.w3.org/TR/2000/WD-xml-2e-20000814</a>
36<a href="http://www.w3.org/TR/1998/REC-xml-19980210"> http://www.w3.org/TR/1998/REC-xml-19980210</a> </dd><dt>Editors:</dt>
37<dd>Tim Bray, Textuality and Netscape <a href="mailto:tbray@textuality.com">&lt;tbray@textuality.com&gt;</a></dd>
38<dd>Jean Paoli, Microsoft <a href="mailto:jeanpa@microsoft.com">&lt;jeanpa@microsoft.com&gt;</a></dd>
39<dd><span class="diff-chg">C. M. Sperberg-McQueen, University
40of Illinois at Chicago and Text Encoding Initiative <a href="mailto:cmsmcq@uic.edu">&lt;cmsmcq@uic.edu&gt;</a></span></dd>
41<dd><span class="diff-add">Eve Maler, Sun Microsystems,
42Inc. <a href="mailto:elm@east.sun.com">&lt;eve.maler@east.sun.com&gt;</a> - Second Edition</span></dd>
43</dl><p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a>���2000�<a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>�</sup> (<a href="http://www.lcs.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>, <a href="http://www.inria.fr/"><abbr lang="fr" title="Institut National de Recherche en Informatique et Automatique">INRIA</abbr></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a>, <a href="http://www.w3.org/Consortium/Legal/copyright-documents-19990405">document use</a>, and <a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">software licensing</a> rules apply.</p></div><hr><div id="abstract">
44<h2><a name="abstract">Abstract</a></h2>
45<p>The Extensible Markup Language (XML) is a subset of SGML that is completely
46described in this document. Its goal is to enable generic SGML to be served,
47received, and processed on the Web in the way that is now possible with HTML.
48XML has been designed for ease of implementation and for interoperability
49with both SGML and HTML.</p>
50</div><div id="status">
51<h2><a name="status">Status of this Document</a></h2>
52<p>This document has been reviewed by W3C Members and other interested parties
53and has been endorsed by the Director as a W3C Recommendation. It is a stable
54document and may be used as reference material or cited as a normative reference
55from another document. W3C's role in making the Recommendation is to draw
56attention to the specification and to promote its widespread deployment. This
57enhances the functionality and interoperability of the Web.</p>
58<p>This document specifies a syntax created by subsetting an existing, widely
59used international text processing standard (Standard Generalized Markup Language,
60ISO 8879:1986(E) as amended and corrected) for use on the World Wide Web.
61It is a product of the W3C XML Activity, details of which can be found at <a href="http://www.w3.org/XML/">http://www.w3.org/XML</a>. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E100">[E100]</a>
62The English version of this specification is the only normative version. However,
63for translations of this document, see <a href="http://www.w3.org/XML/#trans">http://www.w3.org/XML/#trans</a>. </span>A
64list of current W3C Recommendations and other technical documents can be found
65at <a href="http://www.w3.org/TR/">http://www.w3.org/TR</a>.</p>
66<div class="diff-del"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E66">[E66]</a>This
67specification uses the term URI, which is defined by <a href="#Berners-Lee">[Berners-Lee et al.]</a>,
68a work in progress expected to update <a href="#RFC1738">[IETF RFC1738]</a> and <a href="#RFC1808">[IETF RFC1808]</a>.</p></div>
69<div class="diff-add"><p>This second edition is <em>not</em> a new version of XML (first published 10 February 1998);
70it merely incorporates the changes dictated by the first-edition errata (available
71at <a href="http://www.w3.org/XML/xml-19980210-errata">http://www.w3.org/XML/xml-19980210-errata</a>)
72as a convenience to readers. The errata list for this second edition is available
73at <a href="http://www.w3.org/XML/xml-V10-2e-errata">http://www.w3.org/XML/xml-V10-2e-errata</a>.</p></div>
74<p>Please report errors in this document to <a href="mailto:xml-editor@w3.org">xml-editor@w3.org</a><span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E101">[E101]</a>; <a href="http://lists.w3.org/Archives/Public/xml-editor">archives</a> are available</span>.</p>
75<div class="diff-add"><div class="note"><p class="prefix"><b>Note:</b></p>
76<p>C. M. Sperberg-McQueen's affiliation has changed since the publication
77of the first edition. He is now at the World Wide Web Consortium, and can
78be contacted at <a href="mailto:cmsmcq@w3.org">cmsmcq@w3.org</a>.</p>
79</div></div>
80</div>
81<div class="toc">
82<h2><a name="contents">Table of Contents</a></h2><p class="toc">1 <a href="#sec-intro">Introduction</a><br>����1.1 <a href="#sec-origin-goals">Origin and Goals</a><br>����1.2 <a href="#sec-terminology">Terminology</a><br>2 <a href="#sec-documents">Documents</a><br>����2.1 <a href="#sec-well-formed">Well-Formed XML Documents</a><br>����2.2 <a href="#charsets">Characters</a><br>����2.3 <a href="#sec-common-syn">Common Syntactic Constructs</a><br>����2.4 <a href="#syntax">Character Data and Markup</a><br>����2.5 <a href="#sec-comments">Comments</a><br>����2.6 <a href="#sec-pi">Processing Instructions</a><br>����2.7 <a href="#sec-cdata-sect">CDATA Sections</a><br>����2.8 <a href="#sec-prolog-dtd">Prolog and Document Type Declaration</a><br>����2.9 <a href="#sec-rmd">Standalone Document Declaration</a><br>����2.10 <a href="#sec-white-space">White Space Handling</a><br>����2.11 <a href="#sec-line-ends">End-of-Line Handling</a><br>����2.12 <a href="#sec-lang-tag">Language Identification</a><br>3 <a href="#sec-logical-struct">Logical Structures</a><br>����3.1 <a href="#sec-starttags">Start-Tags, End-Tags, and Empty-Element Tags</a><br>����3.2 <a href="#elemdecls">Element Type Declarations</a><br>��������3.2.1 <a href="#sec-element-content">Element Content</a><br>��������3.2.2 <a href="#sec-mixed-content">Mixed Content</a><br>����3.3 <a href="#attdecls">Attribute-List Declarations</a><br>��������3.3.1 <a href="#sec-attribute-types">Attribute Types</a><br>��������3.3.2 <a href="#sec-attr-defaults">Attribute Defaults</a><br>��������3.3.3 <a href="#AVNormalize">Attribute-Value
83Normalization</a><br>����3.4 <a href="#sec-condition-sect">Conditional Sections</a><br>4 <a href="#sec-physical-struct">Physical Structures</a><br>����4.1 <a href="#sec-references">Character and Entity References</a><br>����4.2 <a href="#sec-entity-decl">Entity Declarations</a><br>��������4.2.1 <a href="#sec-internal-ent">Internal Entities</a><br>��������4.2.2 <a href="#sec-external-ent">External Entities</a><br>����4.3 <a href="#TextEntities">Parsed Entities</a><br>��������4.3.1 <a href="#sec-TextDecl">The Text Declaration</a><br>��������4.3.2 <a href="#wf-entities">Well-Formed Parsed Entities</a><br>��������4.3.3 <a href="#charencoding">Character Encoding in Entities</a><br>����4.4 <a href="#entproc">XML Processor Treatment of Entities and References</a><br>��������4.4.1 <a href="#not-recognized">Not Recognized</a><br>��������4.4.2 <a href="#included">Included</a><br>��������4.4.3 <a href="#include-if-valid">Included If Validating</a><br>��������4.4.4 <a href="#forbidden">Forbidden</a><br>��������4.4.5 <a href="#inliteral">Included in Literal</a><br>��������4.4.6 <a href="#notify">Notify</a><br>��������4.4.7 <a href="#bypass">Bypassed</a><br>��������4.4.8 <a href="#as-PE">Included as PE</a><br>����4.5 <a href="#intern-replacement">Construction of Internal Entity Replacement Text</a><br>����4.6 <a href="#sec-predefined-ent">Predefined Entities</a><br>����4.7 <a href="#Notations">Notation Declarations</a><br>����4.8 <a href="#sec-doc-entity">Document Entity</a><br>5 <a href="#sec-conformance">Conformance</a><br>����5.1 <a href="#proc-types">Validating and Non-Validating Processors</a><br>����5.2 <a href="#safe-behavior">Using XML Processors</a><br>6 <a href="#sec-notation">Notation</a><br></p>
84<h3>Appendices</h3><p class="toc">A <a href="#sec-bibliography">References</a><br>����A.1 <a href="#sec-existing-stds">Normative References</a><br>����A.2 <a href="#null">Other References</a><br>B <a href="#CharClasses">Character Classes</a><br>C <a href="#sec-xml-and-sgml">XML and SGML</a> (Non-Normative)<br>D <a href="#sec-entexpand">Expansion of Entity and Character References</a> (Non-Normative)<br>E <a href="#determinism">Deterministic Content Models</a> (Non-Normative)<br>F <a href="#sec-guessing">Autodetection
85of Character Encodings</a> (Non-Normative)<br>����F.1 <a href="#sec-guessing-no-ext-info">Detection Without External Encoding Information</a><br>����F.2 <a href="#sec-guessing-with-ext-info">Priorities in the Presence of External Encoding Information</a><br>G <a href="#sec-xml-wg">W3C XML Working Group</a> (Non-Normative)<br>H <a href="#sec-core-wg">W3C XML Core Group</a> (Non-Normative)<br>I <a href="#id2683713">Production Notes</a> (Non-Normative)<br></p></div><hr><div class="body">
86<div class="div1">
87
88<h2><a name="sec-intro"></a>1 Introduction</h2>
89<p>Extensible Markup Language, abbreviated XML, describes a class of data
90objects called <a title="XML Document" href="#dt-xml-doc">XML documents</a> and partially
91describes the behavior of computer programs which process them. XML is an
92application profile or restricted form of SGML, the Standard Generalized Markup
93Language <a href="#ISO8879">[ISO 8879]</a>. By construction, XML documents are conforming
94SGML documents.</p>
95<p>XML documents are made up of storage units called <a title="Entity" href="#dt-entity">entities</a>,
96which contain either parsed or unparsed data. Parsed data is made up of <a title="Character" href="#dt-character">characters</a>, some of which form <a title="Character Data" href="#dt-chardata">character
97data</a>, and some of which form <a title="Markup" href="#dt-markup">markup</a>.
98Markup encodes a description of the document's storage layout and logical
99structure. XML provides a mechanism to impose constraints on the storage layout
100and logical structure.</p>
101<p>[<a name="dt-xml-proc" title="XML Processor">Definition</a>: A software module called
102an <b>XML processor</b> is used to read XML documents and provide access
103to their content and structure.] [<a name="dt-app" title="Application">Definition</a>: It
104is assumed that an XML processor is doing its work on behalf of another module,
105called the <b>application</b>.] This specification describes
106the required behavior of an XML processor in terms of how it must read XML
107data and the information it must provide to the application.</p>
108<div class="div2">
109
110<h3><a name="sec-origin-goals"></a>1.1 Origin and Goals</h3>
111<p>XML was developed by an XML Working Group (originally known as the SGML
112Editorial Review Board) formed under the auspices of the World Wide Web Consortium
113(W3C) in 1996. It was chaired by Jon Bosak of Sun Microsystems with the active
114participation of an XML Special Interest Group (previously known as the SGML
115Working Group) also organized by the W3C. The membership of the XML Working
116Group is given in an appendix. Dan Connolly served as the WG's contact with
117the W3C.</p>
118<p>The design goals for XML are:</p>
119<ol>
120<li><p>XML shall be straightforwardly usable over the Internet.</p></li>
121<li><p>XML shall support a wide variety of applications.</p></li>
122<li><p>XML shall be compatible with SGML.</p></li>
123<li><p>It shall be easy to write programs which process XML documents.</p>
124</li>
125<li><p>The number of optional features in XML is to be kept to the absolute
126minimum, ideally zero.</p></li>
127<li><p>XML documents should be human-legible and reasonably clear.</p></li>
128<li><p>The XML design should be prepared quickly.</p></li>
129<li><p>The design of XML shall be formal and concise.</p></li>
130<li><p>XML documents shall be easy to create.</p></li>
131<li><p>Terseness in XML markup is of minimal importance.</p></li>
132</ol>
133<p>This specification, together with associated standards (Unicode and ISO/IEC
13410646 for characters, Internet RFC 1766 for language identification tags,
135ISO 639 for language name codes, and ISO 3166 for country name codes), provides
136all the information necessary to understand XML Version 1.0 and
137construct computer programs to process it.</p>
138<p>This version of the XML specification  may be distributed freely, as long as
139all text and legal notices remain intact.</p>
140</div>
141<div class="div2">
142
143<h3><a name="sec-terminology"></a>1.2 Terminology</h3>
144<p>The terminology used to describe XML documents is defined in the body of
145this specification. The terms defined in the following list are used in building
146those definitions and in describing the actions of an XML processor: </p><dl>
147<dt class="label">may</dt>
148<dd>
149<p>[<a name="dt-may" title="May">Definition</a>: Conforming documents and XML processors
150are permitted to but need not behave as described.]</p>
151</dd>
152<dt class="label">must</dt>
153<dd>
154<p>[<a name="dt-must" title="Must">Definition</a>: Conforming documents and XML processors
155are required to behave as described; otherwise they are in error. ]</p>
156</dd>
157<dt class="label">error</dt>
158<dd>
159<p>[<a name="dt-error" title="Error">Definition</a>: A violation of the rules of this specification;
160results are undefined. Conforming software may detect and report an error
161and may recover from it.]</p>
162</dd>
163<dt class="label">fatal error</dt>
164<dd>
165<p>[<a name="dt-fatal" title="Fatal Error">Definition</a>: An error which a conforming <a title="XML Processor" href="#dt-xml-proc">XML processor</a> must detect and report to the application.
166After encountering a fatal error, the processor may continue processing the
167data to search for further errors and may report such errors to the application.
168In order to support correction of errors, the processor may make unprocessed
169data from the document (with intermingled character data and markup) available
170to the application. Once a fatal error is detected, however, the processor
171must not continue normal processing (i.e., it must not continue to pass character
172data and information about the document's logical structure to the application
173in the normal way).]</p>
174</dd>
175<dt class="label">at user option</dt>
176<dd>
177<p>[<a name="dt-atuseroption" title="At user option">Definition</a>: Conforming software
178may or must (depending on the modal verb in the sentence) behave as described;
179if it does, it must provide users a means to enable or disable the behavior
180described.]</p>
181</dd>
182<dt class="label">validity constraint</dt>
183<dd>
184<p>[<a name="dt-vc" title="Validity constraint">Definition</a>: A rule which applies to
185all <a title="Validity" href="#dt-valid">valid</a> XML documents. Violations of validity
186constraints are errors; they must, at user option, be reported by <a title="Validating Processor" href="#dt-validating">validating XML processors</a>.]</p>
187</dd>
188<dt class="label">well-formedness constraint</dt>
189<dd>
190<p>[<a name="dt-wfc" title="Well-formedness constraint">Definition</a>: A rule which applies
191to all <a title="Well-Formed" href="#dt-wellformed">well-formed</a> XML documents. Violations
192of well-formedness constraints are <a title="Fatal Error" href="#dt-fatal">fatal errors</a>.]</p>
193</dd>
194<dt class="label">match</dt>
195<dd>
196<p>[<a name="dt-match" title="match">Definition</a>: (Of strings or names:) Two strings
197or names being compared must be identical. Characters with multiple possible
198representations in ISO/IEC 10646 (e.g. characters with both precomposed and
199base+diacritic forms) match only if they have the same representation in both
200strings. <span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E85">[E85]</a>At
201user option, processors may normalize such characters to some canonical form. </span>No
202case folding is performed. (Of strings and rules in the grammar:) A string
203matches a grammatical production if it belongs to the language generated by
204that production. (Of content and content models:) An element matches its declaration
205when it conforms in the fashion described in the constraint <a href="#elementvalid"><b>[VC: Element Valid]</b></a>.]</p>
206</dd>
207<dt class="label">for compatibility</dt>
208<dd>
209<p>[<a name="dt-compat" title="For Compatibility">Definition</a>: <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E87">[E87]</a>Marks
210a sentence describing</span> a feature of XML included solely to ensure
211that XML remains compatible with SGML.]</p>
212</dd>
213<dt class="label">for interoperability</dt>
214<dd>
215<p>[<a name="dt-interop" title="For interoperability">Definition</a>: <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E87">[E87]</a>Marks
216a sentence describing</span> a non-binding recommendation included to increase
217the chances that XML documents can be processed by the existing installed
218base of SGML processors which predate the WebSGML Adaptations Annex to ISO 8879.]</p>
219</dd>
220</dl><p></p>
221</div>
222</div>
223
224<div class="div1">
225
226<h2><a name="sec-documents"></a>2 Documents</h2>
227<p>[<a name="dt-xml-doc" title="XML Document">Definition</a>:  A data object is an <b>XML
228document</b> if it is <a title="Well-Formed" href="#dt-wellformed">well-formed</a>,
229as defined in this specification. A well-formed XML document may in addition
230be <a title="Validity" href="#dt-valid">valid</a> if it meets certain further constraints.]</p>
231<p>Each XML document has both a logical and a physical structure. Physically,
232the document is composed of units called <a title="Entity" href="#dt-entity">entities</a>.
233An entity may <a title="Entity Reference" href="#dt-entref">refer</a> to other entities to
234cause their inclusion in the document. A document begins in a "root"
235or <a title="Document Entity" href="#dt-docent">document entity</a>. Logically, the document
236is composed of declarations, elements, comments, character references, and
237processing instructions, all of which are indicated in the document by explicit
238markup. The logical and physical structures must nest properly, as described
239in <a href="#wf-entities"><b>4.3.2 Well-Formed Parsed Entities</b></a>.</p>
240<div class="div2">
241
242<h3><a name="sec-well-formed"></a>2.1 Well-Formed XML Documents</h3>
243<p>[<a name="dt-wellformed" title="Well-Formed">Definition</a>:  A textual object is a <b>well-formed</b>
244XML document if:]</p>
245<ol>
246<li><p>Taken as a whole, it matches the production labeled <a href="#NT-document">document</a>.</p>
247</li>
248<li><p>It meets all the well-formedness constraints given in this specification.</p>
249</li>
250<li><p>Each of the <a title="Text Entity" href="#dt-parsedent">parsed entities</a>
251which is referenced directly or indirectly within the document is <a title="Well-Formed" href="#dt-wellformed">well-formed</a>.</p></li>
252</ol>
253
254<h5>Document</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-document"></a>[1]���</td><td><code>document</code></td><td>���::=���</td><td><code><a href="#NT-prolog">prolog</a> <a href="#NT-element">element</a> <a href="#NT-Misc">Misc</a>*</code></td><xsltdebug></xsltdebug></tr></tbody></table>
255<p>Matching the <a href="#NT-document">document</a> production implies that:</p>
256<ol>
257<li><p>It contains one or more <a title="Element" href="#dt-element">elements</a>.</p>
258</li>
259
260<li><p>[<a name="dt-root" title="Root Element">Definition</a>: There is exactly one element,
261called the <b>root</b>, or document element, no part of which appears
262in the <a title="Content" href="#dt-content">content</a> of any other element.] <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E17">[E17]</a>For
263all other elements, if the <a title="Start-Tag" href="#dt-stag">start-tag</a> is in
264the content of another element, the <a title="End Tag" href="#dt-etag">end-tag</a>
265is in the content of the same element.</span> More simply stated, the elements,
266delimited by start- and end-tags, nest properly within each other.</p></li>
267</ol>
268<p>[<a name="dt-parentchild" title="Parent/Child">Definition</a>: As a consequence of this,
269for each non-root element <code>C</code> in the document, there is one other element <code>P</code>
270in the document such that <code>C</code> is in the content of <code>P</code>, but
271is not in the content of any other element that is in the content of <code>P</code>. <code>P</code>
272is referred to as the <b>parent</b> of <code>C</code>, and <code>C</code> as
273a <b>child</b> of <code>P</code>.]</p>
274</div>
275<div class="div2">
276
277<h3><a name="charsets"></a>2.2 Characters</h3>
278<p>[<a name="dt-text" title="Text">Definition</a>: A parsed entity contains <b>text</b>,
279a sequence of <a title="Character" href="#dt-character">characters</a>, which may
280represent markup or character data.] [<a name="dt-character" title="Character">Definition</a>: A <b>character</b>
281is an atomic unit of text as specified by ISO/IEC 10646 <a href="#ISO10646">[ISO/IEC 10646]</a> <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</a>(see
282also <a href="#ISO10646-2000">[ISO/IEC 10646-2000]</a>)</span>. Legal characters are tab, carriage
283return, line feed, and the legal <span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E35">[E35]</a>graphic </span>characters
284of Unicode and ISO/IEC 10646. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E69">[E69]</a>The
285versions of these standards cited in <a href="#sec-existing-stds"><b>A.1 Normative References</b></a> were
286current at the time this document was prepared. New characters may be added
287to these standards by amendments or new editions. Consequently, XML processors
288must accept any character in the range specified for <a href="#NT-Char">Char</a>.</span>
289The use of "compatibility characters", as defined in section
2906.8 of <a href="#Unicode">[Unicode]</a> <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</a>(see
291also D21 in section 3.6 of <a href="#Unicode3">[Unicode3]</a>)</span>, is discouraged.]</p>
292
293<h5>Character Range</h5><table class="scrap" summary="Scrap"><tbody>
294<tr valign="baseline"><td><a name="NT-Char"></a>[2]���</td><td><code>Char</code></td><td>���::=���</td><td><code>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]</code></td><xsltdebug></xsltdebug><td><i>/* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */</i></td></tr>
295</tbody></table>
296<p>The mechanism for encoding character code points into bit patterns may
297vary from entity to entity. All XML processors must accept the UTF-8 and UTF-16
298encodings of 10646; the mechanisms for signaling which of the two is in use,
299or for bringing other encodings into play, are discussed later, in <a href="#charencoding"><b>4.3.3 Character Encoding in Entities</b></a>.</p>
300
301</div>
302<div class="div2">
303
304<h3><a name="sec-common-syn"></a>2.3 Common Syntactic Constructs</h3>
305<p>This section defines some symbols used widely in the grammar.</p>
306<p><a href="#NT-S">S</a> (white space) consists of one or more space (#x20)
307characters, carriage returns, line feeds, or tabs.</p>
308
309<h5>White Space</h5><table class="scrap" summary="Scrap"><tbody>
310<tr valign="baseline"><td><a name="NT-S"></a>[3]���</td><td><code>S</code></td><td>���::=���</td><td><code>(#x20 | #x9 | #xD | #xA)+</code></td><xsltdebug></xsltdebug></tr>
311</tbody></table>
312<p>Characters are classified for convenience as letters, digits, or other
313characters. <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E30">[E30]</a>A
314letter consists of an alphabetic or syllabic base character or an ideographic
315character.</span> Full definitions of the specific characters in each class
316are given in <a href="#CharClasses"><b>B Character Classes</b></a>.</p>
317<p>[<a name="dt-name" title="Name">Definition</a>: A <b>Name</b> is a token beginning
318with a letter or one of a few punctuation characters, and continuing with
319letters, digits, hyphens, underscores, colons, or full stops, together known
320as name characters.] Names beginning with the string "<code>xml</code>",
321or any string which would match <code>(('X'|'x') ('M'|'m') ('L'|'l'))</code>,
322are reserved for standardization in this or future versions of this specification.</p>
323<div class="note"><p class="prefix"><b>Note:</b></p>
324<div class="diff-chg"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E98">[E98]</a>The
325Namespaces in XML Recommendation <a href="#xml-names">[XML Names]</a> assigns a meaning
326to names containing colon characters. Therefore, authors should not use the
327colon in XML names except for namespace purposes, but XML processors must
328accept the colon as a name character.</p></div>
329</div>
330<p>An <a href="#NT-Nmtoken">Nmtoken</a> (name token) is any mixture of name
331characters.</p>
332
333<h5>Names and Tokens</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-NameChar"></a>[4]���</td><td><code>NameChar</code></td><td>���::=���</td><td><code><a href="#NT-Letter">Letter</a> | <a href="#NT-Digit">Digit</a>
334| '.' | '-' | '_' | ':' | <a href="#NT-CombiningChar">CombiningChar</a> | <a href="#NT-Extender">Extender</a></code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-Name"></a>[5]���</td><td><code>Name</code></td><td>���::=���</td><td><code>(<a href="#NT-Letter">Letter</a> | '_' | ':') (<a href="#NT-NameChar">NameChar</a>)*</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-Names"></a>[6]���</td><td><code>Names</code></td><td>���::=���</td><td><code><a href="#NT-Name">Name</a> (<a href="#NT-S">S</a> <a href="#NT-Name">Name</a>)*</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-Nmtoken"></a>[7]���</td><td><code>Nmtoken</code></td><td>���::=���</td><td><code>(<a href="#NT-NameChar">NameChar</a>)+</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-Nmtokens"></a>[8]���</td><td><code>Nmtokens</code></td><td>���::=���</td><td><code><a href="#NT-Nmtoken">Nmtoken</a> (<a href="#NT-S">S</a> <a href="#NT-Nmtoken">Nmtoken</a>)*</code></td><xsltdebug></xsltdebug></tr></tbody></table>
335<p>Literal data is any quoted string not containing the quotation mark used
336as a delimiter for that string. Literals are used for specifying the content
337of internal entities (<a href="#NT-EntityValue">EntityValue</a>), the values
338of attributes (<a href="#NT-AttValue">AttValue</a>), and external identifiers
339(<a href="#NT-SystemLiteral">SystemLiteral</a>). Note that a <a href="#NT-SystemLiteral">SystemLiteral</a>
340can be parsed without scanning for markup.</p>
341
342<h5>Literals</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-EntityValue"></a>[9]���</td><td><code>EntityValue</code></td><td>���::=���</td><td><code>'"' ([^%&amp;"] | <a href="#NT-PEReference">PEReference</a>
343| <a href="#NT-Reference">Reference</a>)* '"' </code></td><xsltdebug></xsltdebug></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>|� "'" ([^%&amp;'] | <a href="#NT-PEReference">PEReference</a> | <a href="#NT-Reference">Reference</a>)* "'"</code></td></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-AttValue"></a>[10]���</td><td><code>AttValue</code></td><td>���::=���</td><td><code>'"' ([^&lt;&amp;"] | <a href="#NT-Reference">Reference</a>)*
344'"' </code></td><xsltdebug></xsltdebug></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>|� "'" ([^&lt;&amp;'] | <a href="#NT-Reference">Reference</a>)*
345"'"</code></td></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-SystemLiteral"></a>[11]���</td><td><code>SystemLiteral</code></td><td>���::=���</td><td><code>('"' [^"]* '"') |�("'" [^']* "'") </code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-PubidLiteral"></a>[12]���</td><td><code>PubidLiteral</code></td><td>���::=���</td><td><code>'"' <a href="#NT-PubidChar">PubidChar</a>* '"'
346| "'" (<a href="#NT-PubidChar">PubidChar</a> - "'")* "'"</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-PubidChar"></a>[13]���</td><td><code>PubidChar</code></td><td>���::=���</td><td><code>#x20 | #xD | #xA |�[a-zA-Z0-9] |�[-'()+,./:=?;!*#@$_%]</code></td><xsltdebug></xsltdebug></tr></tbody></table>
347<div class="diff-add"><div class="note"><p class="prefix"><b>Note:</b></p>
348<p><a href="http://www.w3.org/XML/xml-19980210-errata#E72">[E72]</a>Although
349the <a href="#NT-EntityValue">EntityValue</a> production allows the definition
350of an entity consisting of a single explicit <code>&lt;</code> in the literal
351(e.g., <code>&lt;!ENTITY mylt "&lt;"&gt;</code>), it is strongly advised to avoid
352this practice since any reference to that entity will cause a well-formedness
353error.</p>
354</div></div>
355</div>
356<div class="div2">
357
358<h3><a name="syntax"></a>2.4 Character Data and Markup</h3>
359<p><a title="Text" href="#dt-text">Text</a> consists of intermingled <a title="Character Data" href="#dt-chardata">character data</a> and markup. [<a name="dt-markup" title="Markup">Definition</a>: <b>Markup</b> takes the form of <a title="Start-Tag" href="#dt-stag">start-tags</a>, <a title="End Tag" href="#dt-etag">end-tags</a>, <a title="Empty" href="#dt-empty">empty-element tags</a>, <a title="Entity Reference" href="#dt-entref">entity references</a>, <a title="Character Reference" href="#dt-charref">character
360references</a>, <a title="Comment" href="#dt-comment">comments</a>, <a title="CDATA Section" href="#dt-cdsection">CDATA section</a> delimiters, <a title="Document Type Declaration" href="#dt-doctype">document
361type declarations</a>, <a title="Processing instruction" href="#dt-pi">processing instructions</a>, <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E89">[E89]</a><a href="#NT-XMLDecl">XML declarations</a>, <a href="#NT-TextDecl">text declarations</a>,
362and any white space that is at the top level of the document entity (that
363is, outside the document element and not inside any other markup).</span>]</p>
364<p>[<a name="dt-chardata" title="Character Data">Definition</a>: All text that is not markup
365constitutes the <b>character data</b> of the document.]</p>
366<p>The ampersand character (&amp;) and the left angle bracket (&lt;) may appear
367in their literal form <em>only</em> when used as markup delimiters, or
368within a <a title="Comment" href="#dt-comment">comment</a>, a <a title="Processing instruction" href="#dt-pi">processing
369instruction</a>, or a <a title="CDATA Section" href="#dt-cdsection">CDATA section</a>.<span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E18">[E18]</a>They
370are also legal within the <a title="Literal Entity Value" href="#dt-litentval">literal entity value</a>
371of an internal entity declaration; see <a href="#wf-entities"><b>4.3.2 Well-Formed Parsed Entities</b></a>.</span> 
372If they are needed elsewhere, they must be <a title="escape" href="#dt-escape">escaped</a>
373using either <a title="Character Reference" href="#dt-charref">numeric character references</a>
374or the strings "<code>&amp;amp;</code>" and "<code>&amp;lt;</code>"
375respectively. The right angle bracket (&gt;) may be represented using the string "<code>&amp;gt;</code>",
376and must, <a title="For Compatibility" href="#dt-compat">for compatibility</a>, be escaped
377using "<code>&amp;gt;</code>" or a character reference when it
378appears in the string "<code>]]&gt;</code>" in content, when
379that string is not marking the end of a <a title="CDATA Section" href="#dt-cdsection">CDATA
380section</a>.</p>
381<p>In the content of elements, character data is any string of characters
382which does not contain the start-delimiter of any markup. In a CDATA section,
383character data is any string of characters not including the CDATA-section-close
384delimiter, "<code>]]&gt;</code>".</p>
385<p>To allow attribute values to contain both single and double quotes, the
386apostrophe or single-quote character (') may be represented as "<code>&amp;apos;</code>",
387and the double-quote character (") as "<code>&amp;quot;</code>".</p>
388
389<h5>Character Data</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-CharData"></a>[14]���</td><td><code>CharData</code></td><td>���::=���</td><td><code>[^&lt;&amp;]* - ([^&lt;&amp;]* ']]&gt;' [^&lt;&amp;]*)</code></td><xsltdebug></xsltdebug></tr></tbody></table>
390</div>
391<div class="div2">
392
393<h3><a name="sec-comments"></a>2.5 Comments</h3>
394<p>[<a name="dt-comment" title="Comment">Definition</a>: <b>Comments</b> may appear
395anywhere in a document outside other <a title="Markup" href="#dt-markup">markup</a>;
396in addition, they may appear within the document type declaration at places
397allowed by the grammar. They are not part of the document's <a title="Character Data" href="#dt-chardata">character
398data</a>; an XML processor may, but need not, make it possible for an
399application to retrieve the text of comments. <a title="For Compatibility" href="#dt-compat">For
400compatibility</a>, the string "<code>--</code>" (double-hyphen)
401must not occur within comments.] <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E63">[E63]</a>Parameter
402entity references are not recognized within comments.</span></p>
403
404<h5>Comments</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-Comment"></a>[15]���</td><td><code>Comment</code></td><td>���::=���</td><td><code>'&lt;!--' ((<a href="#NT-Char">Char</a> - '-') | ('-'
405(<a href="#NT-Char">Char</a> - '-')))* '--&gt;'</code></td><xsltdebug></xsltdebug></tr></tbody></table>
406<p>An example of a comment:</p>
407<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!-- declarations for &lt;head&gt; &amp; &lt;body&gt; --&gt;</pre></td></tr></table>
408<div class="diff-add"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E27">[E27]</a>Note
409that the grammar does not allow a comment ending in <code>---&gt;</code>. The
410following example is <em>not</em> well-formed.</p></div>
411<div class="diff-add"><table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td class="diff-add"><pre>&lt;!-- B+, B, or B---&gt;</pre></td></tr></table></div>
412</div>
413<div class="div2">
414
415<h3><a name="sec-pi"></a>2.6 Processing Instructions</h3>
416<p>[<a name="dt-pi" title="Processing instruction">Definition</a>: <b>Processing instructions</b>
417(PIs) allow documents to contain instructions for applications.]</p>
418
419<h5>Processing Instructions</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-PI"></a>[16]���</td><td><code>PI</code></td><td>���::=���</td><td><code>'&lt;?' <a href="#NT-PITarget">PITarget</a> (<a href="#NT-S">S</a>
420(<a href="#NT-Char">Char</a>* - (<a href="#NT-Char">Char</a>* '?&gt;' <a href="#NT-Char">Char</a>*)))? '?&gt;'</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-PITarget"></a>[17]���</td><td><code>PITarget</code></td><td>���::=���</td><td><code><a href="#NT-Name">Name</a> - (('X' | 'x') ('M' |
421'm') ('L' | 'l'))</code></td><xsltdebug></xsltdebug></tr></tbody></table>
422<p>PIs are not part of the document's <a title="Character Data" href="#dt-chardata">character
423data</a>, but must be passed through to the application. The PI begins
424with a target (<a href="#NT-PITarget">PITarget</a>) used to identify the application
425to which the instruction is directed. The target names "<code>XML</code>", "<code>xml</code>",
426and so on are reserved for standardization in this or future versions of this
427specification. The XML <a title="Notation" href="#dt-notation">Notation</a> mechanism
428may be used for formal declaration of PI targets. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E63">[E63]</a>Parameter
429entity references are not recognized within processing instructions.</span></p>
430</div>
431<div class="div2">
432
433<h3><a name="sec-cdata-sect"></a>2.7 CDATA Sections</h3>
434<p>[<a name="dt-cdsection" title="CDATA Section">Definition</a>: <b>CDATA sections</b>
435may occur anywhere character data may occur; they are used to escape blocks
436of text containing characters which would otherwise be recognized as markup.
437CDATA sections begin with the string "<code>&lt;![CDATA[</code>"
438and end with the string "<code>]]&gt;</code>":]</p>
439
440<h5>CDATA Sections</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-CDSect"></a>[18]���</td><td><code>CDSect</code></td><td>���::=���</td><td><code><a href="#NT-CDStart">CDStart</a> <a href="#NT-CData">CData</a> <a href="#NT-CDEnd">CDEnd</a></code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-CDStart"></a>[19]���</td><td><code>CDStart</code></td><td>���::=���</td><td><code>'&lt;![CDATA['</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-CData"></a>[20]���</td><td><code>CData</code></td><td>���::=���</td><td><code>(<a href="#NT-Char">Char</a>* - (<a href="#NT-Char">Char</a>*
441']]&gt;' <a href="#NT-Char">Char</a>*)) </code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-CDEnd"></a>[21]���</td><td><code>CDEnd</code></td><td>���::=���</td><td><code>']]&gt;'</code></td><xsltdebug></xsltdebug></tr></tbody></table>
442<p>Within a CDATA section, only the <a href="#NT-CDEnd">CDEnd</a> string is
443recognized as markup, so that left angle brackets and ampersands may occur
444in their literal form; they need not (and cannot) be escaped using "<code>&amp;lt;</code>"
445and "<code>&amp;amp;</code>". CDATA sections cannot nest.</p>
446<p>An example of a CDATA section, in which "<code>&lt;greeting&gt;</code>"
447and "<code>&lt;/greeting&gt;</code>" are recognized as <a title="Character Data" href="#dt-chardata">character data</a>, not <a title="Markup" href="#dt-markup">markup</a>:</p>
448<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;![CDATA[&lt;greeting&gt;Hello, world!&lt;/greeting&gt;]]&gt; </pre></td></tr></table>
449</div>
450<div class="div2">
451
452<h3><a name="sec-prolog-dtd"></a>2.8 Prolog and Document Type Declaration</h3>
453<p>[<a name="dt-xmldecl" title="XML Declaration">Definition</a>: XML documents <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E107">[E107]</a>should</span>
454begin with an <b>XML declaration</b> which specifies the version of
455XML 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>
456<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;?xml version="1.0"?&gt; &lt;greeting&gt;Hello, world!&lt;/greeting&gt; </pre></td></tr></table>
457<p>and so is this:</p>
458<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;greeting&gt;Hello, world!&lt;/greeting&gt;</pre></td></tr></table>
459<p>The version number "<code>1.0</code>" should be used to indicate
460conformance to this version of this specification; it is an error for a document
461to use the value "<code>1.0</code>" if it does not conform to
462this version of this specification. It is the intent of the XML working group
463to give later versions of this specification numbers other than "<code>1.0</code>",
464but this intent does not indicate a commitment to produce any future versions
465of XML, nor if any are produced, to use any particular numbering scheme. Since
466future versions are not ruled out, this construct is provided as a means to
467allow the possibility of automatic version recognition, should it become necessary.
468Processors may signal an error if they receive documents labeled with versions
469they do not support.</p>
470<p>The function of the markup in an XML document is to describe its storage
471and logical structure and to associate attribute-value pairs with its logical
472structures. XML provides a mechanism, the <a title="Document Type Declaration" href="#dt-doctype">document
473type declaration</a>, to define constraints on the logical structure
474and to support the use of predefined storage units. [<a name="dt-valid" title="Validity">Definition</a>: An XML document is <b>valid</b> if it has an associated
475document type declaration and if the document complies with the constraints
476expressed in it.]</p>
477<p>The document type declaration must appear before the first <a title="Element" href="#dt-element">element</a>
478in the document.</p>
479
480<h5>Prolog</h5><table class="scrap" summary="Scrap"><tbody>
481<tr valign="baseline"><td><a name="NT-prolog"></a>[22]���</td><td><code>prolog</code></td><td>���::=���</td><td><code><a href="#NT-XMLDecl">XMLDecl</a>? <a href="#NT-Misc">Misc</a>*
482(<a href="#NT-doctypedecl">doctypedecl</a> <a href="#NT-Misc">Misc</a>*)?</code></td><xsltdebug></xsltdebug></tr>
483<tr valign="baseline"><td><a name="NT-XMLDecl"></a>[23]���</td><td><code>XMLDecl</code></td><td>���::=���</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>? '?&gt;'</code></td><xsltdebug></xsltdebug></tr>
484<tr valign="baseline"><td class="diff-chg"><a name="NT-VersionInfo"></a>[24]���</td><td class="diff-chg"><code>VersionInfo</code></td><td class="diff-chg">���::=���</td><td class="diff-chg"><code><a href="#NT-S">S</a> 'version' <a href="#NT-Eq">Eq</a>
485("'" <a href="#NT-VersionNum">VersionNum</a> "'" | '"' <a href="#NT-VersionNum">VersionNum</a>
486'"')<i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E15">[E15]</a> */</i></code></td><xsltdebug></xsltdebug></tr>
487<tr valign="baseline"><td><a name="NT-Eq"></a>[25]���</td><td><code>Eq</code></td><td>���::=���</td><td><code><a href="#NT-S">S</a>? '=' <a href="#NT-S">S</a>?</code></td><xsltdebug></xsltdebug></tr>
488<tr valign="baseline"><td><a name="NT-VersionNum"></a>[26]���</td><td><code>VersionNum</code></td><td>���::=���</td><td><code>([a-zA-Z0-9_.:] | '-')+</code></td><xsltdebug></xsltdebug></tr>
489<tr valign="baseline"><td><a name="NT-Misc"></a>[27]���</td><td><code>Misc</code></td><td>���::=���</td><td><code><a href="#NT-Comment">Comment</a> | <a href="#NT-PI">PI</a>
490| <a href="#NT-S">S</a></code></td><xsltdebug></xsltdebug></tr>
491</tbody></table>
492<p>[<a name="dt-doctype" title="Document Type Declaration">Definition</a>: The XML <b>document
493type declaration</b> contains or points to <a title="markup declaration" href="#dt-markupdecl">markup
494declarations</a> that provide a grammar for a class of documents. This
495grammar is known as a document type definition, or <b>DTD</b>. The document
496type declaration can point to an external subset (a special kind of <a title="External Entity" href="#dt-extent">external entity</a>) containing markup declarations,
497or can contain the markup declarations directly in an internal subset, or
498can do both. The DTD for a document consists of both subsets taken together.]</p>
499<p>[<a name="dt-markupdecl" title="markup declaration">Definition</a>:  A <b>markup declaration</b>
500is 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
501declaration</a>, or a <a title="Notation Declaration" href="#dt-notdecl">notation declaration</a>.]
502These declarations may be contained in whole or in part within <a title="Parameter entity" href="#dt-PE">parameter
503entities</a>, as described in the well-formedness and validity constraints
504below. For <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E14">[E14]</a>further</span>
505information, see <a href="#sec-physical-struct"><b>4 Physical Structures</b></a>.</p>
506
507<h5>Document Type Definition</h5><table class="scrap" summary="Scrap"><tbody>
508<tr valign="baseline"><td class="diff-chg"><a name="NT-doctypedecl"></a>[28]���</td><td class="diff-chg"><code>doctypedecl</code></td><td class="diff-chg">���::=���</td><td class="diff-chg"><code>'&lt;!DOCTYPE' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a>
509(<a href="#NT-S">S</a> <a href="#NT-ExternalID">ExternalID</a>)? <a href="#NT-S">S</a>?
510('[' (<a href="#NT-markupdecl">markupdecl</a> | <a href="#NT-DeclSep">DeclSep</a>)*
511']' <a href="#NT-S">S</a>?)? '&gt;'</code></td><xsltdebug></xsltdebug><td><a href="#vc-roottype">[VC: Root Element Type]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td class="diff-add"><a href="#ExtSubset">[WFC: External
512Subset]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td class="diff-chg"><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a> */</i></td></tr>
513<tr valign="baseline"><td class="diff-add"><a name="NT-DeclSep"></a>[28a]���</td><td class="diff-add"><code>DeclSep</code></td><td class="diff-add">���::=���</td><td class="diff-add"><code><a href="#NT-PEReference">PEReference</a> | <a href="#NT-S">S</a></code></td><xsltdebug></xsltdebug><td class="diff-add"><a href="#PE-between-Decls">[WFC: PE
514Between Declarations]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td class="diff-add"><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a> */</i></td></tr>
515<tr valign="baseline"><td><a name="NT-markupdecl"></a>[29]���</td><td><code>markupdecl</code></td><td>���::=���</td><td><code><a href="#NT-elementdecl">elementdecl</a> | <a href="#NT-AttlistDecl">AttlistDecl</a> | <a href="#NT-EntityDecl">EntityDecl</a>
516| <a href="#NT-NotationDecl">NotationDecl</a> | <a href="#NT-PI">PI</a> | <a href="#NT-Comment">Comment</a> </code></td><xsltdebug></xsltdebug><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>
517</tbody></table>
518<div class="diff-add"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E82">[E82]</a>Note
519that it is possible to construct a well-formed document containing a <a href="#NT-doctypedecl">doctypedecl</a>
520that neither points to an external subset nor contains an internal subset.</p></div>
521<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
522entities</a>. The productions later in this specification for individual
523nonterminals (<a href="#NT-elementdecl">elementdecl</a>, <a href="#NT-AttlistDecl">AttlistDecl</a>,
524and so on) describe the declarations <em>after</em> all the parameter
525entities have been <a title="Include" href="#dt-include">included</a>.</p>
526<div class="diff-add"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E75">[E75]</a>Parameter
527entity references are recognized anywhere in the DTD (internal and external
528subsets and external parameter entities), except in literals, processing instructions,
529comments, and the contents of ignored conditional sections (see <a href="#sec-condition-sect"><b>3.4 Conditional Sections</b></a>).
530They are also recognized in entity value literals. The use of parameter entities
531in the internal subset is restricted as described below.</p></div>
532<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>
533in the document type declaration must match the element type of the <a title="Root Element" href="#dt-root">root element</a>.</p>
534</div>
535<div class="constraint"><p class="prefix"><a name="vc-PEinMarkupDecl"></a><b>Validity constraint: Proper Declaration/PE Nesting</b></p>
536<p>Parameter-entity <a title="Replacement Text" href="#dt-repltext">replacement text</a>
537must be properly nested with markup declarations. That is to say, if either
538the first character or the last character of a markup declaration (<a href="#NT-markupdecl">markupdecl</a>
539above) is contained in the replacement text for a <a title="Parameter-entity reference" href="#dt-PERef">parameter-entity
540reference</a>, both must be contained in the same replacement text.</p>
541</div>
542<div class="constraint"><p class="prefix"><a name="wfc-PEinInternalSubset"></a><b>Well-formedness constraint: PEs in Internal Subset</b></p><p>In
543the internal DTD subset, <a title="Parameter-entity reference" href="#dt-PERef">parameter-entity references</a>
544can occur only where markup declarations can occur, not within markup declarations.
545(This does not apply to references that occur in external parameter entities
546or to the external subset.)</p>
547</div>
548<div class="diff-add"><div class="constraint"><p class="prefix"><a name="ExtSubset"></a><b>Well-formedness constraint: <a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a>External
549Subset</b></p><p>The external subset, if any, must match the production for <a href="#NT-extSubset">extSubset</a>.</p>
550</div></div>
551<div class="diff-add"><div class="constraint"><p class="prefix"><a name="PE-between-Decls"></a><b>Well-formedness constraint: <a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a>PE
552Between Declarations</b></p><p>The replacement text of a parameter entity reference
553in a <a href="#NT-DeclSep">DeclSep</a> must match the production <a href="#NT-extSubsetDecl">extSubsetDecl</a>.</p>
554</div></div>
555<p>Like the internal subset, the external subset and any external parameter
556entities <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a>referenced
557in a <a href="#NT-DeclSep">DeclSep</a></span> must consist of a series of
558complete 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
559the contents of the external subset or of <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a>these </span>
560external parameter entities may conditionally be ignored by using the <a title="conditional section" href="#dt-cond-section">conditional section</a> construct; this is not
561allowed in the internal subset.</p>
562
563<h5>External Subset</h5><table class="scrap" summary="Scrap"><tbody>
564<tr valign="baseline"><td><a name="NT-extSubset"></a>[30]���</td><td><code>extSubset</code></td><td>���::=���</td><td><code><a href="#NT-TextDecl">TextDecl</a>? <a href="#NT-extSubsetDecl">extSubsetDecl</a></code></td><xsltdebug></xsltdebug></tr>
565<tr valign="baseline"><td class="diff-chg"><a name="NT-extSubsetDecl"></a>[31]���</td><td class="diff-chg"><code>extSubsetDecl</code></td><td class="diff-chg">���::=���</td><td class="diff-chg"><code>( <a href="#NT-markupdecl">markupdecl</a> | <a href="#NT-conditionalSect">conditionalSect</a> | <a href="#NT-DeclSep">DeclSep</a>)*</code></td><xsltdebug></xsltdebug><td class="diff-chg"><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a> */</i></td></tr>
566</tbody></table>
567<p>The external subset and external parameter entities also differ from the
568internal subset in that in them, <a title="Parameter-entity reference" href="#dt-PERef">parameter-entity
569references</a> are permitted <em>within</em> markup declarations,
570not only <em>between</em> markup declarations.</p>
571<p>An example of an XML document with a document type declaration:</p>
572<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;?xml version="1.0"?&gt; &lt;!DOCTYPE greeting SYSTEM "hello.dtd"&gt; &lt;greeting&gt;Hello, world!&lt;/greeting&gt; </pre></td></tr></table>
573<p>The <a title="System Identifier" href="#dt-sysid">system identifier</a> "<code>hello.dtd</code>"
574gives the <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E78">[E78]</a>address
575(a URI reference)</span> of a DTD for the document.</p>
576<p>The declarations can also be given locally, as in this example:</p>
577<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
578&lt;!DOCTYPE greeting [
579  &lt;!ELEMENT greeting (#PCDATA)&gt;
580]&gt;
581&lt;greeting&gt;Hello, world!&lt;/greeting&gt;</pre></td></tr></table>
582<p>If both the external and internal subsets are used, the internal subset
583is considered to occur before the external subset. 
584This has the effect that entity and attribute-list declarations in the internal
585subset take precedence over those in the external subset.</p>
586</div>
587<div class="div2">
588
589<h3><a name="sec-rmd"></a>2.9 Standalone Document Declaration</h3>
590<p>Markup declarations can affect the content of the document, as passed from
591an <a title="XML Processor" href="#dt-xml-proc">XML processor</a> to an application; examples
592are attribute defaults and entity declarations. The standalone document declaration,
593which may appear as a component of the XML declaration, signals whether or
594not there are such declarations which appear external to the <a title="Document Entity" href="#dt-docent">document
595entity</a><span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E64">[E64]</a>
596or in parameter entities. [<a name="dt-extmkpdecl" title="External Markup Declaration">Definition</a>: An <b>external
597markup declaration</b> is defined as a markup declaration occurring in
598the external subset or in a parameter entity (external or internal, the latter
599being included because non-validating processors are not required to read
600them).]</span></p>
601
602<h5>Standalone Document Declaration</h5><table class="scrap" summary="Scrap"><tbody>
603<tr valign="baseline"><td><a name="NT-SDDecl"></a>[32]���</td><td><code>SDDecl</code></td><td>���::=���</td><td><code> <a href="#NT-S">S</a> 'standalone' <a href="#NT-Eq">Eq</a>
604(("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"')) </code></td><xsltdebug></xsltdebug><td><a href="#vc-check-rmd">[VC: Standalone Document Declaration]</a></td></tr>
605</tbody></table>
606<p>In a standalone document declaration, the value "yes" indicates
607that there are no <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E64">[E64]</a><a title="External Markup Declaration" href="#dt-extmkpdecl">external markup declarations</a></span> which
608affect the information passed from the XML processor to the application. The
609value "no" indicates that there are or may be such external
610markup declarations. Note that the standalone document declaration only denotes
611the presence of external <em>declarations</em>; the presence, in a document,
612of references to external <em>entities</em>, when those entities are internally
613declared, does not change its standalone status.</p>
614<p>If there are no external markup declarations, the standalone document declaration
615has no meaning. If there are external markup declarations but there is no
616standalone document declaration, the value "no" is assumed.</p>
617<p>Any XML document for which <code>standalone="no"</code> holds can be converted
618algorithmically to a standalone document, which may be desirable for some
619network delivery applications.</p>
620<div class="constraint"><p class="prefix"><a name="vc-check-rmd"></a><b>Validity constraint: Standalone Document Declaration</b></p><p>The
621standalone document declaration must have the value "no" if
622any external markup declarations contain declarations of:</p>
623<ul>
624<li><p>attributes with <a title="Attribute Default" href="#dt-default">default</a> values,
625if elements to which these attributes apply appear in the document without
626specifications of values for these attributes, or</p></li>
627<li><p>entities (other than <code>amp</code>,
628<code>lt</code>,
629<code>gt</code>,
630<code>apos</code>,
631<code>quot</code>), if <a title="Entity Reference" href="#dt-entref">references</a>
632to those entities appear in the document, or</p></li>
633<li><p>attributes with values subject to <a href="#AVNormalize"><cite>normalization</cite></a>,
634where the attribute appears in the document with a value which will change
635as a result of normalization, or</p></li>
636<li><p>element types with <a title="Element content" href="#dt-elemcontent">element content</a>,
637if white space occurs directly within any instance of those types.</p></li>
638</ul>
639</div>
640<p>An example XML declaration with a standalone document declaration:</p>
641<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;?xml version="1.0" standalone='yes'?&gt;</pre></td></tr></table>
642</div>
643<div class="div2">
644
645<h3><a name="sec-white-space"></a>2.10 White Space Handling</h3>
646<p>In editing XML documents, it is often convenient to use "white space"
647(spaces, tabs, and blank lines<span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E39">[E39]</a>,
648denoted by the nonterminal <a href="#NT-S">S</a> in this specification</span>)
649to set apart the markup for greater readability. Such white space is typically
650not intended for inclusion in the delivered version of the document. On the
651other hand, "significant" white space that should be preserved
652in the delivered version is common, for example in poetry and source code.</p>
653<p>An <a title="XML Processor" href="#dt-xml-proc">XML processor</a> must always pass
654all characters in a document that are not markup through to the application.
655A <a title="Validating Processor" href="#dt-validating"> validating XML processor</a> must also
656inform the application which of these characters constitute white space appearing
657in <a title="Element content" href="#dt-elemcontent">element content</a>.</p>
658<p>A special <a title="Attribute" href="#dt-attr">attribute</a> named <code>xml:space</code>
659may be attached to an element to signal an intention that in that element,
660white space should be preserved by applications. In valid documents, this
661attribute, like any other, must be <a title="Attribute-List Declaration" href="#dt-attdecl">declared</a>
662if it is used. When declared, it must be given as an <a title="Enumerated Attribute Values" href="#dt-enumerated">enumerated
663type</a> whose <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E81">[E81]</a>values
664are one or both of</span> "default" and "preserve".
665For example:</p>
666<div class="diff-chg"><table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td class="diff-chg"><pre>&lt;!ATTLIST poem  xml:space (default|preserve) 'preserve'&gt;
667
668&lt;!-- <a href="http://www.w3.org/XML/xml-19980210-errata#E81">[E81]</a>--&gt;
669&lt;!ATTLIST pre xml:space (preserve) #FIXED 'preserve'&gt;</pre></td></tr></table></div>
670<p>The value "default" signals that applications' default white-space
671processing modes are acceptable for this element; the value "preserve"
672indicates the intent that applications preserve all the white space. This
673declared intent is considered to apply to all elements within the content
674of the element where it is specified, unless overriden with another instance
675of the <code>xml:space</code> attribute.</p>
676<p>The <a title="Root Element" href="#dt-root">root element</a> of any document is considered
677to have signaled no intentions as regards application space handling, unless
678it provides a value for this attribute or the attribute is declared with a
679default value.</p>
680</div>
681<div class="div2">
682
683<h3><a name="sec-line-ends"></a>2.11 End-of-Line Handling</h3>
684<p>XML <a title="Text Entity" href="#dt-parsedent">parsed entities</a> are often stored
685in computer files which, for editing convenience, are organized into lines.
686These lines are typically separated by some combination of the characters
687carriage-return (#xD) and line-feed (#xA).</p>
688<div class="diff-del"><p>To simplify the tasks of <a title="Application" href="#dt-app">applications</a>,
689wherever an external parsed entity or the literal entity value of an internal
690parsed entity contains either the literal two-character sequence "#xD#xA"
691or a standalone literal #xD, an <a title="XML Processor" href="#dt-xml-proc">XML processor</a>
692must pass to the application the single character #xA. (This behavior can
693conveniently be produced by normalizing all line breaks to #xA on input, before
694parsing.)</p></div>
695<div class="diff-add"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E104">[E104]</a>To
696simplify the tasks of <a title="Application" href="#dt-app">applications</a>, the characters
697passed to an application by the <a title="XML Processor" href="#dt-xml-proc">XML processor</a>
698must be as if the XML processor normalized all line breaks in external parsed
699entities (including the document entity) on input, before parsing, by translating
700both the two-character sequence #xD #xA and any #xD that is not followed by
701#xA to a single #xA character.</p></div>
702</div>
703<div class="div2">
704
705<h3><a name="sec-lang-tag"></a>2.12 Language Identification</h3>
706<p>In document processing, it is often useful to identify the natural or formal
707language in which the content is written. A special <a title="Attribute" href="#dt-attr">attribute</a>
708named <code>xml:lang</code> may be inserted in documents to specify the language
709used in the contents and attribute values of any element in an XML document.
710In valid documents, this attribute, like any other, must be <a title="Attribute-List Declaration" href="#dt-attdecl">declared</a>
711if it is used. <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E73">[E73]</a>The
712values of the attribute are language identifiers as defined by <a href="#RFC1766">[IETF RFC 1766]</a>, <cite>Tags
713for the Identification of Languages</cite>, or its successor on the IETF
714Standards Track.</span></p>
715<div class="diff-add"><div class="note"><p class="prefix"><b>Note:</b></p>
716<p><a href="http://www.w3.org/XML/xml-19980210-errata#E73">[E73]</a><a href="#RFC1766">[IETF RFC 1766]</a> tags are constructed from two-letter language codes as defined
717by <a href="#ISO639">[ISO 639]</a>, from two-letter country codes as defined by <a href="#ISO3166">[ISO 3166]</a>, or from language identifiers registered with the Internet
718Assigned Numbers Authority <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E58">[E58]</a><span class="diff-chg"><a href="#IANA-LANGCODES">[IANA-LANGCODES]</a></span></span>. It is expected that the successor
719to <a href="#RFC1766">[IETF RFC 1766]</a> will introduce three-letter language codes for
720languages not presently covered by <a href="#ISO639">[ISO 639]</a>.</p>
721</div></div>
722<div class="diff-add"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E73">[E73]</a>(Productions
72333 through 38 have been removed.)</p></div>
724<div class="diff-del">
725<h5>Language Identification</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td class="diff-del"><a name="NT-LanguageID"></a>[33]���</td><td class="diff-del"><code>LanguageID</code></td><td class="diff-del">���::=���</td><td class="diff-del"><code><a href="#NT-Langcode">Langcode</a> ('-' <a href="#NT-Subcode">Subcode</a>)*</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td class="diff-del"><a name="NT-Langcode"></a>[34]���</td><td class="diff-del"><code>Langcode</code></td><td class="diff-del">���::=���</td><td class="diff-del"><code><a href="#NT-ISO639Code">ISO639Code</a> | <a href="#NT-IanaCode">IanaCode</a>
726| <a href="#NT-UserCode">UserCode</a></code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td class="diff-del"><a name="NT-ISO639Code"></a>[35]���</td><td class="diff-del"><code>ISO639Code</code></td><td class="diff-del">���::=���</td><td class="diff-del"><code>([a-z] | [A-Z]) ([a-z] | [A-Z])</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td class="diff-del"><a name="NT-IanaCode"></a>[36]���</td><td class="diff-del"><code>IanaCode</code></td><td class="diff-del">���::=���</td><td class="diff-del"><code>('i' | 'I') '-' ([a-z] | [A-Z])+</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td class="diff-del"><a name="NT-UserCode"></a>[37]���</td><td class="diff-del"><code>UserCode</code></td><td class="diff-del">���::=���</td><td class="diff-del"><code>('x' | 'X') '-' ([a-z] | [A-Z])+</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td class="diff-del"><a name="NT-Subcode"></a>[38]���</td><td class="diff-del"><code>Subcode</code></td><td class="diff-del">���::=���</td><td class="diff-del"><code>([a-z] | [A-Z])+</code></td><xsltdebug></xsltdebug></tr></tbody></table></div>
727<div class="diff-del"><p>The <a href="#NT-Langcode">Langcode</a> may be any of the following:</p></div>
728<div class="diff-del"><ul>
729<li><p>a two-letter language code as defined by <a href="#ISO639">[ISO 639]</a>, <cite>Codes
730for the representation of names of languages</cite></p></li>
731<li><p>a language identifier registered with the Internet Assigned Numbers
732Authority <span class="diff-chg"><a href="#IANA-LANGCODES">[IANA-LANGCODES]</a></span>; these begin with the
733prefix "<code>i-</code>" (or "<code>I-</code>")</p>
734</li>
735<li><p>a language identifier assigned by the user, or agreed on between
736parties in private use; these must begin with the prefix "<code>x-</code>"
737or "<code>X-</code>" in order to ensure that they do not conflict
738with names later standardized or registered with IANA</p></li>
739</ul></div>
740<div class="diff-del"><p>There may be any number of <a href="#NT-Subcode">Subcode</a>
741segments; if the first subcode segment exists and the Subcode consists of
742two letters, then it must be a country code from <a href="#ISO3166">[ISO 3166]</a>,
743"Codes for the representation of names of countries." If the first subcode
744consists of more than two letters, it must be a subcode for the language in
745question registered with IANA, unless the <a href="#NT-Langcode">Langcode</a>
746begins with the prefix "<code>x-</code>" or "<code>X-</code>". </p></div>
747<div class="diff-del"><p>It is customary to give the language code in lower case, and
748the country code (if any) in upper case. Note that these values, unlike other
749names in XML documents, are case insensitive.</p></div>
750<p>For example:</p>
751<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;p xml:lang="en"&gt;The quick brown fox jumps over the lazy dog.&lt;/p&gt;
752&lt;p xml:lang="en-GB"&gt;What colour is it?&lt;/p&gt;
753&lt;p xml:lang="en-US"&gt;What color is it?&lt;/p&gt;
754&lt;sp who="Faust" desc='leise' xml:lang="de"&gt;
755  &lt;l&gt;Habe nun, ach! Philosophie,&lt;/l&gt;
756  &lt;l&gt;Juristerei, und Medizin&lt;/l&gt;
757  &lt;l&gt;und leider auch Theologie&lt;/l&gt;
758  &lt;l&gt;durchaus studiert mit hei�em Bem�h'n.&lt;/l&gt;
759&lt;/sp&gt;</pre></td></tr></table>
760
761<p>The intent declared with <code>xml:lang</code> is considered to apply to
762all attributes and content of the element where it is specified, unless overridden
763with an instance of <code>xml:lang</code> on another element within that content.</p>
764
765<p>A simple declaration for <code>xml:lang</code> might take the form</p>
766<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>xml:lang NMTOKEN #IMPLIED</pre></td></tr></table>
767<p>but specific default values may also be given, if appropriate. In a collection
768of French poems for English students, with glosses and notes in English, the <code>xml:lang</code>
769attribute might be declared this way:</p>
770<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ATTLIST poem   xml:lang NMTOKEN 'fr'&gt;
771&lt;!ATTLIST gloss  xml:lang NMTOKEN 'en'&gt;
772&lt;!ATTLIST note   xml:lang NMTOKEN 'en'&gt;</pre></td></tr></table>
773</div>
774</div>
775
776<div class="div1">
777
778<h2><a name="sec-logical-struct"></a>3 Logical Structures</h2>
779<p>[<a name="dt-element" title="Element">Definition</a>: Each <a title="XML Document" href="#dt-xml-doc">XML
780document</a> contains one or more <b>elements</b>, the boundaries
781of which are either delimited by <a title="Start-Tag" href="#dt-stag">start-tags</a>
782and <a title="End Tag" href="#dt-etag">end-tags</a>, or, for <a title="Empty" href="#dt-empty">empty</a>
783elements, by an <a title="empty-element tag" href="#dt-eetag">empty-element tag</a>. Each
784element has a type, identified by name, sometimes called its "generic
785identifier" (GI), and may have a set of attribute specifications.]
786Each attribute specification has a <a title="Attribute Name" href="#dt-attrname">name</a>
787and a <a title="Attribute Value" href="#dt-attrval">value</a>.</p>
788
789<h5>Element</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-element"></a>[39]���</td><td><code>element</code></td><td>���::=���</td><td><code><a href="#NT-EmptyElemTag">EmptyElemTag</a></code></td><xsltdebug></xsltdebug></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| <a href="#NT-STag">STag</a> <a href="#NT-content">content</a> <a href="#NT-ETag">ETag</a></code></td><td><a href="#GIMatch">[WFC: Element Type Match]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#elementvalid">[VC: Element Valid]</a></td></tr></tbody></table>
790<p>This specification does not constrain the semantics, use, or (beyond syntax)
791names of the element types and attributes, except that names beginning with
792a match to <code>(('X'|'x')('M'|'m')('L'|'l'))</code> are reserved for standardization
793in this or future versions of this specification.</p>
794<div class="constraint"><p class="prefix"><a name="GIMatch"></a><b>Well-formedness constraint: Element Type Match</b></p><p>The <a href="#NT-Name">Name</a>
795in an element's end-tag must match the element type in the start-tag.</p>
796</div>
797<div class="constraint"><p class="prefix"><a name="elementvalid"></a><b>Validity constraint: Element Valid</b></p><p>An element is valid
798if there is a declaration matching <a href="#NT-elementdecl">elementdecl</a>
799where the <a href="#NT-Name">Name</a> matches the element type, and one of
800the following holds:</p>
801<ol>
802<li><p>The declaration matches <b>EMPTY</b> and the element has no <a title="Content" href="#dt-content">content</a>.</p></li>
803<li><p>The declaration matches <a href="#NT-children">children</a> and the
804sequence of <a title="Parent/Child" href="#dt-parentchild">child elements</a> belongs
805to the language generated by the regular expression in the content model,
806with optional white space (characters matching the nonterminal <a href="#NT-S">S</a>)
807between <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E59">[E59]</a>the
808start-tag and the first child element, between child elements, or between
809the last child element and the end-tag. Note that a CDATA section containing
810only white space does not match the nonterminal <a href="#NT-S">S</a>, and
811hence cannot appear in these positions.</span></p></li>
812<li><p>The declaration matches <a href="#NT-Mixed">Mixed</a> and the content
813consists of <a title="Character Data" href="#dt-chardata">character data</a> and <a title="Parent/Child" href="#dt-parentchild">child elements</a> whose types match names in the
814content model.</p></li>
815<li><p>The declaration matches <b>ANY</b>, and the types of any <a title="Parent/Child" href="#dt-parentchild">child elements</a> have been declared.</p></li>
816</ol>
817</div>
818<div class="div2">
819
820<h3><a name="sec-starttags"></a>3.1 Start-Tags, End-Tags, and Empty-Element Tags</h3>
821<p>[<a name="dt-stag" title="Start-Tag">Definition</a>: The beginning of every non-empty
822XML element is marked by a <b>start-tag</b>.]</p>
823
824<h5>Start-tag</h5><table class="scrap" summary="Scrap"><tbody>
825<tr valign="baseline"><td><a name="NT-STag"></a>[40]���</td><td><code>STag</code></td><td>���::=���</td><td><code>'&lt;' <a href="#NT-Name">Name</a> (<a href="#NT-S">S</a> <a href="#NT-Attribute">Attribute</a>)* <a href="#NT-S">S</a>? '&gt;'</code></td><xsltdebug></xsltdebug><td><a href="#uniqattspec">[WFC: Unique Att Spec]</a></td></tr>
826<tr valign="baseline"><td><a name="NT-Attribute"></a>[41]���</td><td><code>Attribute</code></td><td>���::=���</td><td><code><a href="#NT-Name">Name</a> <a href="#NT-Eq">Eq</a> <a href="#NT-AttValue">AttValue</a></code></td><xsltdebug></xsltdebug><td><a href="#ValueType">[VC: Attribute Value Type]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#NoExternalRefs">[WFC: No External Entity References]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#CleanAttrVals">[WFC: No &lt; in Attribute Values]</a></td></tr>
827</tbody></table>
828<p>The <a href="#NT-Name">Name</a> in the start- and end-tags gives the element's <b>type</b>. [<a name="dt-attr" title="Attribute">Definition</a>:  The <a href="#NT-Name">Name</a>-<a href="#NT-AttValue">AttValue</a>
829pairs are referred to as the <b>attribute specifications</b> of the
830element], [<a name="dt-attrname" title="Attribute Name">Definition</a>: with the <a href="#NT-Name">Name</a> in each pair referred to as the <b>attribute name</b>]
831and [<a name="dt-attrval" title="Attribute Value">Definition</a>: the content of the <a href="#NT-AttValue">AttValue</a> (the text between the <code>'</code> or <code>"</code>
832delimiters) as the <b>attribute value</b>.]<span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E46">[E46]</a>Note
833that the order of attribute specifications in a start-tag or empty-element
834tag is not significant.</span></p>
835<div class="constraint"><p class="prefix"><a name="uniqattspec"></a><b>Well-formedness constraint: Unique Att Spec</b></p><p>No attribute name
836may appear more than once in the same start-tag or empty-element tag.</p>
837</div>
838<div class="constraint"><p class="prefix"><a name="ValueType"></a><b>Validity constraint: Attribute Value Type</b></p><p>The attribute must
839have been declared; the value must be of the type declared for it. (For attribute
840types, see <a href="#attdecls"><b>3.3 Attribute-List Declarations</b></a>.)</p>
841</div>
842<div class="constraint"><p class="prefix"><a name="NoExternalRefs"></a><b>Well-formedness constraint: No External Entity References</b></p><p>Attribute
843values cannot contain direct or indirect entity references to external entities.</p>
844</div>
845<div class="constraint"><p class="prefix"><a name="CleanAttrVals"></a><b>Well-formedness constraint: No <code>&lt;</code> in Attribute Values</b></p>
846<p>The <a title="Replacement Text" href="#dt-repltext">replacement text</a> of any entity
847referred to directly or indirectly in an attribute value <span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E83">[E83]</a>(other
848than "<code>&amp;lt;</code>") </span>must not contain a <code>&lt;</code>.</p>
849</div>
850<p>An example of a start-tag:</p>
851<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;termdef id="dt-dog" term="dog"&gt;</pre></td></tr></table>
852<p>[<a name="dt-etag" title="End Tag">Definition</a>: The end of every element that begins
853with a start-tag must be marked by an <b>end-tag</b> containing a name
854that echoes the element's type as given in the start-tag:]</p>
855
856<h5>End-tag</h5><table class="scrap" summary="Scrap"><tbody>
857<tr valign="baseline"><td><a name="NT-ETag"></a>[42]���</td><td><code>ETag</code></td><td>���::=���</td><td><code>'&lt;/' <a href="#NT-Name">Name</a> <a href="#NT-S">S</a>?
858'&gt;'</code></td><xsltdebug></xsltdebug></tr>
859</tbody></table>
860<p>An example of an end-tag:</p>
861<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;/termdef&gt;</pre></td></tr></table>
862<p>[<a name="dt-content" title="Content">Definition</a>: The <a title="Text" href="#dt-text">text</a>
863between the start-tag and end-tag is called the element's <b>content</b>:]</p>
864
865<h5>Content of Elements</h5><table class="scrap" summary="Scrap"><tbody>
866<tr valign="baseline"><td class="diff-chg"><a name="NT-content"></a>[43]���</td><td class="diff-chg"><code>content</code></td><td class="diff-chg">���::=���</td><td class="diff-chg"><code><a href="#NT-CharData">CharData</a>? ((<a href="#NT-element">element</a>
867| <a href="#NT-Reference">Reference</a> | <a href="#NT-CDSect">CDSect</a>
868| <a href="#NT-PI">PI</a> | <a href="#NT-Comment">Comment</a>) <a href="#NT-CharData">CharData</a>?)*</code></td><xsltdebug></xsltdebug><td class="diff-chg"><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E71">[E71]</a> */</i></td></tr>
869</tbody></table>
870<p><span class="diff-chg">[<a name="dt-empty" title="Empty">Definition</a>: <a href="http://www.w3.org/XML/xml-19980210-errata#E97">[E97]</a>An element
871with no content is said to be <b>empty</b>.] The representation
872of an empty element is either a start-tag immediately followed by an end-tag,
873or an empty-element tag.</span> [<a name="dt-eetag" title="empty-element tag">Definition</a>: An <b>empty-element
874tag</b> takes a special form:]</p>
875
876<h5>Tags for Empty Elements</h5><table class="scrap" summary="Scrap"><tbody>
877<tr valign="baseline"><td><a name="NT-EmptyElemTag"></a>[44]���</td><td><code>EmptyElemTag</code></td><td>���::=���</td><td><code>'&lt;' <a href="#NT-Name">Name</a> (<a href="#NT-S">S</a> <a href="#NT-Attribute">Attribute</a>)* <a href="#NT-S">S</a>? '/&gt;'</code></td><xsltdebug></xsltdebug><td><a href="#uniqattspec">[WFC: Unique Att Spec]</a></td></tr>
878</tbody></table>
879<p>Empty-element tags may be used for any element which has no content, whether
880or not it is declared using the keyword <b>EMPTY</b>. <a title="For interoperability" href="#dt-interop">For
881interoperability</a>, the empty-element tag <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E45">[E45]</a>should
882be used, and should only be used,</span> for elements which are declared
883EMPTY.</p>
884<p>Examples of empty elements:</p>
885<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;IMG align="left"
886 src="http://www.w3.org/Icons/WWW/w3c_home" /&gt;
887&lt;br&gt;&lt;/br&gt;
888&lt;br/&gt;</pre></td></tr></table>
889</div>
890<div class="div2">
891
892<h3><a name="elemdecls"></a>3.2 Element Type Declarations</h3>
893<p>The <a title="Element" href="#dt-element">element</a> structure of an <a title="XML Document" href="#dt-xml-doc">XML document</a> may, for <a title="Validity" href="#dt-valid">validation</a>
894purposes, be constrained using element type and attribute-list declarations.
895An element type declaration constrains the element's <a title="Content" href="#dt-content">content</a>.</p>
896<p>Element type declarations often constrain which element types can appear
897as <a title="Parent/Child" href="#dt-parentchild">children</a> of the element. At user
898option, an XML processor may issue a warning when a declaration mentions an
899element type for which no declaration is provided, but this is not an error.</p>
900<p>[<a name="dt-eldecl" title="Element Type declaration">Definition</a>: An <b>element
901type declaration</b> takes the form:]</p>
902
903<h5>Element Type Declaration</h5><table class="scrap" summary="Scrap"><tbody>
904<tr valign="baseline"><td><a name="NT-elementdecl"></a>[45]���</td><td><code>elementdecl</code></td><td>���::=���</td><td><code>'&lt;!ELEMENT' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a> <a href="#NT-S">S</a> <a href="#NT-contentspec">contentspec</a> <a href="#NT-S">S</a>?
905'&gt;'</code></td><xsltdebug></xsltdebug><td><a href="#EDUnique">[VC: Unique Element Type Declaration]</a></td></tr>
906<tr valign="baseline"><td><a name="NT-contentspec"></a>[46]���</td><td><code>contentspec</code></td><td>���::=���</td><td><code>'EMPTY' | 'ANY' | <a href="#NT-Mixed">Mixed</a>
907| <a href="#NT-children">children</a> </code></td><xsltdebug></xsltdebug></tr>
908</tbody></table>
909<p>where the <a href="#NT-Name">Name</a> gives the element type being declared.</p>
910<div class="constraint"><p class="prefix"><a name="EDUnique"></a><b>Validity constraint: Unique Element Type Declaration</b></p><p>No element
911type may be declared more than once.</p>
912</div>
913<p>Examples of element type declarations:</p>
914<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ELEMENT br EMPTY&gt;
915&lt;!ELEMENT p (#PCDATA|emph)* &gt;
916&lt;!ELEMENT %name.para; %content.para; &gt;
917&lt;!ELEMENT container ANY&gt;</pre></td></tr></table>
918<div class="div3">
919
920<h4><a name="sec-element-content"></a>3.2.1 Element Content</h4>
921<p>[<a name="dt-elemcontent" title="Element content">Definition</a>: An element <a title="Start-Tag" href="#dt-stag">type</a> has <b>element content</b> when elements
922of that type must contain only <a title="Parent/Child" href="#dt-parentchild">child</a>
923elements (no character data), optionally separated by white space (characters
924matching the nonterminal <a href="#NT-S">S</a>).][<a name="dt-content-model" title="Content model">Definition</a>: In this case, the constraint includes a <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E55">[E55]</a><b>content
925model</b></span>, a simple grammar governing the allowed types of the
926child elements and the order in which they are allowed to appear.]
927The grammar is built on content particles (<a href="#NT-cp">cp</a>s), which
928consist of names, choice lists of content particles, or sequence lists of
929content particles:</p>
930
931<h5>Element-content Models</h5><table class="scrap" summary="Scrap"><tbody>
932<tr valign="baseline"><td><a name="NT-children"></a>[47]���</td><td><code>children</code></td><td>���::=���</td><td><code>(<a href="#NT-choice">choice</a> | <a href="#NT-seq">seq</a>)
933('?' | '*' | '+')?</code></td><xsltdebug></xsltdebug></tr>
934<tr valign="baseline"><td><a name="NT-cp"></a>[48]���</td><td><code>cp</code></td><td>���::=���</td><td><code>(<a href="#NT-Name">Name</a> | <a href="#NT-choice">choice</a>
935| <a href="#NT-seq">seq</a>) ('?' | '*' | '+')?</code></td><xsltdebug></xsltdebug></tr>
936<tr valign="baseline"><td class="diff-chg"><a name="NT-choice"></a>[49]���</td><td class="diff-chg"><code>choice</code></td><td class="diff-chg">���::=���</td><td class="diff-chg"><code>'(' <a href="#NT-S">S</a>? <a href="#NT-cp">cp</a> ( <a href="#NT-S">S</a>? '|' <a href="#NT-S">S</a>? <a href="#NT-cp">cp</a> )+ <a href="#NT-S">S</a>? ')'</code></td><xsltdebug></xsltdebug><td class="diff-chg"><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E50">[E50]</a> */</i></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td class="diff-chg"><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E52">[E52]</a> */</i></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#vc-PEinGroup">[VC: Proper Group/PE Nesting]</a></td></tr>
937<tr valign="baseline"><td class="diff-chg"><a name="NT-seq"></a>[50]���</td><td class="diff-chg"><code>seq</code></td><td class="diff-chg">���::=���</td><td class="diff-chg"><code>'(' <a href="#NT-S">S</a>? <a href="#NT-cp">cp</a> ( <a href="#NT-S">S</a>? ',' <a href="#NT-S">S</a>? <a href="#NT-cp">cp</a> )* <a href="#NT-S">S</a>? ')'</code></td><xsltdebug></xsltdebug><td class="diff-chg"><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E52">[E52]</a> */</i></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#vc-PEinGroup">[VC: Proper Group/PE Nesting]</a></td></tr>
938</tbody></table>
939<p>where each <a href="#NT-Name">Name</a> is the type of an element which
940may appear as a <a title="Parent/Child" href="#dt-parentchild">child</a>. Any content
941particle in a choice list may appear in the <a title="Element content" href="#dt-elemcontent">element
942content</a> at the location where the choice list appears in the grammar;
943content particles occurring in a sequence list must each appear in the <a title="Element content" href="#dt-elemcontent">element content</a> in the order given in the list.
944The optional character following a name or list governs whether the element
945or the content particles in the list may occur one or more (<code>+</code>),
946zero or more (<code>*</code>), or zero or one times (<code>?</code>). The
947absence of such an operator means that the element or content particle must
948appear exactly once. This syntax and meaning are identical to those used in
949the productions in this specification.</p>
950<p>The content of an element matches a content model if and only if it is
951possible to trace out a path through the content model, obeying the sequence,
952choice, and repetition operators and matching each element in the content
953against an element type in the content model. <a title="For Compatibility" href="#dt-compat">For
954compatibility</a>, it is an error if an element in the document can
955match more than one occurrence of an element type in the content model. For
956more information, see <a href="#determinism"><b>E Deterministic Content Models</b></a>.</p>
957
958
959<div class="constraint"><p class="prefix"><a name="vc-PEinGroup"></a><b>Validity constraint: Proper Group/PE Nesting</b></p><p>Parameter-entity <a title="Replacement Text" href="#dt-repltext">replacement text</a> must be properly nested with <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E11">[E11]</a>parenthesized</span>
960groups. That is to say, if either of the opening or closing parentheses in
961a <a href="#NT-choice">choice</a>, <a href="#NT-seq">seq</a>, or <a href="#NT-Mixed">Mixed</a>
962construct is contained in the replacement text for a <a title="Parameter-entity reference" href="#dt-PERef">parameter
963entity</a>, both must be contained in the same replacement text.</p>
964<div class="diff-chg"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E19">[E19]</a><a title="For interoperability" href="#dt-interop">For interoperability</a>, if a parameter-entity reference
965appears in a <a href="#NT-choice">choice</a>, <a href="#NT-seq">seq</a>, or <a href="#NT-Mixed">Mixed</a> construct, its replacement text should contain at
966least one non-blank character, and neither the first nor last non-blank character
967of the replacement text should be a connector (<code>|</code> or <code>,</code>).</p></div>
968</div>
969<p>Examples of element-content models:</p>
970<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ELEMENT spec (front, body, back?)&gt;
971&lt;!ELEMENT div1 (head, (p | list | note)*, div2*)&gt;
972&lt;!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*&gt;</pre></td></tr></table>
973</div>
974<div class="div3">
975
976<h4><a name="sec-mixed-content"></a>3.2.2 Mixed Content</h4>
977<p>[<a name="dt-mixed" title="Mixed Content">Definition</a>: An element <a title="Start-Tag" href="#dt-stag">type</a>
978has <b>mixed content</b> when elements of that type may contain character
979data, optionally interspersed with <a title="Parent/Child" href="#dt-parentchild">child</a>
980elements.] In this case, the types of the child elements may be constrained,
981but not their order or their number of occurrences:</p>
982
983<h5>Mixed-content Declaration</h5><table class="scrap" summary="Scrap"><tbody>
984<tr valign="baseline"><td><a name="NT-Mixed"></a>[51]���</td><td><code>Mixed</code></td><td>���::=���</td><td><code>'(' <a href="#NT-S">S</a>? '#PCDATA' (<a href="#NT-S">S</a>?
985'|' <a href="#NT-S">S</a>? <a href="#NT-Name">Name</a>)* <a href="#NT-S">S</a>?
986')*' </code></td><xsltdebug></xsltdebug></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| '(' <a href="#NT-S">S</a>? '#PCDATA' <a href="#NT-S">S</a>? ')' </code></td><td><a href="#vc-PEinGroup">[VC: Proper Group/PE Nesting]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#vc-MixedChildrenUnique">[VC: No Duplicate Types]</a></td></tr>
987</tbody></table>
988<p>where the <a href="#NT-Name">Name</a>s give the types of elements that
989may appear as children. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E10">[E10]</a>The
990keyword <b>#PCDATA</b> derives historically from the term "parsed
991character data."</span></p>
992<div class="constraint"><p class="prefix"><a name="vc-MixedChildrenUnique"></a><b>Validity constraint: No Duplicate Types</b></p><p>The
993same name must not appear more than once in a single mixed-content declaration.</p>
994</div>
995<p>Examples of mixed content declarations:</p>
996<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ELEMENT p (#PCDATA|a|ul|b|i|em)*&gt;
997&lt;!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* &gt;
998&lt;!ELEMENT b (#PCDATA)&gt;</pre></td></tr></table>
999</div>
1000</div>
1001<div class="div2">
1002
1003<h3><a name="attdecls"></a>3.3 Attribute-List Declarations</h3>
1004<p><a title="Attribute" href="#dt-attr">Attributes</a> are used to associate name-value
1005pairs with <a title="Element" href="#dt-element">elements</a>. Attribute specifications
1006may appear only within <a title="Start-Tag" href="#dt-stag">start-tags</a> and <a title="empty-element tag" href="#dt-eetag">empty-element tags</a>; thus, the productions used to
1007recognize them appear in <a href="#sec-starttags"><b>3.1 Start-Tags, End-Tags, and Empty-Element Tags</b></a>. Attribute-list declarations
1008may be used:</p>
1009<ul>
1010<li><p>To define the set of attributes pertaining to a given element type.</p>
1011</li>
1012<li><p>To establish type constraints for these attributes.</p></li>
1013<li><p>To provide <a title="Attribute Default" href="#dt-default">default values</a> for
1014attributes.</p></li>
1015</ul>
1016<p>[<a name="dt-attdecl" title="Attribute-List Declaration">Definition</a>:  <b>Attribute-list
1017declarations</b> specify the name, data type, and default value (if any)
1018of each attribute associated with a given element type:]</p>
1019
1020<h5>Attribute-list Declaration</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-AttlistDecl"></a>[52]���</td><td><code>AttlistDecl</code></td><td>���::=���</td><td><code>'&lt;!ATTLIST' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a> <a href="#NT-AttDef">AttDef</a>* <a href="#NT-S">S</a>? '&gt;'</code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-AttDef"></a>[53]���</td><td><code>AttDef</code></td><td>���::=���</td><td><code><a href="#NT-S">S</a> <a href="#NT-Name">Name</a> <a href="#NT-S">S</a> <a href="#NT-AttType">AttType</a> <a href="#NT-S">S</a> <a href="#NT-DefaultDecl">DefaultDecl</a></code></td><xsltdebug></xsltdebug></tr></tbody></table>
1021<p>The <a href="#NT-Name">Name</a> in the <a href="#NT-AttlistDecl">AttlistDecl</a>
1022rule is the type of an element. At user option, an XML processor may issue
1023a warning if attributes are declared for an element type not itself declared,
1024but this is not an error. The <a href="#NT-Name">Name</a> in the <a href="#NT-AttDef">AttDef</a>
1025rule is the name of the attribute.</p>
1026<p>When more than one <a href="#NT-AttlistDecl">AttlistDecl</a> is provided
1027for a given element type, the contents of all those provided are merged. When
1028more than one definition is provided for the same attribute of a given element
1029type, the first declaration is binding and later declarations are ignored. <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E9">[E9]</a><a title="For interoperability" href="#dt-interop">For interoperability,</a> writers of DTDs may choose
1030to provide at most one attribute-list declaration for a given element type,
1031at most one attribute definition for a given attribute name in an attribute-list
1032declaration, and at least one attribute definition in each attribute-list
1033declaration.</span> For interoperability, an XML processor may at user option
1034issue a warning when more than one attribute-list declaration is provided
1035for a given element type, or more than one attribute definition is provided
1036for a given attribute, but this is not an error.</p>
1037<div class="div3">
1038
1039<h4><a name="sec-attribute-types"></a>3.3.1 Attribute Types</h4>
1040<p>XML attribute types are of three kinds: a string type, a set of tokenized
1041types, and enumerated types. The string type may take any literal string as
1042a value; the tokenized types have varying lexical and semantic constraints<span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E8">[E8]</a>.
1043The validity constraints noted in the grammar are applied after the attribute
1044value has been normalized as described in <a href="#attdecls"><b>3.3 Attribute-List Declarations</b></a>.</span></p>
1045
1046<h5>Attribute Types</h5><table class="scrap" summary="Scrap"><tbody>
1047<tr valign="baseline"><td><a name="NT-AttType"></a>[54]���</td><td><code>AttType</code></td><td>���::=���</td><td><code><a href="#NT-StringType">StringType</a> | <a href="#NT-TokenizedType">TokenizedType</a>
1048| <a href="#NT-EnumeratedType">EnumeratedType</a> </code></td><xsltdebug></xsltdebug></tr>
1049<tr valign="baseline"><td><a name="NT-StringType"></a>[55]���</td><td><code>StringType</code></td><td>���::=���</td><td><code>'CDATA'</code></td><xsltdebug></xsltdebug></tr>
1050<tr valign="baseline"><td><a name="NT-TokenizedType"></a>[56]���</td><td><code>TokenizedType</code></td><td>���::=���</td><td><code>'ID'</code></td><xsltdebug></xsltdebug><td><a href="#id">[VC: ID]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#one-id-per-el">[VC: One ID per Element Type]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#id-default">[VC: ID Attribute Default]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| 'IDREF'</code></td><td><a href="#idref">[VC: IDREF]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| 'IDREFS'</code></td><td><a href="#idref">[VC: IDREF]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| 'ENTITY'</code></td><td><a href="#entname">[VC: Entity Name]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| 'ENTITIES'</code></td><td><a href="#entname">[VC: Entity Name]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| 'NMTOKEN'</code></td><td><a href="#nmtok">[VC: Name Token]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| 'NMTOKENS'</code></td><td><a href="#nmtok">[VC: Name Token]</a></td></tr>
1051</tbody></table>
1052<div class="constraint"><p class="prefix"><a name="id"></a><b>Validity constraint: ID</b></p><p>Values of type <b>ID</b> must match the <a href="#NT-Name">Name</a> production. A name must not appear more than once
1053in an XML document as a value of this type; i.e., ID values must uniquely
1054identify the elements which bear them.</p>
1055</div>
1056<div class="constraint"><p class="prefix"><a name="one-id-per-el"></a><b>Validity constraint: One ID per Element Type</b></p><p>No element
1057type may have more than one ID attribute specified.</p>
1058</div>
1059<div class="constraint"><p class="prefix"><a name="id-default"></a><b>Validity constraint: ID Attribute Default</b></p><p>An ID attribute
1060must have a declared default of <b>#IMPLIED</b> or <b>#REQUIRED</b>.</p>
1061</div>
1062<div class="constraint"><p class="prefix"><a name="idref"></a><b>Validity constraint: IDREF</b></p><p>Values of type <b>IDREF</b> must
1063match the <a href="#NT-Name">Name</a> production, and values of type <b>IDREFS</b>
1064must match <a href="#NT-Names">Names</a>; each <a href="#NT-Name">Name</a>
1065must match the value of an ID attribute on some element in the XML document;
1066i.e. <b>IDREF</b> values must match the value of some ID attribute.</p>
1067</div>
1068<div class="constraint"><p class="prefix"><a name="entname"></a><b>Validity constraint: Entity Name</b></p><p>Values of type <b>ENTITY</b>
1069must match the <a href="#NT-Name">Name</a> production, values of type <b>ENTITIES</b>
1070must match <a href="#NT-Names">Names</a>; each <a href="#NT-Name">Name</a>
1071must match the name of an <a title="Unparsed Entity" href="#dt-unparsed">unparsed entity</a>
1072declared in the <a title="Document Type Declaration" href="#dt-doctype">DTD</a>.</p>
1073</div>
1074<div class="constraint"><p class="prefix"><a name="nmtok"></a><b>Validity constraint: Name Token</b></p><p>Values of type <b>NMTOKEN</b>
1075must match the <a href="#NT-Nmtoken">Nmtoken</a> production; values of type <b>NMTOKENS</b>
1076must match <a title="" href="#NT-Nmtokens">Nmtokens</a>.</p>
1077</div>
1078
1079<p>[<a name="dt-enumerated" title="Enumerated Attribute Values">Definition</a>: <b>Enumerated attributes</b> can take one of a list of values
1080provided in the declaration]. There are two kinds of enumerated types:</p>
1081
1082<h5>Enumerated Attribute Types</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-EnumeratedType"></a>[57]���</td><td><code>EnumeratedType</code></td><td>���::=���</td><td><code><a href="#NT-NotationType">NotationType</a>
1083| <a href="#NT-Enumeration">Enumeration</a> </code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-NotationType"></a>[58]���</td><td><code>NotationType</code></td><td>���::=���</td><td><code>'NOTATION' <a href="#NT-S">S</a> '(' <a href="#NT-S">S</a>? <a href="#NT-Name">Name</a> (<a href="#NT-S">S</a>? '|' <a href="#NT-S">S</a>? <a href="#NT-Name">Name</a>)* <a href="#NT-S">S</a>? ')' </code></td><xsltdebug></xsltdebug><td><a href="#notatn">[VC: Notation Attributes]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td class="diff-add"><a href="#OneNotationPer">[VC: One
1084Notation Per Element Type]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td class="diff-add"><a href="#NoNotationEmpty">[VC: No
1085Notation on Empty Element]</a></td></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-Enumeration"></a>[59]���</td><td><code>Enumeration</code></td><td>���::=���</td><td><code>'(' <a href="#NT-S">S</a>? <a href="#NT-Nmtoken">Nmtoken</a>
1086(<a href="#NT-S">S</a>? '|' <a href="#NT-S">S</a>? <a href="#NT-Nmtoken">Nmtoken</a>)* <a href="#NT-S">S</a>? ')'</code></td><xsltdebug></xsltdebug><td><a href="#enum">[VC: Enumeration]</a></td></tr></tbody></table>
1087<p>A <b>NOTATION</b> attribute identifies a <a title="Notation" href="#dt-notation">notation</a>,
1088declared in the DTD with associated system and/or public identifiers, to be
1089used in interpreting the element to which the attribute is attached.</p>
1090<div class="constraint"><p class="prefix"><a name="notatn"></a><b>Validity constraint: Notation Attributes</b></p><p>Values of this type
1091must match one of the <a href="#Notations"><cite>notation</cite></a> names
1092included in the declaration; all notation names in the declaration must be
1093declared.</p>
1094</div>
1095<div class="diff-add"><div class="constraint"><p class="prefix"><a name="OneNotationPer"></a><b>Validity constraint: <a href="http://www.w3.org/XML/xml-19980210-errata#E7">[E7]</a>One
1096Notation Per Element Type</b></p><p>No element type may have more than one <b>NOTATION</b>
1097attribute specified.</p>
1098</div></div>
1099<div class="diff-add"><div class="constraint"><p class="prefix"><a name="NoNotationEmpty"></a><b>Validity constraint: <a href="http://www.w3.org/XML/xml-19980210-errata#E68">[E68]</a>No
1100Notation on Empty Element</b></p><p><a title="For Compatibility" href="#dt-compat">For compatibility</a>,
1101an attribute of type <b>NOTATION</b> must not be declared on an element
1102declared <b>EMPTY</b>.</p>
1103</div></div>
1104<div class="constraint"><p class="prefix"><a name="enum"></a><b>Validity constraint: Enumeration</b></p><p>Values of this type must match
1105one of the <a href="#NT-Nmtoken">Nmtoken</a> tokens in the declaration.</p>
1106</div>
1107<p><a title="For interoperability" href="#dt-interop">For interoperability,</a> the same <a href="#NT-Nmtoken">Nmtoken</a> should not occur more than once in the enumerated
1108attribute types of a single element type.</p>
1109</div>
1110<div class="div3">
1111
1112<h4><a name="sec-attr-defaults"></a>3.3.2 Attribute Defaults</h4>
1113<p>An <a title="Attribute-List Declaration" href="#dt-attdecl">attribute declaration</a> provides information
1114on whether the attribute's presence is required, and if not, how an XML processor
1115should react if a declared attribute is absent in a document.</p>
1116
1117<h5>Attribute Defaults</h5><table class="scrap" summary="Scrap"><tbody>
1118<tr valign="baseline"><td><a name="NT-DefaultDecl"></a>[60]���</td><td><code>DefaultDecl</code></td><td>���::=���</td><td><code>'#REQUIRED' |�'#IMPLIED' </code></td><xsltdebug></xsltdebug></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| (('#FIXED' S)? <a href="#NT-AttValue">AttValue</a>)</code></td><td><a href="#RequiredAttr">[VC: Required Attribute]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#defattrvalid">[VC: Attribute Default Legal]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#CleanAttrVals">[WFC: No &lt; in Attribute Values]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#FixedAttr">[VC: Fixed Attribute Default]</a></td></tr>
1119</tbody></table>
1120<p>In an attribute declaration, <b>#REQUIRED</b> means that the attribute
1121must always be provided, <b>#IMPLIED</b> that no default value is provided.  [<a name="dt-default" title="Attribute Default">Definition</a>: If
1122the declaration is neither <b>#REQUIRED</b> nor <b>#IMPLIED</b>, then
1123the <a href="#NT-AttValue">AttValue</a> value contains the declared <b>default</b>
1124value; the <b>#FIXED</b> keyword states that the attribute must always have
1125the default value. If a default value is declared, when an XML processor encounters
1126an omitted attribute, it is to behave as though the attribute were present
1127with the declared default value.]</p>
1128<div class="constraint"><p class="prefix"><a name="RequiredAttr"></a><b>Validity constraint: Required Attribute</b></p><p>If the default
1129declaration is the keyword <b>#REQUIRED</b>, then the attribute must be
1130specified for all elements of the type in the attribute-list declaration.</p>
1131</div>
1132<div class="constraint"><p class="prefix"><a name="defattrvalid"></a><b>Validity constraint: Attribute Default Legal</b></p><p>The declared
1133default value must meet the lexical constraints of the declared attribute
1134type.</p>
1135</div>
1136<div class="constraint"><p class="prefix"><a name="FixedAttr"></a><b>Validity constraint: Fixed Attribute Default</b></p><p>If an attribute
1137has a default value declared with the <b>#FIXED</b> keyword, instances of
1138that attribute must match the default value.</p>
1139</div>
1140<p>Examples of attribute-list declarations:</p>
1141<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ATTLIST termdef
1142          id      ID      #REQUIRED
1143          name    CDATA   #IMPLIED&gt;
1144&lt;!ATTLIST list
1145          type    (bullets|ordered|glossary)  "ordered"&gt;
1146&lt;!ATTLIST form
1147          method  CDATA   #FIXED "POST"&gt;</pre></td></tr></table>
1148</div>
1149<div class="diff-chg"><div class="div3">
1150
1151<h4><a name="AVNormalize"></a>3.3.3 <a href="http://www.w3.org/XML/xml-19980210-errata#E70">[E70]</a>Attribute-Value
1152Normalization</h4>
1153<p>Before the value of an attribute is passed to the application or checked
1154for validity, the XML processor must normalize the attribute value by applying
1155the algorithm below, or by using some other method such that the value passed
1156to the application is the same as that produced by the algorithm.</p>
1157<ol>
1158<li><p>All line breaks must have been normalized on input to #xA as described
1159in <a href="#sec-line-ends"><b>2.11 End-of-Line Handling</b></a>, so the rest of this algorithm operates
1160on text normalized in this way.</p></li>
1161<li><p>Begin with a normalized value consisting of the empty string.</p>
1162</li>
1163<li><p>For each character, entity reference, or character reference in the
1164unnormalized attribute value, beginning with the first and continuing to the
1165last, do the following:</p>
1166<ul>
1167<li><p>For a character reference, append the referenced character to the
1168normalized value.</p></li>
1169<li><p>For an entity reference, recursively apply step 3 of this algorithm
1170to the replacement text of the entity.</p></li>
1171<li><p>For a white space character (#x20, #xD, #xA, #x9), append a space
1172character (#x20) to the normalized value.</p></li>
1173<li><p>For another character, append the character to the normalized value.</p>
1174</li>
1175</ul>
1176</li>
1177</ol>
1178<p>If the attribute type is not CDATA, then the XML processor must further
1179process the normalized attribute value by discarding any leading and trailing
1180space (#x20) characters, and by replacing sequences of space (#x20) characters
1181by a single space (#x20) character.</p>
1182<p>Note that if the unnormalized attribute value contains a character reference
1183to a white space character other than space (#x20), the normalized value contains
1184the referenced character itself (#xD, #xA or #x9). This contrasts with the
1185case where the unnormalized value contains a white space character (not a
1186reference), which is replaced with a space character (#x20) in the normalized
1187value and also contrasts with the case where the unnormalized value contains
1188an entity reference whose replacement text contains a white space character;
1189being recursively processed, the white space character is replaced with a
1190space character (#x20) in the normalized value.</p>
1191<p>All attributes for which no declaration has been read should be treated
1192by a non-validating <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E95">[E95]</a>processor</span>
1193as if declared <b>CDATA</b>.</p>
1194<p>Following are examples of attribute normalization. Given the following
1195declarations:</p>
1196<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ENTITY d "&amp;#xD;"&gt;
1197&lt;!ENTITY a "&amp;#xA;"&gt;
1198&lt;!ENTITY da "&amp;#xD;&amp;#xA;"&gt;</pre></td></tr></table>
1199<p>the attribute specifications in the left column below would be normalized
1200to the character sequences of the middle column if the attribute <code>a</code>
1201is declared <b>NMTOKENS</b> and to those of the right columns if <code>a</code>
1202is declared <b>CDATA</b>.</p>
1203<table border="1" frame="border"><thead><tr><th rowspan="1" colspan="1">Attribute specification</th>
1204<th rowspan="1" colspan="1">a is NMTOKENS</th><th rowspan="1" colspan="1">a is CDATA</th></tr></thead><tbody><tr><td rowspan="1" colspan="1"><table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>a="
1205
1206xyz"</pre></td></tr></table></td><td rowspan="1" colspan="1"><code>x y z</code></td><td rowspan="1" colspan="1"><code>#x20 #x20 x y z</code></td>
1207</tr><tr><td rowspan="1" colspan="1"><table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>a="&amp;d;&amp;d;A&amp;a;&amp;a;B&amp;da;"</pre></td></tr></table></td><td rowspan="1" colspan="1"><code>A
1208#x20 B</code></td><td rowspan="1" colspan="1"><code>#x20 #x20 A #x20 #x20 B #x20 #x20</code></td>
1209</tr><tr><td rowspan="1" colspan="1"><table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>a=
1210"&amp;#xd;&amp;#xd;A&amp;#xa;&amp;#xa;B&amp;#xd;&amp;#xa;"</pre></td></tr></table></td><td rowspan="1" colspan="1"><code>#xD
1211#xD A #xA #xA B #xD #xA</code></td><td rowspan="1" colspan="1"><code>#xD #xD A #xA #xA B #xD #xD</code></td>
1212</tr></tbody></table>
1213<p>Note that the last example is invalid (but well-formed) if <code>a</code>
1214is declared to be of type <b>NMTOKENS</b>.</p>
1215</div></div>
1216</div>
1217<div class="div2">
1218
1219<h3><a name="sec-condition-sect"></a>3.4 Conditional Sections</h3>
1220<p>[<a name="dt-cond-section" title="conditional section">Definition</a>:  <b>Conditional
1221sections</b> are portions of the <a title="Document Type Declaration" href="#dt-doctype">document type
1222declaration external subset</a> which are included in, or excluded from,
1223the logical structure of the DTD based on the keyword which governs them.]</p>
1224
1225<h5>Conditional Section</h5><table class="scrap" summary="Scrap"><tbody>
1226<tr valign="baseline"><td><a name="NT-conditionalSect"></a>[61]���</td><td><code>conditionalSect</code></td><td>���::=���</td><td><code><a href="#NT-includeSect">includeSect</a> | <a href="#NT-ignoreSect">ignoreSect</a> </code></td><xsltdebug></xsltdebug></tr>
1227<tr valign="baseline"><td><a name="NT-includeSect"></a>[62]���</td><td><code>includeSect</code></td><td>���::=���</td><td><code>'&lt;![' S? 'INCLUDE' S? '[' <a href="#NT-extSubsetDecl">extSubsetDecl</a>
1228']]&gt;' </code></td><xsltdebug></xsltdebug><td><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</a> */</i></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td class="diff-add"><a href="#condsec-nesting">[VC: Proper
1229Conditional Section/PE Nesting]</a></td></tr>
1230<tr valign="baseline"><td><a name="NT-ignoreSect"></a>[63]���</td><td><code>ignoreSect</code></td><td>���::=���</td><td><code>'&lt;![' S? 'IGNORE' S? '[' <a href="#NT-ignoreSectContents">ignoreSectContents</a>*
1231']]&gt;'</code></td><xsltdebug></xsltdebug><td><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</a> */</i></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td class="diff-add"><a href="#condsec-nesting">[VC: Proper
1232Conditional Section/PE Nesting]</a></td></tr>
1233<tr valign="baseline"><td><a name="NT-ignoreSectContents"></a>[64]���</td><td><code>ignoreSectContents</code></td><td>���::=���</td><td><code><a href="#NT-Ignore">Ignore</a> ('&lt;![' <a href="#NT-ignoreSectContents">ignoreSectContents</a> ']]&gt;' <a href="#NT-Ignore">Ignore</a>)*</code></td><xsltdebug></xsltdebug></tr>
1234<tr valign="baseline"><td><a name="NT-Ignore"></a>[65]���</td><td><code>Ignore</code></td><td>���::=���</td><td><code><a href="#NT-Char">Char</a>* - (<a href="#NT-Char">Char</a>*
1235('&lt;![' | ']]&gt;') <a href="#NT-Char">Char</a>*) </code></td><xsltdebug></xsltdebug></tr>
1236</tbody></table>
1237<div class="diff-add"><div class="constraint"><p class="prefix"><a name="condsec-nesting"></a><b>Validity constraint: <a href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</a>Proper
1238Conditional Section/PE Nesting</b></p><p>If any of the "<code>&lt;![</code>",
1239"<code>[</code>", or "<code>]]&gt;</code>" of a conditional section is contained
1240in the replacement text for a parameter-entity reference, all of them must
1241be contained in the same replacement text.</p>
1242</div></div>
1243<p>Like the internal and external DTD subsets, a conditional section may contain
1244one or more complete declarations, comments, processing instructions, or nested
1245conditional sections, intermingled with white space.</p>
1246<p>If the keyword of the conditional section is <b>INCLUDE</b>, then the
1247contents of the conditional section are part of the DTD. If the keyword of
1248the conditional section is <b>IGNORE</b>, then the contents of the conditional
1249section are not logically part of the DTD. <span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</a>Note that
1250for reliable parsing, the contents of even ignored conditional sections must
1251be read in order to detect nested conditional sections and ensure that the
1252end of the outermost (ignored) conditional section is properly detected.</span>
1253If a conditional section with a keyword of <b>INCLUDE</b> occurs within
1254a larger conditional section with a keyword of <b>IGNORE</b>, both the outer
1255and the inner conditional sections are ignored.<span class="diff-add"> <a href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</a>The contents
1256of an ignored conditional section are parsed by ignoring all characters after
1257the "<code>[</code>" following the keyword, except conditional section starts
1258"<code>&lt;![</code>" and ends "<code>]]&gt;</code>", until the matching conditional
1259section end is found. Parameter entity references are not recognized in this
1260process.</span></p>
1261<p>If the keyword of the conditional section is a parameter-entity reference,
1262the parameter entity must be replaced by its content before the processor
1263decides whether to include or ignore the conditional section.</p>
1264<p>An example:</p>
1265<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ENTITY % draft 'INCLUDE' &gt;
1266&lt;!ENTITY % final 'IGNORE' &gt;
1267
1268&lt;![%draft;[
1269&lt;!ELEMENT book (comments*, title, body, supplements?)&gt;
1270]]&gt;
1271&lt;![%final;[
1272&lt;!ELEMENT book (title, body, supplements?)&gt;
1273]]&gt;</pre></td></tr></table>
1274</div>
1275
1276</div>
1277
1278<div class="div1">
1279
1280<h2><a name="sec-physical-struct"></a>4 Physical Structures</h2>
1281<p>[<a name="dt-entity" title="Entity">Definition</a>: An XML document may consist of one
1282or many storage units. <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E6">[E6]</a>These
1283are called <b>entities</b>; they all have <b>content</b> and are
1284all (except for the <a title="Document Entity" href="#dt-docent">document entity</a> and
1285the <a title="Document Type Declaration" href="#dt-doctype">external DTD subset</a>) identified by
1286entity <b>name</b></span>.] Each XML document has one entity
1287called the <a title="Document Entity" href="#dt-docent">document entity</a>, which serves
1288as the starting point for the <a title="XML Processor" href="#dt-xml-proc">XML processor</a>
1289and may contain the whole document.</p>
1290<p>Entities may be either parsed or unparsed. [<a name="dt-parsedent" title="Text Entity">Definition</a>: A <b>parsed
1291entity's</b> contents are referred to as its <a title="Replacement Text" href="#dt-repltext">replacement
1292text</a>; this <a title="Text" href="#dt-text">text</a> is considered an
1293integral part of the document.]</p>
1294<p>[<a name="dt-unparsed" title="Unparsed Entity">Definition</a>: An <b>unparsed entity</b>
1295is a resource whose contents may or may not be <a title="Text" href="#dt-text">text</a>,
1296and if text, <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E25">[E25]</a>may
1297be other than</span> XML. Each unparsed entity has an associated <a title="Notation" href="#dt-notation">notation</a>, identified by name. Beyond a requirement
1298that an XML processor make the identifiers for the entity and notation available
1299to the application, XML places no constraints on the contents of unparsed
1300entities.]</p>
1301<p>Parsed entities are invoked by name using entity references; unparsed entities
1302by name, given in the value of <b>ENTITY</b> or <b>ENTITIES</b> attributes.</p>
1303<p>[<a name="gen-entity" title="general entity">Definition</a>: <b>General entities</b>
1304are entities for use within the document content. In this specification, general
1305entities are sometimes referred to with the unqualified term <em>entity</em>
1306when this leads to no ambiguity.] [<a name="dt-PE" title="Parameter entity">Definition</a>: <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E53">[E53]</a><b>Parameter
1307entities</b></span> are parsed entities for use within the DTD.]
1308These two types of entities use different forms of reference and are recognized
1309in different contexts. Furthermore, they occupy different namespaces; a parameter
1310entity and a general entity with the same name are two distinct entities.</p>
1311<div class="div2">
1312
1313<h3><a name="sec-references"></a>4.1 Character and Entity References</h3>
1314<p>[<a name="dt-charref" title="Character Reference">Definition</a>:  A <b>character
1315reference</b> refers to a specific character in the ISO/IEC 10646 character
1316set, for example one not directly accessible from available input devices.]</p>
1317
1318<h5>Character Reference</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-CharRef"></a>[66]���</td><td><code>CharRef</code></td><td>���::=���</td><td><code>'&amp;#' [0-9]+ ';' </code></td><xsltdebug></xsltdebug></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| '&amp;#x' [0-9a-fA-F]+ ';'</code></td><td><a href="#wf-Legalchar">[WFC: Legal Character]</a></td></tr></tbody></table>
1319<div class="constraint"><p class="prefix"><a name="wf-Legalchar"></a><b>Well-formedness constraint: Legal Character</b></p><p>Characters referred
1320to using character references must match the production for <a title="" href="#NT-Char">Char</a>.</p>
1321</div>
1322<p>If the character reference begins with "<code>&amp;#x</code>",
1323the digits and letters up to the terminating <code>;</code> provide a hexadecimal
1324representation of the character's code point in ISO/IEC 10646. If it begins
1325just with "<code>&amp;#</code>", the digits up to the terminating <code>;</code>
1326provide a decimal representation of the character's code point.</p>
1327<p>[<a name="dt-entref" title="Entity Reference">Definition</a>: An <b>entity reference</b>
1328refers to the content of a named entity.] [<a name="dt-GERef" title="General Entity Reference">Definition</a>: References to parsed general entities use
1329ampersand (<code>&amp;</code>) and semicolon (<code>;</code>) as delimiters.] [<a name="dt-PERef" title="Parameter-entity reference">Definition</a>:  <b>Parameter-entity references</b>
1330use percent-sign (<code>%</code>) and semicolon (<code>;</code>) as delimiters.]</p>
1331
1332<h5>Entity Reference</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-Reference"></a>[67]���</td><td><code>Reference</code></td><td>���::=���</td><td><code><a href="#NT-EntityRef">EntityRef</a> | <a href="#NT-CharRef">CharRef</a></code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-EntityRef"></a>[68]���</td><td><code>EntityRef</code></td><td>���::=���</td><td><code>'&amp;' <a href="#NT-Name">Name</a> ';'</code></td><xsltdebug></xsltdebug><td><a href="#wf-entdeclared">[WFC: Entity Declared]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#vc-entdeclared">[VC: Entity Declared]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#textent">[WFC: Parsed Entity]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#norecursion">[WFC: No Recursion]</a></td></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-PEReference"></a>[69]���</td><td><code>PEReference</code></td><td>���::=���</td><td><code>'%' <a href="#NT-Name">Name</a> ';'</code></td><xsltdebug></xsltdebug><td><a href="#vc-entdeclared">[VC: Entity Declared]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#norecursion">[WFC: No Recursion]</a></td></tr><tr valign="baseline"><td></td><td></td><td></td><td></td><td><a href="#indtd">[WFC: In DTD]</a></td></tr></tbody></table>
1333<div class="constraint"><p class="prefix"><a name="wf-entdeclared"></a><b>Well-formedness constraint: Entity Declared</b></p><p>In a document
1334without any DTD, a document with only an internal DTD subset which contains
1335no parameter entity references, or a document with "<code>standalone='yes'</code>", <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E34">[E34]</a>for
1336an entity reference that does not occur within the external subset or a parameter
1337entity, the <a href="#NT-Name">Name</a> given in the entity reference must <a title="match" href="#dt-match">match</a> that in an <a href="#sec-entity-decl"><cite>entity
1338declaration</cite></a> that does not occur within the external subset or a
1339parameter entity</span>, except that well-formed documents need not declare
1340any of the following entities: <code>amp</code>,
1341<code>lt</code>,
1342<code>gt</code>,
1343<code>apos</code>,
1344<code>quot</code>. <span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E29">[E29]</a>The declaration
1345of a parameter entity must precede any reference to it. Similarly, </span>The
1346declaration of a general entity must precede any reference to it which appears
1347in a default value in an attribute-list declaration.</p>
1348<p>Note that if entities are declared in the external subset or in external
1349parameter entities, a non-validating processor is <a href="#include-if-valid"><cite>not
1350obligated to</cite></a> read and process their declarations; for such documents,
1351the rule that an entity must be declared is a well-formedness constraint only
1352if <a href="#sec-rmd"><cite>standalone='yes'</cite></a>.</p>
1353</div>
1354<div class="constraint"><p class="prefix"><a name="vc-entdeclared"></a><b>Validity constraint: Entity Declared</b></p><p>In a document with
1355an external subset or external parameter entities with "<code>standalone='no'</code>",
1356the <a href="#NT-Name">Name</a> given in the entity reference must <a title="match" href="#dt-match">match</a> that in an <a href="#sec-entity-decl"><cite>entity
1357declaration</cite></a>. For interoperability, valid documents should declare
1358the entities <code>amp</code>,
1359<code>lt</code>,
1360<code>gt</code>,
1361<code>apos</code>,
1362<code>quot</code>, in the form specified in <a href="#sec-predefined-ent"><b>4.6 Predefined Entities</b></a>.
1363The declaration of a parameter entity must precede any reference to it. Similarly,
1364the declaration of a general entity must precede any <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E92">[E92]</a>attribute-list
1365declaration containing a default value with a direct or indirect reference
1366to that general entity.</span></p>
1367</div>
1368
1369<div class="constraint"><p class="prefix"><a name="textent"></a><b>Well-formedness constraint: Parsed Entity</b></p><p>An entity reference must
1370not contain the name of an <a title="Unparsed Entity" href="#dt-unparsed">unparsed entity</a>.
1371Unparsed entities may be referred to only in <a title="Attribute Value" href="#dt-attrval">attribute
1372values</a> declared to be of type <b>ENTITY</b> or <b>ENTITIES</b>.</p>
1373</div>
1374<div class="constraint"><p class="prefix"><a name="norecursion"></a><b>Well-formedness constraint: No Recursion</b></p><p>A parsed entity must
1375not contain a recursive reference to itself, either directly or indirectly.</p>
1376</div>
1377<div class="constraint"><p class="prefix"><a name="indtd"></a><b>Well-formedness constraint: In DTD</b></p><p>Parameter-entity references may
1378only appear in the <a title="Document Type Declaration" href="#dt-doctype">DTD</a>.</p>
1379</div>
1380<p>Examples of character and entity references:</p>
1381<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>Type &lt;key&gt;less-than&lt;/key&gt; (&amp;#x3C;) to save options.
1382This document was prepared on &amp;docdate; and
1383is classified &amp;security-level;.</pre></td></tr></table>
1384<p>Example of a parameter-entity reference:</p>
1385<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!-- declare the parameter entity "ISOLat2"... --&gt;
1386&lt;!ENTITY % ISOLat2
1387         SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" &gt;
1388&lt;!-- ... now reference it. --&gt;
1389%ISOLat2;</pre></td></tr></table>
1390</div>
1391<div class="div2">
1392
1393<h3><a name="sec-entity-decl"></a>4.2 Entity Declarations</h3>
1394<p>[<a name="dt-entdecl" title="entity declaration">Definition</a>:  Entities are declared
1395thus:]</p>
1396
1397<h5>Entity Declaration</h5><table class="scrap" summary="Scrap"><tbody>
1398<tr valign="baseline"><td><a name="NT-EntityDecl"></a>[70]���</td><td><code>EntityDecl</code></td><td>���::=���</td><td><code><a href="#NT-GEDecl">GEDecl</a> | <a href="#NT-PEDecl">PEDecl</a></code></td><xsltdebug></xsltdebug></tr>
1399<tr valign="baseline"><td><a name="NT-GEDecl"></a>[71]���</td><td><code>GEDecl</code></td><td>���::=���</td><td><code>'&lt;!ENTITY' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a> <a href="#NT-S">S</a> <a href="#NT-EntityDef">EntityDef</a> <a href="#NT-S">S</a>?
1400'&gt;'</code></td><xsltdebug></xsltdebug></tr>
1401<tr valign="baseline"><td><a name="NT-PEDecl"></a>[72]���</td><td><code>PEDecl</code></td><td>���::=���</td><td><code>'&lt;!ENTITY' <a href="#NT-S">S</a> '%' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a> <a href="#NT-S">S</a> <a href="#NT-PEDef">PEDef</a> <a href="#NT-S">S</a>? '&gt;'</code></td><xsltdebug></xsltdebug></tr>
1402<tr valign="baseline"><td><a name="NT-EntityDef"></a>[73]���</td><td><code>EntityDef</code></td><td>���::=���</td><td><code><a href="#NT-EntityValue">EntityValue</a> | (<a href="#NT-ExternalID">ExternalID</a> <a href="#NT-NDataDecl">NDataDecl</a>?)</code></td><xsltdebug></xsltdebug></tr>
1403
1404<tr valign="baseline"><td><a name="NT-PEDef"></a>[74]���</td><td><code>PEDef</code></td><td>���::=���</td><td><code><a href="#NT-EntityValue">EntityValue</a> | <a href="#NT-ExternalID">ExternalID</a></code></td><xsltdebug></xsltdebug></tr>
1405</tbody></table>
1406<p>The <a href="#NT-Name">Name</a> identifies the entity in an <a title="Entity Reference" href="#dt-entref">entity
1407reference</a> or, in the case of an unparsed entity, in the value of
1408an <b>ENTITY</b> or <b>ENTITIES</b> attribute. If the same entity is declared
1409more than once, the first declaration encountered is binding; at user option,
1410an XML processor may issue a warning if entities are declared multiple times.</p>
1411<div class="div3">
1412
1413<h4><a name="sec-internal-ent"></a>4.2.1 Internal Entities</h4>
1414<p>[<a name="dt-internent" title="Internal Entity Replacement Text">Definition</a>: If the
1415entity definition is an <a href="#NT-EntityValue">EntityValue</a>, the defined
1416entity is called an <b>internal entity</b>. There is no separate physical
1417storage object, and the content of the entity is given in the declaration.]
1418Note that some processing of entity and character references in the <a title="Literal Entity Value" href="#dt-litentval">literal entity value</a> may be required to produce
1419the correct <a title="Replacement Text" href="#dt-repltext">replacement text</a>: see <a href="#intern-replacement"><b>4.5 Construction of Internal Entity Replacement Text</b></a>.</p>
1420<p>An internal entity is a <a title="Text Entity" href="#dt-parsedent">parsed entity</a>.</p>
1421<p>Example of an internal entity declaration:</p>
1422<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ENTITY Pub-Status "This is a pre-release of the
1423 specification."&gt;</pre></td></tr></table>
1424</div>
1425<div class="div3">
1426
1427<h4><a name="sec-external-ent"></a>4.2.2 External Entities</h4>
1428<p>[<a name="dt-extent" title="External Entity">Definition</a>: If the entity is not internal,
1429it is an <b>external entity</b>, declared as follows:]</p>
1430
1431<h5>External Entity Declaration</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-ExternalID"></a>[75]���</td><td><code>ExternalID</code></td><td>���::=���</td><td><code>'SYSTEM' <a href="#NT-S">S</a> <a href="#NT-SystemLiteral">SystemLiteral</a></code></td><xsltdebug></xsltdebug></tr><tr valign="baseline"><td></td><td></td><td></td><td><code>| 'PUBLIC' <a href="#NT-S">S</a> <a href="#NT-PubidLiteral">PubidLiteral</a> <a href="#NT-S">S</a> <a href="#NT-SystemLiteral">SystemLiteral</a> </code></td></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-NDataDecl"></a>[76]���</td><td><code>NDataDecl</code></td><td>���::=���</td><td><code><a href="#NT-S">S</a> 'NDATA' <a href="#NT-S">S</a> <a href="#NT-Name">Name</a></code></td><xsltdebug></xsltdebug><td><a href="#not-declared">[VC: Notation Declared]</a></td></tr></tbody></table>
1432<p>If the <a href="#NT-NDataDecl">NDataDecl</a> is present, this is a general <a title="Unparsed Entity" href="#dt-unparsed">unparsed entity</a>; otherwise it is a parsed entity.</p>
1433<div class="constraint"><p class="prefix"><a name="not-declared"></a><b>Validity constraint: Notation Declared</b></p><p>The <a href="#NT-Name">Name</a>
1434must match the declared name of a <a title="Notation" href="#dt-notation">notation</a>.</p>
1435</div>
1436<p><span class="diff-chg">[<a name="dt-sysid" title="System Identifier">Definition</a>: The <a href="#NT-SystemLiteral">SystemLiteral</a> is called the entity's <b>system
1437identifier</b>. It is a <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E88">[E88]</a>URI
1438reference</span><span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E66">[E66]</a>
1439(as defined in <a href="#rfc2396">[IETF RFC 2396]</a>, updated by <a href="#rfc2732">[IETF RFC 2732]</a>)</span>, <a href="http://www.w3.org/XML/xml-19980210-errata#E76">[E76]</a>meant
1440to be dereferenced to obtain input for the XML processor to construct the
1441entity's replacement text.] It is an error for a fragment identifier
1442(beginning with a <code>#</code> character) to be part of a system identifier.</span>
1443Unless otherwise provided by information outside the scope of this specification
1444(e.g. a special XML element type defined by a particular DTD, or a processing
1445instruction defined by a particular application specification), relative URIs
1446are relative to the location of the resource within which the entity declaration
1447occurs. A URI might thus be relative to the <a title="Document Entity" href="#dt-docent">document
1448entity</a>, to the entity containing the <a title="Document Type Declaration" href="#dt-doctype">external
1449DTD subset</a>, or to some other <a title="External Entity" href="#dt-extent">external parameter
1450entity</a>.</p>
1451<div class="diff-chg"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E78">[E78]</a>URI
1452references require encoding and escaping of certain characters. The disallowed
1453characters include all non-ASCII characters, plus the excluded characters
1454listed in Section 2.4 of <a href="#rfc2396">[IETF RFC 2396]</a>, except for the number sign
1455(<code>#</code>) and percent sign (<code>%</code>) characters and the square
1456bracket characters re-allowed in <a href="#rfc2732">[IETF RFC 2732]</a>. Disallowed characters
1457must be escaped as follows:</p></div>
1458<div class="diff-add"><ol>
1459<li><p>Each disallowed character is converted to UTF-8 <a href="#rfc2279">[IETF RFC 2279]</a>
1460as one or more bytes.</p></li>
1461<li><p>Any octets corresponding to a disallowed character are escaped with
1462the URI escaping mechanism (that is, converted to <code>%</code><var>HH</var>,
1463where HH is the hexadecimal notation of the byte value).</p></li>
1464<li><p>The original character is replaced by the resulting character sequence.</p>
1465</li>
1466</ol></div>
1467<p>[<a name="dt-pubid" title="Public identifier">Definition</a>:  In addition to a system
1468identifier, an external identifier may include a <b>public identifier</b>.]
1469An XML processor attempting to retrieve the entity's content may use the public
1470identifier to try to generate an alternative <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E88">[E88]</a>URI reference</span>.
1471If the processor is unable to do so, it must use the <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E88">[E88]</a>URI
1472reference</span> specified in the system literal. Before a match is attempted,
1473all strings of white space in the public identifier must be normalized to
1474single space characters (#x20), and leading and trailing white space must
1475be removed.</p>
1476<p>Examples of external entity declarations:</p>
1477<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ENTITY open-hatch
1478         SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml"&gt;
1479&lt;!ENTITY open-hatch
1480         PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"
1481         "http://www.textuality.com/boilerplate/OpenHatch.xml"&gt;
1482&lt;!ENTITY hatch-pic
1483         SYSTEM "/grafix/OpenHatch.gif"
1484         NDATA gif &gt;</pre></td></tr></table>
1485</div>
1486</div>
1487<div class="div2">
1488
1489<h3><a name="TextEntities"></a>4.3 Parsed Entities</h3>
1490<div class="div3">
1491
1492<h4><a name="sec-TextDecl"></a>4.3.1 The Text Declaration</h4>
1493<p>External parsed entities <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E107">[E107]</a>should</span> each begin with a <b>text declaration</b>.</p>
1494
1495<h5>Text Declaration</h5><table class="scrap" summary="Scrap"><tbody>
1496<tr valign="baseline"><td><a name="NT-TextDecl"></a>[77]���</td><td><code>TextDecl</code></td><td>���::=���</td><td><code>'&lt;?xml' <a href="#NT-VersionInfo">VersionInfo</a>? <a href="#NT-EncodingDecl">EncodingDecl</a> <a href="#NT-S">S</a>? '?&gt;'</code></td><xsltdebug></xsltdebug></tr>
1497</tbody></table>
1498<p>The text declaration must be provided literally, not by reference to a
1499parsed entity. No text declaration may appear at any position other than the
1500beginning of an external parsed entity. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E94">[E94]</a>The text declaration
1501in an external parsed entity is not considered part of its <a title="Replacement Text" href="#dt-repltext">replacement
1502text</a>.</span></p>
1503</div>
1504<div class="div3">
1505
1506<h4><a name="wf-entities"></a>4.3.2 Well-Formed Parsed Entities</h4>
1507<p>The document entity is well-formed if it matches the production labeled <a href="#NT-document">document</a>. An external general parsed entity is well-formed
1508if it matches the production labeled <a href="#NT-extParsedEnt">extParsedEnt</a>. <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a>All
1509external parameter entities are well-formed by definition.</span></p>
1510
1511<h5>Well-Formed External Parsed Entity</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-extParsedEnt"></a>[78]���</td><td><code>extParsedEnt</code></td><td>���::=���</td><td><code><a href="#NT-TextDecl">TextDecl</a>? <a href="#NT-content">content</a></code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td class="diff-del"><a name="NT-extPE"></a>[79]���</td><td class="diff-del"><code>extPE</code></td><td class="diff-del">���::=���</td><td class="diff-del"><code><a href="#NT-TextDecl">TextDecl</a>? <a href="#NT-extSubsetDecl">extSubsetDecl</a></code></td><xsltdebug></xsltdebug><td class="diff-del"><i>/* <a href="http://www.w3.org/XML/xml-19980210-errata#E109">[E109]</a> */</i></td></tr></tbody></table>
1512<p>An internal general parsed entity is well-formed if its replacement text
1513matches the production labeled <a href="#NT-content">content</a>. All internal
1514parameter entities are well-formed by definition.</p>
1515<p>A consequence of well-formedness in entities is that the logical and physical
1516structures in an XML document are properly nested; no <a title="Start-Tag" href="#dt-stag">start-tag</a>, <a title="End Tag" href="#dt-etag">end-tag</a>, <a title="Empty" href="#dt-empty">empty-element tag</a>, <a title="Element" href="#dt-element">element</a>, <a title="Comment" href="#dt-comment">comment</a>, <a title="Processing instruction" href="#dt-pi">processing instruction</a>, <a title="Character Reference" href="#dt-charref">character
1517reference</a>, or <a title="Entity Reference" href="#dt-entref">entity reference</a>
1518can begin in one entity and end in another.</p>
1519</div>
1520<div class="div3">
1521
1522<h4><a name="charencoding"></a>4.3.3 Character Encoding in Entities</h4>
1523<p>Each external parsed entity in an XML document may use a different encoding
1524for its characters. All XML processors must be able to read entities in <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E56">[E56]</a>both
1525the UTF-8 and UTF-16 encodings.</span> <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E77">[E77]</a>The terms "UTF-8"
1526and "UTF-16" in this specification do not apply to character
1527encodings with any other labels, even if the encodings or labels are very
1528similar to UTF-8 or UTF-16.</span></p>
1529<p>Entities encoded in UTF-16 must begin with the Byte Order Mark described
1530by <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</a>Annex
1531F of <a href="#ISO10646">[ISO/IEC 10646]</a>, Annex H of <a href="#ISO10646-2000">[ISO/IEC 10646-2000]</a>, section
15322.4 of <a href="#Unicode">[Unicode]</a>, and section 2.7 of <a href="#Unicode3">[Unicode3]</a></span>
1533(the ZERO WIDTH NO-BREAK SPACE character, #xFEFF). This is an encoding signature,
1534not part of either the markup or the character data of the XML document. XML
1535processors must be able to use this character to differentiate between UTF-8
1536and UTF-16 encoded documents.</p>
1537<p>Although an XML processor is required to read only entities in the UTF-8
1538and UTF-16 encodings, it is recognized that other encodings are used around
1539the world, and it may be desired for XML processors to read entities that
1540use them. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E47">[E47]</a>In
1541the absence of external character encoding information (such as MIME headers),</span>
1542parsed entities which are stored in an encoding other than UTF-8 or UTF-16
1543must begin with a text declaration <span class="diff-add">(see <a href="#sec-TextDecl"><b>4.3.1 The Text Declaration</b></a>) </span>containing
1544an encoding declaration:</p>
1545
1546<h5>Encoding Declaration</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-EncodingDecl"></a>[80]���</td><td><code>EncodingDecl</code></td><td>���::=���</td><td><code><a href="#NT-S">S</a> 'encoding' <a href="#NT-Eq">Eq</a>
1547('"' <a href="#NT-EncName">EncName</a> '"' | "'" <a href="#NT-EncName">EncName</a>
1548"'" ) </code></td><xsltdebug></xsltdebug></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-EncName"></a>[81]���</td><td><code>EncName</code></td><td>���::=���</td><td><code>[A-Za-z] ([A-Za-z0-9._] | '-')*</code></td><xsltdebug></xsltdebug><td><i>/* Encoding
1549name contains only Latin characters */</i></td></tr></tbody></table>
1550<p>In the <a title="Document Entity" href="#dt-docent">document entity</a>, the encoding
1551declaration is part of the <a title="XML Declaration" href="#dt-xmldecl">XML declaration</a>.
1552The <a href="#NT-EncName">EncName</a> is the name of the encoding used.</p>
1553
1554<p>In an encoding declaration, the values "<code>UTF-8</code>", "<code>UTF-16</code>", "<code>ISO-10646-UCS-2</code>", and "<code>ISO-10646-UCS-4</code>" should be used
1555for the various encodings and transformations of Unicode / ISO/IEC 10646,
1556the values "<code>ISO-8859-1</code>", "<code>ISO-8859-2</code>",
1557... <a href="http://www.w3.org/XML/xml-19980210-errata#E106">[E106]</a><span class="diff-chg">"<code>ISO-8859-</code><var>n</var>" (where <var>n</var>
1558is the part number)</span> should be used for the parts of ISO 8859, and
1559the values "<code>ISO-2022-JP</code>", "<code>Shift_JIS</code>",
1560and "<code>EUC-JP</code>" should be used for the various encoded
1561forms of JIS X-0208-1997. <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E57">[E57]</a>It
1562is recommended that character encodings registered (as <em>charset</em>s)
1563with the Internet Assigned Numbers Authority <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E58">[E58]</a><a href="#IANA">[IANA-CHARSETS]</a></span>,
1564other than those just listed, be referred to using their registered names;
1565other encodings should use names starting with an "x-" prefix.
1566XML processors should match character encoding names in a case-insensitive
1567way and should either interpret an IANA-registered name as the encoding registered
1568at IANA for that name or treat it as unknown (processors are, of course, not
1569required to support all IANA-registered encodings).</span></p>
1570<p>In the absence of information provided by an external transport protocol
1571(e.g. HTTP or MIME), it is an <a title="Error" href="#dt-error">error</a> for
1572an entity including an encoding declaration to be presented to the XML processor
1573in an encoding other than that named in the declaration, <span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E5">[E5]</a>for
1574an encoding declaration to occur other than at the beginning of an external
1575entity, </span>or for an entity which begins with neither a Byte Order Mark
1576nor an encoding declaration to use an encoding other than UTF-8. Note that
1577since ASCII is a subset of UTF-8, ordinary ASCII entities do not strictly
1578need an encoding declaration.</p>
1579<div class="diff-add"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E5">[E5]</a>It
1580is <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E36">[E36]</a>a
1581fatal</span> error for a <a href="#NT-TextDecl">TextDecl</a> to occur other
1582than at the beginning of an external entity.</p></div>
1583<p>It is a <a title="Fatal Error" href="#dt-fatal">fatal error</a> when an XML processor
1584encounters an entity with an encoding that it is unable to process. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E79">[E79]</a>It
1585is a fatal error if an XML entity is determined (via default, encoding declaration,
1586or higher-level protocol) to be in a certain encoding but contains octet sequences
1587that are not legal in that encoding. It is also a fatal error if an XML entity
1588contains no encoding declaration and its content is not legal UTF-8 or UTF-16.</span></p>
1589<p>Examples of <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E23">[E23]</a>text
1590declarations containing </span>encoding declarations:</p>
1591<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;?xml encoding='UTF-8'?&gt;
1592&lt;?xml encoding='EUC-JP'?&gt;</pre></td></tr></table>
1593</div>
1594</div>
1595<div class="div2">
1596
1597<h3><a name="entproc"></a>4.4 XML Processor Treatment of Entities and References</h3>
1598<p>The table below summarizes the contexts in which character references,
1599entity references, and invocations of unparsed entities might appear and the
1600required behavior of an <a title="XML Processor" href="#dt-xml-proc">XML processor</a>
1601in each case. The labels in the leftmost column describe the recognition context: </p><dl>
1602<dt class="label">Reference in Content</dt>
1603<dd>
1604<p>as a reference anywhere after the <a title="Start-Tag" href="#dt-stag">start-tag</a>
1605and before the <a title="End Tag" href="#dt-etag">end-tag</a> of an element; corresponds
1606to the nonterminal <a href="#NT-content">content</a>.</p>
1607</dd>
1608<dt class="label">Reference in Attribute Value</dt>
1609<dd>
1610<p>as a reference within either the value of an attribute in a <a title="Start-Tag" href="#dt-stag">start-tag</a>,
1611or a default value in an <a title="Attribute-List Declaration" href="#dt-attdecl">attribute declaration</a>;
1612corresponds to the nonterminal <a href="#NT-AttValue">AttValue</a>.</p>
1613</dd>
1614<dt class="label">Occurs as Attribute Value</dt>
1615<dd>
1616<p>as a <a href="#NT-Name">Name</a>, not a reference, appearing either as
1617the value of an attribute which has been declared as type <b>ENTITY</b>,
1618or as one of the space-separated tokens in the value of an attribute which
1619has been declared as type <b>ENTITIES</b>.</p>
1620</dd>
1621<dt class="label">Reference in Entity Value</dt>
1622<dd>
1623<p>as a reference within a parameter or internal entity's <a title="Literal Entity Value" href="#dt-litentval">literal
1624entity value</a> in the entity's declaration; corresponds to the nonterminal <a href="#NT-EntityValue">EntityValue</a>.</p>
1625</dd>
1626<dt class="label">Reference in DTD</dt>
1627<dd>
1628<div class="diff-chg"><p><a href="http://www.w3.org/XML/xml-19980210-errata#E90">[E90]</a>as
1629a reference within either the internal or external subsets of the <a title="Document Type Declaration" href="#dt-doctype">DTD</a>, but outside of an <a href="#NT-EntityValue">EntityValue</a>, <a href="#NT-AttValue">AttValue</a>, <a href="#NT-PI">PI</a>, <a href="#NT-Comment">Comment</a>, <a href="#NT-SystemLiteral">SystemLiteral</a>, <a href="#NT-PubidLiteral">PubidLiteral</a>,
1630or the contents of an ignored conditional section (see <a href="#sec-condition-sect"><b>3.4 Conditional Sections</b></a>).</p></div>
1631<p>.</p>
1632</dd>
1633</dl><p></p>
1634<table border="1" frame="border" cellpadding="7"><tbody align="center"><tr>
1635<td rowspan="2" colspan="1"></td><td colspan="4" align="center" valign="bottom" rowspan="1">Entity
1636Type</td><td rowspan="2" align="center" colspan="1">Character</td></tr><tr align="center" valign="bottom"><td rowspan="1" colspan="1">Parameter</td><td rowspan="1" colspan="1">Internal General</td><td rowspan="1" colspan="1">External Parsed
1637General</td><td rowspan="1" colspan="1">Unparsed</td></tr><tr align="center" valign="middle"><td align="right" rowspan="1" colspan="1">Reference
1638in Content</td><td rowspan="1" colspan="1"><a href="#not-recognized"><cite>Not recognized</cite></a></td>
1639<td rowspan="1" colspan="1"><a href="#included"><cite>Included</cite></a></td><td rowspan="1" colspan="1"><a href="#include-if-valid"><cite>Included
1640if validating</cite></a></td><td rowspan="1" colspan="1"><a href="#forbidden"><cite>Forbidden</cite></a></td>
1641<td rowspan="1" colspan="1"><a href="#included"><cite>Included</cite></a></td></tr><tr align="center" valign="middle"><td align="right" rowspan="1" colspan="1">Reference in Attribute Value</td><td rowspan="1" colspan="1"><a href="#not-recognized"><cite>Not recognized</cite></a></td><td rowspan="1" colspan="1"><a href="#inliteral"><cite>Included
1642in literal</cite></a></td><td rowspan="1" colspan="1"><a href="#forbidden"><cite>Forbidden</cite></a></td>
1643<td rowspan="1" colspan="1"><a href="http://www.w3.org/XML/xml-19980210-errata#E51">[E51]</a><div class="diff-chg"><a href="#forbidden"><cite>Forbidden</cite></a></div></td><td rowspan="1" colspan="1"><a href="#included"><cite>Included</cite></a></td>
1644</tr><tr align="center" valign="middle"><td align="right" rowspan="1" colspan="1">Occurs as Attribute
1645Value</td><td rowspan="1" colspan="1"><a href="#not-recognized"><cite>Not recognized</cite></a></td>
1646<td rowspan="1" colspan="1"><a href="#forbidden"><cite>Forbidden</cite></a></td><td rowspan="1" colspan="1"><a href="http://www.w3.org/XML/xml-19980210-errata#E51">[E51]</a><div class="diff-chg"><a href="#forbidden"><cite>Forbidden</cite></a></div></td><td rowspan="1" colspan="1"><a href="#notify"><cite>Notify</cite></a></td>
1647<td rowspan="1" colspan="1"><a href="http://www.w3.org/XML/xml-19980210-errata#E51">[E51]</a><div class="diff-chg"><a href="#not-recognized"><cite>Not recognized</cite></a></div></td></tr><tr align="center" valign="middle"><td align="right" rowspan="1" colspan="1">Reference in EntityValue</td><td rowspan="1" colspan="1"><a href="#inliteral"><cite>Included in literal</cite></a></td><td rowspan="1" colspan="1"><a href="#bypass"><cite>Bypassed</cite></a></td>
1648<td rowspan="1" colspan="1"><a href="#bypass"><cite>Bypassed</cite></a></td><td rowspan="1" colspan="1"><a href="#forbidden"><cite>Forbidden</cite></a></td>
1649<td rowspan="1" colspan="1"><a href="#included"><cite>Included</cite></a></td></tr><tr align="center" valign="middle"><td align="right" rowspan="1" colspan="1">Reference in DTD</td><td rowspan="1" colspan="1"><a href="#as-PE"><cite>Included
1650as PE</cite></a></td><td rowspan="1" colspan="1"><a href="#forbidden"><cite>Forbidden</cite></a></td>
1651<td rowspan="1" colspan="1"><a href="#forbidden"><cite>Forbidden</cite></a></td><td rowspan="1" colspan="1"><a href="#forbidden"><cite>Forbidden</cite></a></td>
1652<td rowspan="1" colspan="1"><a href="#forbidden"><cite>Forbidden</cite></a></td></tr></tbody></table>
1653<div class="div3">
1654
1655<h4><a name="not-recognized"></a>4.4.1 Not Recognized</h4>
1656<p>Outside the DTD, the <code>%</code> character has no special significance;
1657thus, what would be parameter entity references in the DTD are not recognized
1658as markup in <a href="#NT-content">content</a>. Similarly, the names of unparsed
1659entities are not recognized except when they appear in the value of an appropriately
1660declared attribute.</p>
1661</div>
1662<div class="div3">
1663
1664<h4><a name="included"></a>4.4.2 Included</h4>
1665<p>[<a name="dt-include" title="Include">Definition</a>: An entity is <b>included</b>
1666when its <a title="Replacement Text" href="#dt-repltext">replacement text</a> is retrieved
1667and processed, in place of the reference itself, as though it were part of
1668the document at the location the reference was recognized.] The replacement
1669text may contain both <a title="Character Data" href="#dt-chardata">character data</a>
1670and (except for parameter entities) <a title="Markup" href="#dt-markup">markup</a>,
1671which must be recognized in the usual way<span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E65">[E65]</a>, except that
1672the replacement text of entities used to escape markup delimiters (the entities <code>amp</code>,
1673<code>lt</code>,
1674<code>gt</code>,
1675<code>apos</code>,
1676<code>quot</code>)
1677is always treated as data</span>. (The string "<code>AT&amp;amp;T;</code>"
1678expands to "<code>AT&amp;T;</code>" and the remaining ampersand
1679is not recognized as an entity-reference delimiter.) A character reference
1680is <b>included</b> when the indicated character is processed in place
1681of the reference itself. </p>
1682</div>
1683<div class="div3">
1684
1685<h4><a name="include-if-valid"></a>4.4.3 Included If Validating</h4>
1686<p>When an XML processor recognizes a reference to a parsed entity, in order
1687to <a title="Validity" href="#dt-valid">validate</a> the document, the processor
1688must <a title="Include" href="#dt-include">include</a> its replacement text. If
1689the entity is external, and the processor is not attempting to validate the
1690XML document, the processor <a title="May" href="#dt-may">may</a>, but need
1691not, include the entity's replacement text. If a non-validating <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E95">[E95]</a>processor</span>
1692does not include the replacement text, it must inform the application that
1693it recognized, but did not read, the entity.</p>
1694<p>This rule is based on the recognition that the automatic inclusion provided
1695by the SGML and XML entity mechanism, primarily designed to support modularity
1696in authoring, is not necessarily appropriate for other applications, in particular
1697document browsing. Browsers, for example, when encountering an external parsed
1698entity reference, might choose to provide a visual indication of the entity's
1699presence and retrieve it for display only on demand.</p>
1700</div>
1701<div class="div3">
1702
1703<h4><a name="forbidden"></a>4.4.4 Forbidden</h4>
1704<p>The following are forbidden, and constitute <a title="Fatal Error" href="#dt-fatal">fatal</a>
1705errors:</p>
1706<ul>
1707<li><p>the appearance of a reference to an <a title="Unparsed Entity" href="#dt-unparsed">unparsed
1708entity</a>.</p></li>
1709<li><p>the appearance of any character or general-entity reference in the
1710DTD except within an <a href="#NT-EntityValue">EntityValue</a> or <a href="#NT-AttValue">AttValue</a>.</p>
1711</li>
1712<li><p>a reference to an external entity in an attribute value.</p></li>
1713</ul>
1714</div>
1715<div class="div3">
1716
1717<h4><a name="inliteral"></a>4.4.5 Included in Literal</h4>
1718<p>When an <a title="Entity Reference" href="#dt-entref">entity reference</a> appears in
1719an attribute value, or a parameter entity reference appears in a literal entity
1720value, its <a title="Replacement Text" href="#dt-repltext">replacement text</a> is processed
1721in place of the reference itself as though it were part of the document at
1722the location the reference was recognized, except that a single or double
1723quote character in the replacement text is always treated as a normal data
1724character and will not terminate the literal. For example, this is well-formed:</p>
1725<div class="diff-chg"><table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td class="diff-chg"><pre>&lt;!-- <a href="http://www.w3.org/XML/xml-19980210-errata#E4">[E4]</a> --&gt;
1726&lt;!ENTITY % YN '"Yes"' &gt;
1727&lt;!ENTITY WhatHeSaid "He said %YN;" &gt;</pre></td></tr></table></div>
1728<p>while this is not:</p>
1729<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ENTITY EndAttr "27'" &gt;
1730&lt;element attribute='a-&amp;EndAttr;&gt;</pre></td></tr></table>
1731</div>
1732<div class="div3">
1733
1734<h4><a name="notify"></a>4.4.6 Notify</h4>
1735<p>When the name of an <a title="Unparsed Entity" href="#dt-unparsed">unparsed entity</a>
1736appears as a token in the value of an attribute of declared type <b>ENTITY</b>
1737or <b>ENTITIES</b>, a validating processor must inform the application of
1738the <a title="System Identifier" href="#dt-sysid">system</a> and <a title="Public identifier" href="#dt-pubid">public</a>
1739(if any) identifiers for both the entity and its associated <a title="Notation" href="#dt-notation">notation</a>.</p>
1740</div>
1741<div class="div3">
1742
1743<h4><a name="bypass"></a>4.4.7 Bypassed</h4>
1744<p>When a general entity reference appears in the <a href="#NT-EntityValue">EntityValue</a>
1745in an entity declaration, it is bypassed and left as is.</p>
1746</div>
1747<div class="div3">
1748
1749<h4><a name="as-PE"></a>4.4.8 Included as PE</h4>
1750<p>Just as with external parsed entities, parameter entities need only be <a href="#include-if-valid"><cite>included if validating</cite></a>. When a parameter-entity
1751reference is recognized in the DTD and included, its <a title="Replacement Text" href="#dt-repltext">replacement
1752text</a> is enlarged by the attachment of one leading and one following
1753space (#x20) character; the intent is to constrain the replacement text of
1754parameter entities to contain an integral number of grammatical tokens in
1755the DTD. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E96">[E96]</a>This
1756behavior does not apply to parameter entity references within entity values;
1757these are described in <a href="#inliteral"><b>4.4.5 Included in Literal</b></a>.</span></p>
1758</div>
1759</div>
1760<div class="div2">
1761
1762<h3><a name="intern-replacement"></a>4.5 Construction of Internal Entity Replacement Text</h3>
1763<p>In discussing the treatment of internal entities, it is useful to distinguish
1764two forms of the entity's value. [<a name="dt-litentval" title="Literal Entity Value">Definition</a>: The <b>literal
1765entity value</b> is the quoted string actually present in the entity declaration,
1766corresponding to the non-terminal <a href="#NT-EntityValue">EntityValue</a>.] [<a name="dt-repltext" title="Replacement Text">Definition</a>: The <b>replacement text</b>
1767is the content of the entity, after replacement of character references and
1768parameter-entity references.]</p>
1769<p>The literal entity value as given in an internal entity declaration (<a href="#NT-EntityValue">EntityValue</a>) may contain character, parameter-entity,
1770and general-entity references. Such references must be contained entirely
1771within the literal entity value. The actual replacement text that is <a title="Include" href="#dt-include">included</a> as described above must contain the <em>replacement
1772text</em> of any parameter entities referred to, and must contain the character
1773referred to, in place of any character references in the literal entity value;
1774however, general-entity references must be left as-is, unexpanded. For example,
1775given the following declarations:</p>
1776<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ENTITY % pub    "&amp;#xc9;ditions Gallimard" &gt;
1777&lt;!ENTITY   rights "All rights reserved" &gt;
1778&lt;!ENTITY   book   "La Peste: Albert Camus,
1779&amp;#xA9; 1947 %pub;. &amp;rights;" &gt;</pre></td></tr></table>
1780<p>then the replacement text for the entity "<code>book</code>"
1781is:</p>
1782<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>La Peste: Albert Camus,
1783� 1947 �ditions Gallimard. &amp;rights;</pre></td></tr></table>
1784<p>The general-entity reference "<code>&amp;rights;</code>" would
1785be expanded should the reference "<code>&amp;book;</code>" appear
1786in the document's content or an attribute value.</p>
1787<p>These simple rules may have complex interactions; for a detailed discussion
1788of a difficult example, see <a href="#sec-entexpand"><b>D Expansion of Entity and Character References</b></a>.</p>
1789</div>
1790<div class="div2">
1791
1792<h3><a name="sec-predefined-ent"></a>4.6 Predefined Entities</h3>
1793<p>[<a name="dt-escape" title="escape">Definition</a>: Entity and character references can
1794both be used to <b>escape</b> the left angle bracket, ampersand, and
1795other delimiters. A set of general entities (<code>amp</code>,
1796<code>lt</code>,
1797<code>gt</code>,
1798<code>apos</code>,
1799<code>quot</code>) is specified for
1800this purpose. Numeric character references may also be used; they are expanded
1801immediately when recognized and must be treated as character data, so the
1802numeric character references "<code>&amp;#60;</code>" and "<code>&amp;#38;</code>"
1803may be used to escape <code>&lt;</code> and <code>&amp;</code> when they occur
1804in character data.]</p>
1805<p>All XML processors must recognize these entities whether they are declared
1806or not. <a title="For interoperability" href="#dt-interop">For interoperability</a>, valid XML
1807documents should declare these entities, like any others, before using them. <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E80">[E80]</a>If
1808the entities <code>lt</code> or <code>amp</code> are declared, they must be
1809declared as internal entities whose replacement text is a character reference
1810to the <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E103">[E103]</a>respective
1811character (less-than sign or ampersand)</span> being escaped; the double
1812escaping is required for these entities so that references to them produce
1813a well-formed result. If the entities <code>gt</code>, <code>apos</code>,
1814or <code>quot</code> are declared, they must be declared as internal entities
1815whose replacement text is the single character being escaped (or a character
1816reference to that character; the double escaping here is unnecessary but harmless).
1817For example:</span></p>
1818<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ENTITY lt     "&amp;#38;#60;"&gt;
1819&lt;!ENTITY gt     "&amp;#62;"&gt;
1820&lt;!ENTITY amp    "&amp;#38;#38;"&gt;
1821&lt;!ENTITY apos   "&amp;#39;"&gt;
1822&lt;!ENTITY quot   "&amp;#34;"&gt;</pre></td></tr></table>
1823<div class="diff-del"><p>Note that the <code>&lt;</code> and <code>&amp;</code> characters
1824in the declarations of "<code>lt</code>" and "<code>amp</code>"
1825are doubly escaped to meet the requirement that entity replacement be well-formed.</p></div>
1826</div>
1827<div class="div2">
1828
1829<h3><a name="Notations"></a>4.7 Notation Declarations</h3>
1830<p>[<a name="dt-notation" title="Notation">Definition</a>: <b>Notations</b> identify
1831by name the format of <a title="External Entity" href="#dt-extent">unparsed entities</a>,
1832the format of elements which bear a notation attribute, or the application
1833to which a <a title="Processing instruction" href="#dt-pi">processing instruction</a> is addressed.]</p>
1834<p>[<a name="dt-notdecl" title="Notation Declaration">Definition</a>:  <b>Notation declarations</b>
1835provide a name for the notation, for use in entity and attribute-list declarations
1836and in attribute specifications, and an external identifier for the notation
1837which may allow an XML processor or its client application to locate a helper
1838application capable of processing data in the given notation.]</p>
1839
1840<h5>Notation Declarations</h5><table class="scrap" summary="Scrap"><tbody><tr valign="baseline"><td><a name="NT-NotationDecl"></a>[82]���</td><td><code>NotationDecl</code></td><td>���::=���</td><td><code>'&lt;!NOTATION' <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-PublicID">PublicID</a>) <a href="#NT-S">S</a>? '&gt;'</code></td><xsltdebug></xsltdebug><td class="diff-add"><a href="#UniqueNotationName">[VC: Unique
1841Notation Name]</a></td></tr></tbody><tbody><tr valign="baseline"><td><a name="NT-PublicID"></a>[83]���</td><td><code>PublicID</code></td><td>���::=���</td><td><code>'PUBLIC' <a href="#NT-S">S</a> <a href="#NT-PubidLiteral">PubidLiteral</a> </code></td><xsltdebug></xsltdebug></tr></tbody></table>
1842<div class="diff-add"><div class="constraint"><p class="prefix"><a name="UniqueNotationName"></a><b>Validity constraint: <a href="http://www.w3.org/XML/xml-19980210-errata#E22">[E22]</a>Unique
1843Notation Name</b></p><p>Only one notation declaration can declare a given <a href="#NT-Name">Name</a>.</p>
1844</div></div>
1845<p>XML processors must provide applications with the name and external identifier(s)
1846of any notation declared and referred to in an attribute value, attribute
1847definition, or entity declaration. They may additionally resolve the external
1848identifier into the <a title="System Identifier" href="#dt-sysid">system identifier</a>, file
1849name, or other information needed to allow the application to call a processor
1850for data in the notation described. (It is not an error, however, for XML
1851documents to declare and refer to notations for which notation-specific applications
1852are not available on the system where the XML processor or application is
1853running.)</p>
1854</div>
1855<div class="div2">
1856
1857<h3><a name="sec-doc-entity"></a>4.8 Document Entity</h3>
1858<p>[<a name="dt-docent" title="Document Entity">Definition</a>: The <b>document entity</b>
1859serves as the root of the entity tree and a starting-point for an <a title="XML Processor" href="#dt-xml-proc">XML processor</a>.] This specification does
1860not specify how the document entity is to be located by an XML processor;
1861unlike other entities, the document entity has no name and might well appear
1862on a processor input stream without any identification at all.</p>
1863</div>
1864</div>
1865
1866<div class="div1">
1867
1868<h2><a name="sec-conformance"></a>5 Conformance</h2>
1869<div class="div2">
1870
1871<h3><a name="proc-types"></a>5.1 Validating and Non-Validating Processors</h3>
1872<p>Conforming <a title="XML Processor" href="#dt-xml-proc">XML processors</a> fall into
1873two classes: validating and non-validating.</p>
1874<p>Validating and non-validating processors alike must report violations of
1875this specification's well-formedness constraints in the content of the <a title="Document Entity" href="#dt-docent">document entity</a> and any other <a title="Text Entity" href="#dt-parsedent">parsed
1876entities</a> that they read.</p>
1877<p>[<a name="dt-validating" title="Validating Processor">Definition</a>: <b>Validating
1878processors</b> must<span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E21">[E21]</a>,
1879at user option,</span> report violations of the constraints expressed by
1880the declarations in the <a title="Document Type Declaration" href="#dt-doctype">DTD</a>, and failures
1881to fulfill the validity constraints given in this specification.]
1882To accomplish this, validating XML processors must read and process the entire
1883DTD and all external parsed entities referenced in the document.</p>
1884<p>Non-validating processors are required to check only the <a title="Document Entity" href="#dt-docent">document
1885entity</a>, including the entire internal DTD subset, for well-formedness. [<a name="dt-use-mdecl" title="Process Declarations">Definition</a>:  While they are not required
1886to check the document for validity, they are required to <b>process</b>
1887all the declarations they read in the internal DTD subset and in any parameter
1888entity that they read, up to the first reference to a parameter entity that
1889they do <em>not</em> read; that is to say, they must use the information
1890in those declarations to <a href="#AVNormalize"><cite>normalize</cite></a>
1891attribute values, <a href="#included"><cite>include</cite></a> the replacement
1892text of internal entities, and supply <a href="#sec-attr-defaults"><cite>default
1893attribute values</cite></a>.] <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E33">[E33]</a>Except when <code>standalone="yes"</code>, </span>they
1894must not <a title="Process Declarations" href="#dt-use-mdecl">process</a> <a title="entity declaration" href="#dt-entdecl">entity
1895declarations</a> or <a title="Attribute-List Declaration" href="#dt-attdecl">attribute-list declarations</a>
1896encountered after a reference to a parameter entity that is not read, since
1897the entity may have contained overriding declarations.</p>
1898</div>
1899<div class="div2">
1900
1901<h3><a name="safe-behavior"></a>5.2 Using XML Processors</h3>
1902<p>The behavior of a validating XML processor is highly predictable; it must
1903read every piece of a document and report all well-formedness and validity
1904violations. Less is required of a non-validating processor; it need not read
1905any part of the document other than the document entity. This has two effects
1906that may be important to users of XML processors:</p>
1907<ul>
1908<li><p>Certain well-formedness errors, specifically those that require reading
1909external entities, may not be detected by a non-validating processor. Examples
1910include the constraints entitled <a href="#wf-entdeclared"><cite>Entity Declared</cite></a>, <a href="#textent"><cite>Parsed Entity</cite></a>, and <a href="#norecursion"><cite>No
1911Recursion</cite></a>, as well as some of the cases described as <a href="#forbidden"><cite>forbidden</cite></a> in <a href="#entproc"><b>4.4 XML Processor Treatment of Entities and References</b></a>.</p></li>
1912<li><p>The information passed from the processor to the application may
1913vary, depending on whether the processor reads parameter and external entities.
1914For example, a non-validating processor may not <a href="#AVNormalize"><cite>normalize</cite></a>
1915attribute values, <a href="#included"><cite>include</cite></a> the replacement
1916text of internal entities, or supply <a href="#sec-attr-defaults"><cite>default
1917attribute values</cite></a>, where doing so depends on having read declarations
1918in external or parameter entities.</p></li>
1919</ul>
1920<p>For maximum reliability in interoperating between different XML processors,
1921applications which use non-validating processors should not rely on any behaviors
1922not required of such processors. Applications which require facilities such
1923as the use of default attributes or internal entities which are declared in
1924external entities should use validating XML processors.</p>
1925</div>
1926</div>
1927<div class="div1">
1928
1929<h2><a name="sec-notation"></a>6 Notation</h2>
1930<p>The formal grammar of XML is given in this specification using a simple
1931Extended Backus-Naur Form (EBNF) notation. Each rule in the grammar defines
1932one symbol, in the form</p>
1933<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>symbol ::= expression</pre></td></tr></table>
1934<p>Symbols are written with an initial capital letter if they are <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E42">[E42]</a>the
1935start symbol of a regular language,</span> otherwise with an initial lower
1936case letter. Literal strings are quoted.</p>
1937<p>Within the expression on the right-hand side of a rule, the following expressions
1938are used to match strings of one or more characters: </p><dl>
1939<dt class="label"><code>#xN</code></dt>
1940<dd>
1941<p>where <code>N</code> is a hexadecimal integer, the expression matches the
1942character in ISO/IEC 10646 whose canonical (UCS-4) code value, when interpreted
1943as an unsigned binary number, has the value indicated. The number of leading
1944zeros in the <code>#xN</code> form is insignificant; the number of leading
1945zeros in the corresponding code value is governed by the character encoding
1946in use and is not significant for XML.</p>
1947</dd>
1948<dt class="label"><code>[a-zA-Z]</code>, <code>[#xN-#xN]</code></dt>
1949<dd>
1950<p>matches any <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E93">[E93]</a><a href="#NT-Char">Char</a></span> with a value in the range(s) indicated (inclusive).</p>
1951</dd>
1952<dt class="label"><span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E3">[E3]</a><code>[abc]</code>, <code>[#xN#xN#xN]</code></span></dt>
1953<dd><div class="diff-add">
1954<p>matches any <a href="#NT-Char">Char</a> with a value among the characters
1955enumerated. Enumerations and ranges can be mixed in one set of brackets.</p>
1956</div></dd>
1957<dt class="label"><code>[^a-z]</code>, <code>[^#xN-#xN]</code></dt>
1958<dd>
1959<p>matches any <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E93">[E93]</a><a href="#NT-Char">Char</a></span> with a value <em>outside</em> the range
1960indicated.</p>
1961</dd>
1962<dt class="label"><code>[^abc]</code>, <code>[^#xN#xN#xN]</code></dt>
1963<dd>
1964<p>matches any <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E93">[E93]</a><a href="#NT-Char">Char</a></span> with a value not among the characters given. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E3">[E3]</a>Enumerations
1965and ranges of forbidden values can be mixed in one set of brackets.</span></p>
1966</dd>
1967<dt class="label"><code>"string"</code></dt>
1968<dd>
1969<p>matches a literal string <a title="match" href="#dt-match">matching</a> that
1970given inside the double quotes.</p>
1971</dd>
1972<dt class="label"><code>'string'</code></dt>
1973<dd>
1974<p>matches a literal string <a title="match" href="#dt-match">matching</a> that
1975given inside the single quotes.</p>
1976</dd>
1977</dl><p> These symbols may be combined to match more complex patterns as follows,
1978where <code>A</code> and <code>B</code> represent simple expressions: </p><dl>
1979<dt class="label">(<code>expression</code>)</dt>
1980<dd>
1981<p><code>expression</code> is treated as a unit and may be combined as described
1982in this list.</p>
1983</dd>
1984<dt class="label"><code>A?</code></dt>
1985<dd>
1986<p>matches <code>A</code> or nothing; optional <code>A</code>.</p>
1987</dd>
1988<dt class="label"><code>A B</code></dt>
1989<dd>
1990<p>matches <code>A</code> followed by <code>B</code>. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E20">[E20]</a>This
1991operator has higher precedence than alternation; thus <code>A B | C D</code>
1992is identical to <code>(A B) | (C D)</code>.</span></p>
1993</dd>
1994<dt class="label"><code>A | B</code></dt>
1995<dd>
1996<p>matches <code>A</code> or <code>B</code> but not both.</p>
1997</dd>
1998<dt class="label"><code>A - B</code></dt>
1999<dd>
2000<p>matches any string that matches <code>A</code> but does not match <code>B</code>.</p>
2001</dd>
2002<dt class="label"><code>A+</code></dt>
2003<dd>
2004<p>matches one or more occurrences of <code>A</code>.<span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E20">[E20]</a>Concatenation
2005has higher precedence than alternation; thus <code>A+ | B+</code> is identical
2006to <code>(A+) | (B+)</code>.</span></p>
2007</dd>
2008<dt class="label"><code>A*</code></dt>
2009<dd>
2010<p>matches zero or more occurrences of <code>A</code>. <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E20">[E20]</a>Concatenation
2011has higher precedence than alternation; thus <code>A* | B*</code> is identical
2012to <code>(A*) | (B*)</code>.</span></p>
2013</dd>
2014</dl><p> Other notations used in the productions are: </p><dl>
2015<dt class="label"><code>/* ... */</code></dt>
2016<dd>
2017<p>comment.</p>
2018</dd>
2019<dt class="label"><code>[ wfc: ... ]</code></dt>
2020<dd>
2021<p>well-formedness constraint; this identifies by name a constraint on <a title="Well-Formed" href="#dt-wellformed">well-formed</a> documents associated with a production.</p>
2022</dd>
2023<dt class="label"><code>[ vc: ... ]</code></dt>
2024<dd>
2025<p>validity constraint; this identifies by name a constraint on <a title="Validity" href="#dt-valid">valid</a>
2026documents associated with a production.</p>
2027</dd>
2028</dl><p></p>
2029</div>
2030</div><div class="back">
2031
2032
2033<div class="div1">
2034
2035<h2><a name="sec-bibliography"></a>A References</h2>
2036<div class="div2">
2037
2038<h3><a name="sec-existing-stds"></a>A.1 Normative References</h3>
2039<dl>
2040<dt class="label"><span class="diff-chg"><a name="IANA"></a>IANA-CHARSETS</span></dt><dd><div class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E58">[E58]</a>(Internet
2041Assigned Numbers Authority) <cite>Official Names for Character Sets</cite>,
2042ed. Keld Simonsen et al. See <a href="ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets">ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets</a>. </div></dd>
2043<dt class="label"><a name="RFC1766"></a>IETF RFC 1766</dt><dd>IETF
2044(Internet Engineering Task Force). <cite>RFC 1766: Tags for the Identification
2045of Languages</cite>, ed. H. Alvestrand. 1995.  (See <a href="http://www.ietf.org/rfc/rfc1766.txt">http://www.ietf.org/rfc/rfc1766.txt</a>.)</dd>
2046<dt class="label"><span class="diff-del"><a name="ISO639-old"></a>ISO 639</span></dt><dd><div class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E38">[E38]</a>
2047(International Organization for Standardization). <cite>ISO 639:1988 (E).
2048Code for the representation of names of languages.</cite> [Geneva]: International
2049Organization for Standardization, 1988.</div></dd>
2050<dt class="label"><span class="diff-del"><a name="ISO3166-old"></a>ISO 3166</span></dt><dd><div class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E38">[E38]</a>
2051(International Organization for Standardization). <cite>ISO 3166-1:1997
2052(E). Codes for the representation of names of countries and their subdivisions --
2053Part 1: Country codes</cite> [Geneva]: International Organization for
2054Standardization, 1997.</div></dd>
2055<dt class="label"><a name="ISO10646"></a>ISO/IEC 10646</dt><dd>ISO (International Organization for
2056Standardization). <cite>ISO/IEC 10646-1993 (E). Information technology --
2057Universal Multiple-Octet Coded Character Set (UCS) -- Part 1: Architecture
2058and Basic Multilingual Plane.</cite> [Geneva]: International Organization
2059for Standardization, 1993 (plus amendments AM 1 through AM 7).</dd>
2060<dt class="label"><span class="diff-add"><a name="ISO10646-2000"></a>ISO/IEC 10646-2000</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</a> ISO (International
2061Organization for Standardization). <cite>ISO/IEC 10646-1:2000. Information
2062technology -- Universal Multiple-Octet Coded Character Set (UCS) --
2063Part 1: Architecture and Basic Multilingual Plane.</cite> [Geneva]: International
2064Organization for Standardization, 2000.</div></dd>
2065<dt class="label"><a name="Unicode"></a>Unicode</dt><dd>The Unicode Consortium. <em>The Unicode
2066Standard, Version 2.0.</em> Reading, Mass.: Addison-Wesley Developers Press,
20671996.</dd>
2068<dt class="label"><span class="diff-add"><a name="Unicode3"></a>Unicode3</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</a>
2069The Unicode Consortium. <em>The Unicode Standard, Version 3.0.</em> Reading,
2070Mass.: Addison-Wesley Developers Press, 2000. ISBN 0-201-61633-5.</div></dd>
2071</dl></div>
2072<div class="div2">
2073
2074
2075<h3><a name="null"></a>A.2 Other References</h3>
2076<dl>
2077<dt class="label"><a name="Aho"></a>Aho/Ullman</dt><dd>Aho, Alfred V., Ravi Sethi, and Jeffrey D.
2078Ullman. <cite>Compilers: Principles, Techniques, and Tools</cite>.
2079Reading: Addison-Wesley, 1986, rpt. corr. 1988.</dd>
2080<dt class="label"><a name="Berners-Lee"></a>Berners-Lee et al.</dt><dd> Berners-Lee, T., R. Fielding,
2081and L. Masinter. <cite>Uniform Resource Identifiers (URI): Generic Syntax
2082and Semantics</cite>. 1997. (Work in progress; see updates to RFC1738.)</dd>
2083<dt class="label"><span class="diff-chg"><a name="ABK"></a>Br�ggemann-Klein</span></dt><dd><div class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E2">[E2]</a>Br�ggemann-Klein,
2084Anne. Formal Models in Document Processing. Habilitationsschrift. Faculty
2085of Mathematics at the University of Freiburg, 1993. (See <a href="ftp://ftp.informatik.uni-freiburg.de/documents/papers/brueggem/habil.ps">ftp://ftp.informatik.uni-freiburg.de/documents/papers/brueggem/habil.ps</a>.)</div></dd>
2086<dt class="label"><span class="diff-chg"><a name="ABKDW"></a>Br�ggemann-Klein and Wood</span></dt><dd><div class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E2">[E2]</a>Br�ggemann-Klein,
2087Anne, and Derick Wood. <cite>Deterministic Regular Languages</cite>.
2088Universit�t Freiburg, Institut f�r Informatik, Bericht 38, Oktober 1991. Extended
2089abstract in A. Finkel, M. Jantzen, Hrsg., STACS 1992, S. 173-184. Springer-Verlag,
2090Berlin 1992. Lecture Notes in Computer Science 577. Full version titled <cite>One-Unambiguous
2091Regular Languages</cite> in Information and Computation 140 (2): 229-253,
2092February 1998.</div></dd>
2093<dt class="label"><a name="Clark"></a>Clark</dt><dd>James Clark. Comparison of SGML and XML. See <a href="http://www.w3.org/TR/NOTE-sgml-xml-971215">http://www.w3.org/TR/NOTE-sgml-xml-971215</a>. </dd>
2094<dt class="label"><span class="diff-add"><a name="IANA-LANGCODES"></a>IANA-LANGCODES</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E58">[E58]</a>(Internet
2095Assigned Numbers Authority) <cite>Registry of Language Tags</cite>,
2096ed. Keld Simonsen et al.  (See <a href="http://www.isi.edu/in-notes/iana/assignments/languages/">http://www.isi.edu/in-notes/iana/assignments/languages/</a>.)</div></dd>
2097<dt class="label"><span class="diff-del"><a name="RFC1738"></a>IETF RFC1738</span></dt><dd><div class="diff-del">IETF
2098(Internet Engineering Task Force). <cite>RFC 1738: Uniform Resource Locators
2099(URL)</cite>, ed. T. Berners-Lee, L. Masinter, M. McCahill. 1994.   (See <a href="http://www.ietf.org/rfc/rfc1738.txt">http://www.ietf.org/rfc/rfc1738.txt</a>.)</div></dd>
2100<dt class="label"><span class="diff-del"><a name="RFC1808"></a>IETF RFC1808</span></dt><dd><div class="diff-del">IETF
2101(Internet Engineering Task Force). <cite>RFC 1808: Relative Uniform Resource
2102Locators</cite>, ed. R. Fielding. 1995.   (See <a href="http://www.ietf.org/rfc/rfc1808.txt">http://www.ietf.org/rfc/rfc1808.txt</a>.)</div></dd>
2103<dt class="label"><a name="RFC2141"></a>IETF RFC2141</dt><dd>IETF
2104(Internet Engineering Task Force). <em>RFC 2141: URN Syntax</em>, ed.
2105R. Moats. 1997.   (See <a href="http://www.ietf.org/rfc/rfc2141.txt">http://www.ietf.org/rfc/rfc2141.txt</a>.)</dd>
2106<dt class="label"><span class="diff-add"><a name="rfc2279"></a>IETF RFC 2279</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E78">[E78]</a>IETF
2107(Internet Engineering Task Force). <cite>RFC 2279: UTF-8, a transformation
2108format of ISO 10646</cite>, <span class="diff-add">ed. F. Yergeau, </span>1998.  (See <a href="http://www.ietf.org/rfc/rfc2279.txt">http://www.ietf.org/rfc/rfc2279.txt</a>.)</div></dd>
2109<dt class="label"><span class="diff-add"><a name="rfc2376"></a>IETF RFC 2376</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E48">[E48]</a>IETF
2110(Internet Engineering Task Force). <cite>RFC 2376: XML Media Types</cite>.
2111ed. E. Whitehead, M. Murata. 1998.  (See <a href="http://www.ietf.org/rfc/rfc2376.txt">http://www.ietf.org/rfc/rfc2376.txt</a>.)</div></dd>
2112<dt class="label"><span class="diff-add"><a name="rfc2396"></a>IETF RFC 2396</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E66">[E66]</a>IETF
2113(Internet Engineering Task Force). <cite>RFC 2396: Uniform Resource Identifiers
2114(URI): Generic Syntax</cite>. T. Berners-Lee, R. Fielding, L. Masinter.
21151998.  (See <a href="http://www.ietf.org/rfc/rfc2396.txt">http://www.ietf.org/rfc/rfc2396.txt</a>.)</div></dd>
2116<dt class="label"><span class="diff-add"><a name="rfc2732"></a>IETF RFC 2732</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E66">[E66]</a>IETF
2117(Internet Engineering Task Force). <cite>RFC 2732: Format for Literal
2118IPv6 Addresses in URL's</cite>. R. Hinden, B. Carpenter, L. Masinter.
21191999.  (See <a href="http://www.ietf.org/rfc/rfc2732.txt">http://www.ietf.org/rfc/rfc2732.txt</a>.)</div></dd>
2120<dt class="label"><span class="diff-add"><a name="rfc2781"></a>IETF RFC 2781</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E77">[E77]</a>
2121IETF (Internet Engineering Task Force). <em>RFC 2781: UTF-16, an encoding
2122of ISO 10646</em>, ed. P. Hoffman, F. Yergeau. 2000.  (See <a href="http://www.ietf.org/rfc/rfc2781.txt">http://www.ietf.org/rfc/rfc2781.txt</a>.)</div></dd>
2123<dt class="label"><span class="diff-add"><a name="ISO639"></a>ISO 639</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E38">[E38]</a>
2124(International Organization for Standardization). <cite>ISO 639:1988 (E).
2125Code for the representation of names of languages.</cite> [Geneva]: International
2126Organization for Standardization, 1988.</div></dd>
2127<dt class="label"><span class="diff-add"><a name="ISO3166"></a>ISO 3166</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E38">[E38]</a>
2128(International Organization for Standardization). <cite>ISO 3166-1:1997
2129(E). Codes for the representation of names of countries and their subdivisions --
2130Part 1: Country codes</cite> [Geneva]: International Organization for
2131Standardization, 1997.</div></dd>
2132<dt class="label"><a name="ISO8879"></a>ISO 8879</dt><dd>ISO (International Organization for Standardization). <cite>ISO
21338879:1986(E). Information processing -- Text and Office Systems --
2134Standard Generalized Markup Language (SGML).</cite> First edition --
21351986-10-15. [Geneva]: International Organization for Standardization, 1986. </dd>
2136<dt class="label"><a name="ISO10744"></a>ISO/IEC 10744</dt><dd>ISO (International Organization for
2137Standardization). <cite>ISO/IEC 10744-1992 (E). Information technology --
2138Hypermedia/Time-based Structuring Language (HyTime). </cite> [Geneva]:
2139International Organization for Standardization, 1992. <em>Extended Facilities
2140Annexe.</em> [Geneva]: International Organization for Standardization, 1996. </dd>
2141<dt class="label"><span class="diff-add"><a name="websgml"></a>WEBSGML</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E43">[E43]</a>ISO
2142(International Organization for Standardization). <cite>ISO 8879:1986
2143TC2. Information technology -- Document Description and Processing Languages. </cite>
2144[Geneva]: International Organization for Standardization, 1998.  (See <a href="http://www.sgmlsource.com/8879rev/n0029.htm">http://www.sgmlsource.com/8879rev/n0029.htm</a>.)</div></dd>
2145<dt class="label"><span class="diff-add"><a name="xml-names"></a>XML Names</span></dt><dd><div class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E98">[E98]</a>Tim Bray,
2146Dave Hollander, and Andrew Layman, editors. <cite>Namespaces in XML</cite>.
2147Textuality, Hewlett-Packard, and Microsoft. World Wide Web Consortium, 1999.  (See <a href="http://www.w3.org/TR/REC-xml-names/">http://www.w3.org/TR/REC-xml-names/</a>.)</div></dd>
2148</dl></div>
2149</div>
2150<div class="div1">
2151
2152<h2><a name="CharClasses"></a>B Character Classes</h2>
2153<p>Following the characteristics defined in the Unicode standard, characters
2154are classed as base characters (among others, these contain the alphabetic
2155characters of the Latin alphabet<span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E84">[E84]</a>, without
2156diacritics</span>), ideographic characters, and combining characters (among
2157others, this class contains most diacritics)<span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E30">[E30]</a>; these classes
2158combine to form the class of letters.</span> Digits and extenders are also
2159distinguished.</p>
2160
2161<h5>Characters</h5><table class="scrap" summary="Scrap"><tbody>
2162<tr valign="baseline"><td><a name="NT-Letter"></a>[84]���</td><td><code>Letter</code></td><td>���::=���</td><td><code><a href="#NT-BaseChar">BaseChar</a> | <a href="#NT-Ideographic">Ideographic</a></code></td><xsltdebug></xsltdebug></tr>
2163<tr valign="baseline"><td><a name="NT-BaseChar"></a>[85]���</td><td><code>BaseChar</code></td><td>���::=���</td><td><code>[#x0041-#x005A] |�[#x0061-#x007A] |�[#x00C0-#x00D6]
2164|�[#x00D8-#x00F6] |�[#x00F8-#x00FF] |�[#x0100-#x0131] |�[#x0134-#x013E]
2165|�[#x0141-#x0148] |�[#x014A-#x017E] |�[#x0180-#x01C3] |�[#x01CD-#x01F0]
2166|�[#x01F4-#x01F5] |�[#x01FA-#x0217] |�[#x0250-#x02A8] |�[#x02BB-#x02C1]
2167|�#x0386 |�[#x0388-#x038A] |�#x038C |�[#x038E-#x03A1]
2168|�[#x03A3-#x03CE] |�[#x03D0-#x03D6] |�#x03DA |�#x03DC
2169|�#x03DE |�#x03E0 |�[#x03E2-#x03F3] |�[#x0401-#x040C]
2170|�[#x040E-#x044F] |�[#x0451-#x045C] |�[#x045E-#x0481] |�[#x0490-#x04C4]
2171|�[#x04C7-#x04C8] |�[#x04CB-#x04CC] |�[#x04D0-#x04EB] |�[#x04EE-#x04F5]
2172|�[#x04F8-#x04F9] |�[#x0531-#x0556] |�#x0559 |�[#x0561-#x0586]
2173|�[#x05D0-#x05EA] |�[#x05F0-#x05F2] |�[#x0621-#x063A] |�[#x0641-#x064A]
2174|�[#x0671-#x06B7] |�[#x06BA-#x06BE] |�[#x06C0-#x06CE] |�[#x06D0-#x06D3]
2175|�#x06D5 |�[#x06E5-#x06E6] |�[#x0905-#x0939] |�#x093D
2176|�[#x0958-#x0961] |�[#x0985-#x098C] |�[#x098F-#x0990] |�[#x0993-#x09A8]
2177|�[#x09AA-#x09B0] |�#x09B2 |�[#x09B6-#x09B9] |�[#x09DC-#x09DD]
2178|�[#x09DF-#x09E1] |�[#x09F0-#x09F1] |�[#x0A05-#x0A0A] |�[#x0A0F-#x0A10]
2179|�[#x0A13-#x0A28] |�[#x0A2A-#x0A30] |�[#x0A32-#x0A33] |�[#x0A35-#x0A36]
2180|�[#x0A38-#x0A39] |�[#x0A59-#x0A5C] |�#x0A5E |�[#x0A72-#x0A74]
2181|�[#x0A85-#x0A8B] |�#x0A8D |�[#x0A8F-#x0A91] |�[#x0A93-#x0AA8]
2182|�[#x0AAA-#x0AB0] |�[#x0AB2-#x0AB3] |�[#x0AB5-#x0AB9] |�#x0ABD
2183|�#x0AE0 |�[#x0B05-#x0B0C] |�[#x0B0F-#x0B10] |�[#x0B13-#x0B28]
2184|�[#x0B2A-#x0B30] |�[#x0B32-#x0B33] |�[#x0B36-#x0B39] |�#x0B3D
2185|�[#x0B5C-#x0B5D] |�[#x0B5F-#x0B61] |�[#x0B85-#x0B8A] |�[#x0B8E-#x0B90]
2186|�[#x0B92-#x0B95] |�[#x0B99-#x0B9A] |�#x0B9C |�[#x0B9E-#x0B9F]
2187|�[#x0BA3-#x0BA4] |�[#x0BA8-#x0BAA] |�[#x0BAE-#x0BB5] |�[#x0BB7-#x0BB9]
2188|�[#x0C05-#x0C0C] |�[#x0C0E-#x0C10] |�[#x0C12-#x0C28] |�[#x0C2A-#x0C33]
2189|�[#x0C35-#x0C39] |�[#x0C60-#x0C61] |�[#x0C85-#x0C8C] |�[#x0C8E-#x0C90]
2190|�[#x0C92-#x0CA8] |�[#x0CAA-#x0CB3] |�[#x0CB5-#x0CB9] |�#x0CDE
2191|�[#x0CE0-#x0CE1] |�[#x0D05-#x0D0C] |�[#x0D0E-#x0D10] |�[#x0D12-#x0D28]
2192|�[#x0D2A-#x0D39] |�[#x0D60-#x0D61] |�[#x0E01-#x0E2E] |�#x0E30
2193|�[#x0E32-#x0E33] |�[#x0E40-#x0E45] |�[#x0E81-#x0E82] |�#x0E84
2194|�[#x0E87-#x0E88] |�#x0E8A |�#x0E8D |�[#x0E94-#x0E97]
2195|�[#x0E99-#x0E9F] |�[#x0EA1-#x0EA3] |�#x0EA5 |�#x0EA7
2196|�[#x0EAA-#x0EAB] |�[#x0EAD-#x0EAE] |�#x0EB0 |�[#x0EB2-#x0EB3]
2197|�#x0EBD |�[#x0EC0-#x0EC4] |�[#x0F40-#x0F47] |�[#x0F49-#x0F69]
2198|�[#x10A0-#x10C5] |�[#x10D0-#x10F6] |�#x1100 |�[#x1102-#x1103]
2199|�[#x1105-#x1107] |�#x1109 |�[#x110B-#x110C] |�[#x110E-#x1112]
2200|�#x113C |�#x113E |�#x1140 |�#x114C |�#x114E |�#x1150
2201|�[#x1154-#x1155] |�#x1159 |�[#x115F-#x1161] |�#x1163
2202|�#x1165 |�#x1167 |�#x1169 |�[#x116D-#x116E] |�[#x1172-#x1173]
2203|�#x1175 |�#x119E |�#x11A8 |�#x11AB |�[#x11AE-#x11AF]
2204|�[#x11B7-#x11B8] |�#x11BA |�[#x11BC-#x11C2] |�#x11EB
2205|�#x11F0 |�#x11F9 |�[#x1E00-#x1E9B] |�[#x1EA0-#x1EF9]
2206|�[#x1F00-#x1F15] |�[#x1F18-#x1F1D] |�[#x1F20-#x1F45] |�[#x1F48-#x1F4D]
2207|�[#x1F50-#x1F57] |�#x1F59 |�#x1F5B |�#x1F5D |�[#x1F5F-#x1F7D]
2208|�[#x1F80-#x1FB4] |�[#x1FB6-#x1FBC] |�#x1FBE |�[#x1FC2-#x1FC4]
2209|�[#x1FC6-#x1FCC] |�[#x1FD0-#x1FD3] |�[#x1FD6-#x1FDB] |�[#x1FE0-#x1FEC]
2210|�[#x1FF2-#x1FF4] |�[#x1FF6-#x1FFC] |�#x2126 |�[#x212A-#x212B]
2211|�#x212E |�[#x2180-#x2182] |�[#x3041-#x3094] |�[#x30A1-#x30FA]
2212|�[#x3105-#x312C] |�[#xAC00-#xD7A3] </code></td><xsltdebug></xsltdebug></tr>
2213<tr valign="baseline"><td><a name="NT-Ideographic"></a>[86]���</td><td><code>Ideographic</code></td><td>���::=���</td><td><code>[#x4E00-#x9FA5] |�#x3007 |�[#x3021-#x3029] </code></td><xsltdebug></xsltdebug></tr>
2214<tr valign="baseline"><td><a name="NT-CombiningChar"></a>[87]���</td><td><code>CombiningChar</code></td><td>���::=���</td><td><code>[#x0300-#x0345] |�[#x0360-#x0361] |�[#x0483-#x0486]
2215|�[#x0591-#x05A1] |�[#x05A3-#x05B9] |�[#x05BB-#x05BD] |�#x05BF
2216|�[#x05C1-#x05C2] |�#x05C4 |�[#x064B-#x0652] |�#x0670
2217|�[#x06D6-#x06DC] |�[#x06DD-#x06DF] |�[#x06E0-#x06E4] |�[#x06E7-#x06E8]
2218|�[#x06EA-#x06ED] |�[#x0901-#x0903] |�#x093C |�[#x093E-#x094C]
2219|�#x094D |�[#x0951-#x0954] |�[#x0962-#x0963] |�[#x0981-#x0983]
2220|�#x09BC |�#x09BE |�#x09BF |�[#x09C0-#x09C4] |�[#x09C7-#x09C8]
2221|�[#x09CB-#x09CD] |�#x09D7 |�[#x09E2-#x09E3] |�#x0A02
2222|�#x0A3C |�#x0A3E |�#x0A3F |�[#x0A40-#x0A42] |�[#x0A47-#x0A48]
2223|�[#x0A4B-#x0A4D] |�[#x0A70-#x0A71] |�[#x0A81-#x0A83] |�#x0ABC
2224|�[#x0ABE-#x0AC5] |�[#x0AC7-#x0AC9] |�[#x0ACB-#x0ACD] |�[#x0B01-#x0B03]
2225|�#x0B3C |�[#x0B3E-#x0B43] |�[#x0B47-#x0B48] |�[#x0B4B-#x0B4D]
2226|�[#x0B56-#x0B57] |�[#x0B82-#x0B83] |�[#x0BBE-#x0BC2] |�[#x0BC6-#x0BC8]
2227|�[#x0BCA-#x0BCD] |�#x0BD7 |�[#x0C01-#x0C03] |�[#x0C3E-#x0C44]
2228|�[#x0C46-#x0C48] |�[#x0C4A-#x0C4D] |�[#x0C55-#x0C56] |�[#x0C82-#x0C83]
2229|�[#x0CBE-#x0CC4] |�[#x0CC6-#x0CC8] |�[#x0CCA-#x0CCD] |�[#x0CD5-#x0CD6]
2230|�[#x0D02-#x0D03] |�[#x0D3E-#x0D43] |�[#x0D46-#x0D48] |�[#x0D4A-#x0D4D]
2231|�#x0D57 |�#x0E31 |�[#x0E34-#x0E3A] |�[#x0E47-#x0E4E]
2232|�#x0EB1 |�[#x0EB4-#x0EB9] |�[#x0EBB-#x0EBC] |�[#x0EC8-#x0ECD]
2233|�[#x0F18-#x0F19] |�#x0F35 |�#x0F37 |�#x0F39 |�#x0F3E
2234|�#x0F3F |�[#x0F71-#x0F84] |�[#x0F86-#x0F8B] |�[#x0F90-#x0F95]
2235|�#x0F97 |�[#x0F99-#x0FAD] |�[#x0FB1-#x0FB7] |�#x0FB9
2236|�[#x20D0-#x20DC] |�#x20E1 |�[#x302A-#x302F] |�#x3099
2237|�#x309A </code></td><xsltdebug></xsltdebug></tr>
2238<tr valign="baseline"><td><a name="NT-Digit"></a>[88]���</td><td><code>Digit</code></td><td>���::=���</td><td><code>[#x0030-#x0039] |�[#x0660-#x0669] |�[#x06F0-#x06F9]
2239|�[#x0966-#x096F] |�[#x09E6-#x09EF] |�[#x0A66-#x0A6F] |�[#x0AE6-#x0AEF]
2240|�[#x0B66-#x0B6F] |�[#x0BE7-#x0BEF] |�[#x0C66-#x0C6F] |�[#x0CE6-#x0CEF]
2241|�[#x0D66-#x0D6F] |�[#x0E50-#x0E59] |�[#x0ED0-#x0ED9] |�[#x0F20-#x0F29] </code></td><xsltdebug></xsltdebug></tr>
2242<tr valign="baseline"><td><a name="NT-Extender"></a>[89]���</td><td><code>Extender</code></td><td>���::=���</td><td><code>#x00B7 |�#x02D0 |�#x02D1 |�#x0387 |�#x0640
2243|�#x0E46 |�#x0EC6 |�#x3005 |�[#x3031-#x3035] |�[#x309D-#x309E]
2244|�[#x30FC-#x30FE] </code></td><xsltdebug></xsltdebug></tr>
2245</tbody></table>
2246<p>The character classes defined here can be derived from the Unicode <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</a>2.0</span>
2247character database as follows:</p>
2248<ul>
2249<li><p>Name start characters must have one of the categories Ll, Lu, Lo,
2250Lt, Nl.</p></li>
2251<li><p>Name characters other than Name-start characters must have one of
2252the categories Mc, Me, Mn, Lm, or Nd.</p></li>
2253<li><p>Characters in the compatibility area (i.e. with character code greater
2254than #xF900 and less than #xFFFE) are not allowed in XML names.</p></li>
2255<li><p>Characters which have a font or compatibility decomposition (i.e.
2256those with a "compatibility formatting tag" in field 5 of the
2257database -- marked by field 5 beginning with a "&lt;") are not
2258allowed.</p></li>
2259<li><p>The following characters are treated as name-start characters rather
2260than name characters, because the property file classifies them as Alphabetic:
2261[#x02BB-#x02C1], #x0559, #x06E5, #x06E6.</p></li>
2262<li><p>Characters #x20DD-#x20E0 are excluded (in accordance with Unicode <span class="diff-add"><a href="http://www.w3.org/XML/xml-19980210-errata#E67">[E67]</a>2.0</span>,
2263section 5.14).</p></li>
2264<li><p>Character #x00B7 is classified as an extender, because the property
2265list so identifies it.</p></li>
2266<li><p>Character #x0387 is added as a name character, because #x00B7 is
2267its canonical equivalent.</p></li>
2268<li><p>Characters ':' and '_' are allowed as name-start characters.</p>
2269</li>
2270<li><p>Characters '-' and '.' are allowed as name characters.</p></li>
2271</ul>
2272</div>
2273<div class="div1">
2274
2275<h2><a name="sec-xml-and-sgml"></a>C XML and SGML (Non-Normative)</h2>
2276<p><span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E43">[E43]</a>XML
2277is designed to be a subset of SGML, in that every XML document should also
2278be a conforming SGML document.</span> For a detailed comparison of the additional
2279restrictions that XML places on documents beyond those of SGML, see <a href="#Clark">[Clark]</a>.</p>
2280</div>
2281<div class="div1">
2282
2283<h2><a name="sec-entexpand"></a>D Expansion of Entity and Character References (Non-Normative)</h2>
2284<p>This appendix contains some examples illustrating the sequence of entity-
2285and character-reference recognition and expansion, as specified in <a href="#entproc"><b>4.4 XML Processor Treatment of Entities and References</b></a>.</p>
2286<p>If the DTD contains the declaration</p>
2287<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;!ENTITY example "&lt;p&gt;An ampersand (&amp;#38;#38;) may be escaped
2288numerically (&amp;#38;#38;#38;) or with a general entity
2289(&amp;amp;amp;).&lt;/p&gt;" &gt;</pre></td></tr></table>
2290<p>then the XML processor will recognize the character references when it
2291parses the entity declaration, and resolve them before storing the following
2292string as the value of the entity "<code>example</code>":</p>
2293<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>&lt;p&gt;An ampersand (&amp;#38;) may be escaped
2294numerically (&amp;#38;#38;) or with a general entity
2295(&amp;amp;amp;).&lt;/p&gt;</pre></td></tr></table>
2296<p>A reference in the document to "<code>&amp;example;</code>"
2297will cause the text to be reparsed, at which time the start- and end-tags
2298of the <code>p</code> element will be recognized and the three references will
2299be recognized and expanded, resulting in a <code>p</code> element with the following
2300content (all data, no delimiters or markup):</p>
2301<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>An ampersand (&amp;) may be escaped
2302numerically (&amp;#38;) or with a general entity
2303(&amp;amp;).</pre></td></tr></table>
2304<p>A more complex example will illustrate the rules and their effects fully.
2305In the following example, the line numbers are solely for reference.</p>
2306<table class="eg" cellpadding="5" border="1" bgcolor="#99ffff" width="100%" summary="Example"><tr><td><pre>1 &lt;?xml version='1.0'?&gt;
23072 &lt;!DOCTYPE test [
23083 &lt;!ELEMENT test (#PCDATA) &gt;
23094 &lt;!ENTITY % xx '&amp;#37;zz;'&gt;
23105 &lt;!ENTITY % zz '&amp;#60;!ENTITY tricky "error-prone" &gt;' &gt;
23116 %xx;
23127 ]&gt;
23138 &lt;test&gt;This sample shows a &amp;tricky; method.&lt;/test&gt;</pre></td></tr></table>
2314<p>This produces the following:</p>
2315<ul>
2316<li><p>in line 4, the reference to character 37 is expanded immediately,
2317and the parameter entity "<code>xx</code>" is stored in the symbol
2318table with the value "<code>%zz;</code>". Since the replacement
2319text is not rescanned, the reference to parameter entity "<code>zz</code>"
2320is not recognized. (And it would be an error if it were, since "<code>zz</code>"
2321is not yet declared.)</p></li>
2322<li><p>in line 5, the character reference "<code>&amp;#60;</code>"
2323is expanded immediately and the parameter entity "<code>zz</code>"
2324is stored with the replacement text "<code>&lt;!ENTITY tricky "error-prone"
2325&gt;</code>", which is a well-formed entity declaration.</p></li>
2326<li><p>in line 6, the reference to "<code>xx</code>" is recognized,
2327and the replacement text of "<code>xx</code>" (namely "<code>%zz;</code>")
2328is parsed. The reference to "<code>zz</code>" is recognized in
2329its turn, and its replacement text ("<code>&lt;!ENTITY tricky "error-prone"
2330&gt;</code>") is parsed. The general entity "<code>tricky</code>"
2331has now been declared, with the replacement text "<code>error-prone</code>".</p>
2332</li>
2333<li><p>in line 8, the reference to the general entity "<code>tricky</code>"
2334is recognized, and it is expanded, so the full content of the <code>test</code>
2335element is the self-describing (and ungrammatical) string <em>This sample
2336shows a error-prone method.</em></p></li>
2337</ul>
2338</div>
2339<div class="div1">
2340
2341<h2><a name="determinism"></a>E Deterministic Content Models (Non-Normative)</h2>
2342<p><span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E102">[E102]</a>As
2343noted in <a href="#sec-element-content"><b>3.2.1 Element Content</b></a>, it is required that content
2344models in element type declarations be deterministic. This requirement is <a title="For Compatibility" href="#dt-compat">for compatibility</a> with SGML (which calls deterministic
2345content models "unambiguous");</span> XML processors built
2346using SGML systems may flag non-deterministic content models as errors.</p>
2347<p>For example, the content model <code>((b, c) | (b, d))</code> is non-deterministic,
2348because given an initial <code>b</code> the <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E95">[E95]</a>XML processor</span>
2349cannot know which <code>b</code> in the model is being matched without looking
2350ahead to see which element follows the <code>b</code>. In this case, the two references
2351to <code>b</code> can be collapsed into a single reference, making the model read <code>(b,
2352(c | d))</code>. An initial <code>b</code> now clearly matches only a single name
2353in the content model. The <span class="diff-chg"><a href="http://www.w3.org/XML/xml-19980210-errata#E95">[E95]</a>processor</span> doesn't need to look ahead to see what follows; either <code>c</code> or <code>d</code>
2354would be accepted.</p>
2355<p>More formally: a finite state automaton may be constructed from the content
2356model using the standard algorithms, e.g. algorithm 3.5 in section 3.9 of
2357Aho, Sethi, and Ullman <a href="#Aho">[Aho/Ullman]</a>. In many such algorithms, a follow
2358set is constructed for each position in the regular expression (i.e., each
2359leaf node in the syntax tree for the regular expression); if any position
2360has a follow set in which more than one following position is labeled with
2361the same element type name, then the content model is in error and may be
2362reported as an error.</p>
2363<p>Algorithms exist which allow many but not all non-deterministic content
2364models to be reduced automatically to equivalent deterministic models; see
2365Br�ggemann-Klein 1991 <a href="#ABK">[Br�ggemann-Klein]</a>.</p>
2366</div>
2367<div class="div1">
2368
2369<h2><a name="sec-guessing"></a>F <a href="http://www.w3.org/XML/xml-19980210-errata#E105">[E105]</a><a href="http://www.w3.org/XML/xml-19980210-errata#E48">[E48]</a>Autodetection
2370of Character Encodings (Non-Normative)</h2>
2371<p>The XML encoding declaration functions as an internal label on each entity,
2372indicating which character encoding is in use. Before an XML processor can
2373read the internal label, however, it apparently has to know what character
2374encoding is in use--which is what the internal label is trying to indicate.
2375In the general case, this is a hopeless situation. It is not entirely hopeless
2376in XML, however, because XML limits the general case in two ways: each implementation
2377is assumed to support only a finite set of character encodings, and the XML
2378encoding declaration is restricted in position and content in order to make
2379it feasible to autodetect the character encoding in use in each entity in
2380normal cases. Also, in many cases other sources of information are available
2381in addition to the XML data stream itself. Two cases may be distinguished,
2382depending on whether the XML entity is presented to the processor without,
2383or with, any accompanying (external) information. We consider the first case
2384first.</p>
2385<div class="div2">
2386<div class="diff-add">
2387<h3><a name="sec-guessing-no-ext-info"></a>F.1 Detection Without External Encoding Information</h3></div>
2388<p>Because each XML entity <span class="diff-add">not accompanied by external
2389encoding information and </span>not in UTF-8 or UTF-16 <span class="diff-chg">encoding</span> <em>must</em>
2390begin with an XML encoding declaration, in which the first characters must
2391be '<code>&lt;?xml</code>', any conforming processor can detect, after two
2392to four octets of input, which of the following cases apply. In reading this
2393list, it may help to know that in UCS-4, '&lt;' is "<code>#x0000003C</code>"
2394and '?' is "<code>#x0000003F</code>", and the Byte Order Mark
2395required of UTF-16 data streams is "<code>#xFEFF</code>". <span class="diff-add">The notation <var>##</var> is used to denote any byte value except <span class="diff-chg">that two consecutive <var>##</var>s cannot be both 00</span>.</span></p>
2396<div class="diff-add"><p>With a Byte Order Mark:</p></div>
2397<div class="diff-add"><table border="1" frame="border"><tbody><tr><td rowspan="1" colspan="1"><code>00 00 FE
2398FF</code></td><td rowspan="1" colspan="1">UCS-4, big-endian machine (1234 order)</td></tr><tr><td rowspan="1" colspan="1"><code>FF
2399FE 00 00</code></td><td rowspan="1" colspan="1">UCS-4, little-endian machine (4321 order)</td></tr>
2400<tr><td rowspan="1" colspan="1"><code>00 00 FF FE</code></td><td rowspan="1" colspan="1">UCS-4, unusual octet order (2143)</td>
2401</tr><tr><td rowspan="1" colspan="1"><code>FE FF 00 00</code></td><td rowspan="1" colspan="1">UCS-4, unusual octet order (3412)</td>
2402</tr><tr><td rowspan="1" colspan="1"><code>FE FF ## ##</code></td><td rowspan="1" colspan="1">UTF-16, big-endian</td></tr>
2403<tr><td rowspan="1" colspan="1"><code>FF FE ## ##</code></td><td rowspan="1" colspan="1">UTF-16, little-endian</td></tr><tr>
2404<td rowspan="1" colspan="1"><code>EF BB BF</code></td><td rowspan="1" colspan="1">UTF-8</td></tr></tbody></table></div>
2405<div class="diff-add"><p>Without a Byte Order Mark:</p></div>
2406<div class="diff-add"><table border="1" frame="border"><tbody><tr><td rowspan="1" colspan="1"><code>00�00�00�3C</code></td>
2407<td rowspan="4" colspan="1">UCS-4 or other encoding with a 32-bit code unit and ASCII
2408characters encoded as ASCII values, in respectively big-endian (1234), little-endian
2409(4321) and two unusual byte orders (2143 and 3412). The encoding declaration
2410must be read to determine which of UCS-4 or other supported 32-bit encodings
2411applies.</td></tr><tr><td rowspan="1" colspan="1"><code>3C 00 00 00</code></td>
2412
2413</tr><tr><td rowspan="1" colspan="1"><code>00 00 3C 00</code></td>
2414
2415</tr><tr><td rowspan="1" colspan="1"><code>00 3C 00 00</code></td>
2416
2417</tr><tr><td rowspan="1" colspan="1"><code>00 3C 00 3F</code></td><td rowspan="1" colspan="1">UTF-16BE or big-endian ISO-10646-UCS-2
2418or other encoding with a 16-bit code unit in big-endian order and ASCII characters
2419encoded as ASCII values (the encoding declaration must be read to determine
2420which)</td></tr><tr><td rowspan="1" colspan="1"><code>3C 00 3F 00</code></td><td rowspan="1" colspan="1">UTF-16LE or little-endian
2421ISO-10646-UCS-2 or other encoding with a 16-bit code unit in little-endian
2422order and ASCII characters encoded as ASCII values (the encoding declaration
2423must be read to determine which)</td></tr><tr><td rowspan="1" colspan="1"><code>3C 3F 78 6D</code></td>
2424<td rowspan="1" colspan="1">UTF-8, ISO 646, ASCII, some part of ISO 8859, Shift-JIS, EUC, or any other
24257-bit, 8-bit, or mixed-width encoding which ensures that the characters of
2426ASCII have their normal positions, width, and values; the actual encoding
2427declaration must be read to detect which of these applies, but since all of
2428these encodings use the same bit patterns for the relevant ASCII characters,
2429the encoding declaration itself may be read reliably</td></tr><tr><td rowspan="1" colspan="1"><code>4C
24306F A7 94</code></td><td rowspan="1" colspan="1">EBCDIC (in some flavor; the full encoding declaration
2431must be read to tell which code page is in use)</td></tr><tr><td rowspan="1" colspan="1">Other</td>
2432<td rowspan="1" colspan="1">UTF-8 without an encoding declaration, or else the data stream is mislabeled
2433(lacking a required encoding declaration), corrupt, fragmentary, or enclosed
2434in a wrapper of some kind</td></tr></tbody></table></div>
2435<div class="diff-add"><div class="note"><p class="prefix"><b>Note:</b></p>
2436<p>In cases above which do not require reading the encoding declaration to
2437determine the encoding, section 4.3.3 still requires that the encoding declaration,
2438if present, be read and that the encoding name be checked to match the actual
2439encoding of the entity. Also, it is possible that new character encodings
2440will be invented that will make it necessary to use the encoding declaration
2441to determine the encoding, in cases where this is not required at present.</p>
2442</div></div>
2443<p>This level of autodetection is enough to read the XML encoding declaration
2444and parse the character-encoding identifier, which is still necessary to distinguish
2445the individual members of each family of encodings (e.g. to tell UTF-8 from
24468859, and the parts of 8859 from each other, or to distinguish the specific
2447EBCDIC code page in use, and so on).</p>
2448<p>Because the contents of the encoding declaration are restricted to <span class="diff-chg">characters from the ASCII repertoire (however encoded)</span>,
2449a processor can reliably read the entire encoding declaration as soon as it
2450has detected which family of encodings is in use. Since in practice, all widely
2451used character encodings fall into one of the categories above, the XML encoding
2452declaration allows reasonably reliable in-band labeling of character encodings,
2453even when external sources of information at the operating-system or transport-protocol
2454level are unreliable. <span class="diff-del">Note that since external parsed entities
2455in UTF-16 may begin with any character, this autodetection does not always
2456work. Also, </span><span class="diff-add">Character encodings such as UTF-7
2457that make overloaded usage of ASCII-valued bytes may fail to be reliably detected.</span></p>
2458<p>Once the processor has detected the character encoding in use, it can act
2459appropriately, whether by invoking a separate input routine for each case,
2460or by calling the proper conversion function on each character of input.</p>
2461<p>Like any self-labeling system, the XML encoding declaration will not work
2462if any software changes the entity's character set or encoding without updating
2463the encoding declaration. Implementors of character-encoding routines should
2464be careful to ensure the accuracy of the internal and external information
2465used to label the entity.</p>
2466</div>
2467<div class="div2">
2468<div class="diff-add">
2469<h3><a name="sec-guessing-with-ext-info"></a>F.2 Priorities in the Presence of External Encoding Information</h3></div>
2470<p>The second possible case occurs when the XML entity is accompanied by encoding
2471information, as in some file systems and some network protocols. When multiple
2472sources of information are available, their relative priority and the preferred
2473method of handling conflict should be specified as part of the higher-level
2474protocol used to deliver XML. <span class="diff-chg">In particular, please refer
2475to <a href="#rfc2376">[IETF RFC 2376]</a> or its successor, which defines the <code>text/xml</code>
2476and <code>application/xml</code> MIME types and provides some useful guidance.
2477In the interests of interoperability, however, the following rule is recommended.</span></p>
2478<ul>
2479<li><p>If an XML entity is in a file, the Byte-Order Mark and encoding declaration <span class="diff-del">PI </span>are used (if present) to determine the character encoding.<span class="diff-del"><a href="http://www.w3.org/XML/xml-19980210-errata#E74">[E74]</a>
2480All other heuristics and sources of information are solely for error recovery.</span></p>
2481</li>
2482</ul>
2483<div class="diff-del"><ul>
2484<li><p>If an XML entity is delivered with a MIME type of text/xml, then
2485the <code>charset</code> parameter on the MIME type determines the character
2486encoding method; all other heuristics and sources of information are solely
2487for error recovery.</p></li>
2488<li><p>If an XML entity is delivered with a MIME type of application/xml,
2489then the Byte-Order Mark and encoding-declaration PI are used (if present)
2490to determine the character encoding. All other heuristics and sources of information
2491are solely for error recovery.</p></li>
2492</ul></div>
2493<div class="diff-del"><p>These rules apply only in the absence of protocol-level documentation;
2494in particular, when the MIME types text/xml and application/xml are defined,
2495the recommendations of the relevant RFC will supersede these rules.</p></div>
2496</div>
2497</div>
2498<div class="div1">
2499
2500<h2><a name="sec-xml-wg"></a>G W3C XML Working Group (Non-Normative)</h2>
2501<p>This specification was prepared and approved for publication by the W3C
2502XML Working Group (WG). WG approval of this specification does not necessarily
2503imply that all WG members voted for its approval. The current and former members
2504of the XML WG are:</p>
2505<ul>
2506<li>Jon Bosak, Sun (<i>Chair</i>) 
2507</li>
2508<li>James Clark (<i>Technical Lead</i>) </li>
2509<li>Tim Bray, Textuality and Netscape
2510 (<i>XML Co-editor</i>) </li>
2511<li>Jean Paoli, Microsoft (<i>XML
2512Co-editor</i>) </li>
2513<li>C. M. Sperberg-McQueen, U. of Ill.
2514 (<i>XML Co-editor</i>) </li>
2515<li>Dan Connolly, W3C (<i>W3C Liaison</i>) 
2516</li>
2517<li>Paula Angerstein, Texcel</li>
2518<li>Steve DeRose, INSO</li>
2519<li>Dave Hollander, HP</li>
2520<li>Eliot Kimber, ISOGEN</li>
2521<li>Eve Maler, ArborText</li>
2522<li>Tom Magliery, NCSA</li>
2523<li>Murray Maloney<span class="diff-chg">, SoftQuad, Grif
2524SA, Muzmo and Veo Systems</span></li>
2525<li><span class="diff-chg">MURATA Makoto (FAMILY Given)</span>, Fuji
2526Xerox Information Systems</li>
2527<li>Joel Nava, Adobe</li>
2528<li>Conleth O'Connell, Vignette
2529</li>
2530<li>Peter Sharpe, SoftQuad</li>
2531<li>John Tigue, DataChannel</li>
2532</ul>
2533</div>
2534<div class="diff-add"><div class="div1">
2535
2536<h2><a name="sec-core-wg"></a>H W3C XML Core Group (Non-Normative)</h2>
2537<p>The second edition of this specification was prepared by the W3C XML Core
2538Working Group (WG). The members of the WG at the time of publication of this
2539edition were:</p>
2540<ul>
2541<li>Paula Angerstein, Vignette</li>
2542<li>Daniel Austin, Ask Jeeves</li>
2543<li>Tim Boland</li>
2544<li>Allen Brown, Microsoft</li>
2545<li>Dan Connolly, W3C (<i>Staff
2546Contact</i>) </li>
2547<li>John Cowan, Reuters Limited
2548</li>
2549<li>John Evdemon, XMLSolutions Corporation
2550</li>
2551<li>Paul Grosso, Arbortext (<i>Co-Chair</i>) 
2552</li>
2553<li>Arnaud Le Hors, IBM (<i>Co-Chair</i>) 
2554</li>
2555<li>Eve Maler, Sun Microsystems
2556 (<i>Second Edition Editor</i>) </li>
2557<li>Jonathan Marsh, Microsoft</li>
2558<li>MURATA Makoto (FAMILY Given), IBM
2559</li>
2560<li>Mark Needleman, Data Research Associates
2561</li>
2562<li>David Orchard, Jamcracker</li>
2563<li>Lew Shannon, NCR</li>
2564<li>Richard Tobin, University of Edinburgh
2565</li>
2566<li>Daniel Veillard, W3C</li>
2567<li>Dan Vint, Lexica</li>
2568<li>Norman Walsh, Sun Microsystems
2569</li>
2570<li>Fran�ois Yergeau, Alis Technologies
2571 (<i>Errata List Editor</i>) </li>
2572<li>Kongyi Zhou, Oracle</li>
2573</ul>
2574</div></div>
2575<div class="diff-add"><div class="div1">
2576
2577<h2><a name="id2683713"></a>I Production Notes (Non-Normative)</h2>
2578<p>This Second Edition was encoded in the <a href="http://www.w3.org/XML/1998/06/xmlspec-v21.dtd">XMLspec
2579DTD</a> (which has <a href="http://www.w3.org/XML/1998/06/xmlspec-report-v21.htm">documentation</a>
2580available). The HTML versions were produced with a combination of the <a href="http://www.w3.org/XML/1998/06/xmlspec.xsl">xmlspec.xsl</a>, <a href="http://www.w3.org/XML/1998/06/diffspec.xsl">diffspec.xsl</a>,
2581and <a href="http://www.w3.org/XML/1998/06/REC-xml-2e.xsl">REC-xml-2e.xsl</a>
2582XSLT stylesheets.  The PDF version was produced with the <a href="http://www.tdb.uu.se/~jan/html2ps.html">html2ps</a>
2583facility and a distiller program.</p>
2584</div></div>
2585</div></body></html>
2586