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