Debian Codegraph @

test/grammar/xml11.html

raw
1 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
3 <head>
4 <title>Extensible Markup Language (XML) 1.1 (Second Edition)</title>
5 <style type="text/css">
6 code {
7 font-family: monospace;
8 }
9
10 div.constraint,
11 div.issue,
12 div.note,
13 div.notice {
14 margin-left: 2em;
15 }
16
17 ol.enumar {
18 list-style-type: decimal;
19 }
20 ol.enumla {
21 list-style-type: lower-alpha;
22 }
23 ol.enumlr {
24 list-style-type: lower-roman;
25 }
26 ol.enumua {
27 list-style-type: upper-alpha;
28 }
29 ol.enumur {
30 list-style-type: upper-roman;
31 }
32
33 div.exampleInner pre {
34 margin-left: 1em;
35 margin-top: 0em;
36 margin-bottom: 0em;
37 }
38 div.exampleOuter {
39 border: 4px double gray;
40 margin: 0em;
41 padding: 0em;
42 }
43 div.exampleInner {
44 background-color: #d5dee3;
45 border-top-width: 4px;
46 border-top-style: double;
47 border-top-color: #d3d3d3;
48 border-bottom-width: 4px;
49 border-bottom-style: double;
50 border-bottom-color: #d3d3d3;
51 padding: 4px;
52 margin: 0em;
53 }
54 div.exampleWrapper {
55 margin: 4px;
56 }
57 div.exampleHeader {
58 font-weight: bold;
59 margin: 4px;
60 }
61
62 em.rfc2119 {
63 text-transform: lowercase;
64 font-variant: small-caps;
65 font-style: normal;
66 }
67 </style>
68 <link
69 rel="stylesheet"
70 type="text/css"
71 href="http://www.w3.org/StyleSheets/TR/W3C-REC.css"
72 />
73 </head>
74 <body>
75 <div class="head">
76 <p>
77 <a href="http://www.w3.org/"
78 ><img
79 src="http://www.w3.org/Icons/w3c_home"
80 alt="W3C"
81 height="48"
82 width="72"
83 /></a>
84 </p>
85 <h1>
86 <a name="title" id="title" />Extensible Markup Language (XML) 1.1
87 (Second Edition)
88 </h1>
89 <h2>
90 <a name="w3c-doctype" id="w3c-doctype" />W3C Recommendation 16 August
91 2006, edited in place 29 September 2006
92 </h2>
93 <dl>
94 <dt>This version:</dt>
95 <dd>
96 <a href="http://www.w3.org/TR/2006/REC-xml11-20060816"
97 >http://www.w3.org/TR/2006/REC-xml11-20060816</a
98 >
99 </dd>
100 <dt>Latest version:</dt>
101 <dd>
102 <a href="http://www.w3.org/TR/xml11">http://www.w3.org/TR/xml11</a>
103 </dd>
104 <dt>Previous version:</dt>
105 <dd>
106 <a href="http://www.w3.org/TR/2006/PER-xml11-20060614"
107 >http://www.w3.org/TR/2006/PER-xml11-20060614</a
108 >
109 </dd>
110 <dt>Editors:</dt>
111 <dd>
112 Tim Bray, Textuality and Netscape
113 <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
114 </dd>
115 <dd>
116 Jean Paoli, Microsoft
117 <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
118 </dd>
119 <dd>
120 C. M. Sperberg-McQueen, W3C
121 <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
122 </dd>
123 <dd>
124 Eve Maler, Sun Microsystems, Inc.
125 <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
126 </dd>
127 <dd>François Yergeau</dd>
128 <dd>
129 John Cowan <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
130 </dd>
131 </dl>
132 <p>
133 Please refer to the
134 <a href="http://www.w3.org/XML/xml-V11-2e-errata"
135 ><strong>errata</strong></a
136 >
137 for this document, which may include some normative corrections.
138 </p>
139 <p>
140 The
141 <a href="http://www.w3.org/XML/xml-V11-1e-errata">previous errata</a>
142 for this document, are also available.
143 </p>
144 <p>
145 See also
146 <a
147 href="http://www.w3.org/2003/03/Translations/byTechnology?technology=xml11"
148 ><strong>translations</strong></a
149 >.
150 </p>
151 <p>
152 This document is also available in these non-normative formats:
153 <a href="REC-xml11-20060816.xml">XML</a> and&nbsp;<a
154 href="REC-xml11-20060816-review.html"
155 >XHTML with color-coded revision indicators</a
156 >.
157 </p>
158 <p class="copyright">
159 <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
160 >Copyright</a
161 >&nbsp;©&nbsp;2006&nbsp;<a href="http://www.w3.org/"
162 ><acronym title="World Wide Web Consortium">W3C</acronym></a
163 ><sup>®</sup> (<a href="http://www.csail.mit.edu/"
164 ><acronym title="Massachusetts Institute of Technology"
165 >MIT</acronym
166 ></a
167 >,
168 <a href="http://www.ercim.org/"
169 ><acronym
170 title="European Research Consortium for Informatics and Mathematics"
171 >ERCIM</acronym
172 ></a
173 >, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
174 <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer"
175 >liability</a
176 >,
177 <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks"
178 >trademark</a
179 >
180 and
181 <a href="http://www.w3.org/Consortium/Legal/copyright-documents"
182 >document use</a
183 >
184 rules apply.
185 </p>
186 </div>
187 <hr />
188 <div>
189 <h2><a name="abstract" id="abstract" />Abstract</h2>
190 <p>
191 The Extensible Markup Language (XML) is a subset of SGML that is
192 completely described in this document. Its goal is to enable generic
193 SGML to be served, received, and processed on the Web in the way that is
194 now possible with HTML. XML has been designed for ease of implementation
195 and for interoperability with both SGML and HTML.
196 </p>
197 </div>
198 <div>
199 <h2><a name="status" id="status" />Status of this Document</h2>
200 <p>
201 <em
202 >This section describes the status of this document at the time of its
203 publication. Other documents may supersede this document. A list of
204 current W3C publications and the latest revision of this technical
205 report can be found in the
206 <a href="http://www.w3.org/TR/">W3C technical reports index</a> at
207 http://www.w3.org/TR/.</em
208 >
209 </p>
210 <p>
211 This document specifies a syntax created by subsetting an existing,
212 widely used international text processing standard (Standard Generalized
213 Markup Language, ISO 8879:1986(E) as amended and corrected) for use on
214 the World Wide Web. It is a product of the
215 <a href="http://www.w3.org/XML/Core/">XML Core Working Group</a> as part
216 of the <a href="http://www.w3.org/XML/Activity">XML Activity</a>.
217 </p>
218 <p>
219 On 29 September 2006 this document was edited in place to remove a
220 number of spurious and potentially misleading spaces.
221 </p>
222 <p>
223 The English version of this specification is the only normative version.
224 However, for translations of this document, see
225 <a
226 href="http://www.w3.org/2003/03/Translations/byTechnology?technology=xml11"
227 >http://www.w3.org/2003/03/Translations/byTechnology?technology=xml11</a
228 >.
229 </p>
230 <p>
231 This document is a
232 <a href="http://www.w3.org/2005/10/Process-20051014/tr.html#q74"
233 >W3C Recommendation</a
234 >. This second edition is <em>not</em> a new version of XML. As a
235 convenience to readers, it incorporates the changes dictated by the
236 accumulated errata (available at
237 <a href="http://www.w3.org/XML/xml-V11-1e-errata"
238 >http://www.w3.org/XML/xml-V11-1e-errata</a
239 >) to the
240 <a href="http://www.w3.org/TR/2004/REC-xml11-20040204/"
241 >First Edition of XML 1.1, dated 4 February 2004</a
242 >. In addition, the markup introduced to clarify when prescriptive
243 keywords are used in the formal sense defined in
244 <a href="#rfc2119">[IETF RFC 2119]</a>, has been modified to better
245 match the intent of <a href="#rfc2119">[IETF RFC 2119]</a>. This edition
246 supersedes the previous
247 <a href="http://www.w3.org/TR/2004/REC-xml11-20040204"
248 >W3C Recommendation of 4 February 2004</a
249 >.
250 </p>
251 <p>
252 Please report errors in this document to the public
253 <a href="mailto:[email protected]">[email protected]</a> mailing list;
254 <a href="http://lists.w3.org/Archives/Public/xml-editor/">archives</a>
255 are available. For the convenience of readers, an
256 <a href="REC-xml11-20060816-review.html"
257 >XHTML version with color-coded revision indicators</a
258 >
259 is also provided; this version highlights each change due to an erratum
260 published in the
261 <a href="http://www.w3.org/XML/xml-V11-1e-errata">errata list</a>,
262 together with a link to the particular erratum in that list. Most of the
263 errata in the list provide a rationale for the change. The errata list
264 for this second edition is available at
265 <a href="http://www.w3.org/XML/xml-V11-2e-errata"
266 >http://www.w3.org/XML/xml-V11-2e-errata</a
267 >.
268 </p>
269 <p>
270 An implementation report is available at
271 <a href="http://www.w3.org/XML/2006/06/xml11-2e-implementation.html"
272 >http://www.w3.org/XML/2006/06/xml11-2e-implementation.html</a
273 >. A <a href="http://www.w3.org/XML/Test/">Test Suite</a> is maintained
274 to help assessing conformance to this specification.
275 </p>
276 <p>
277 This document has been reviewed by W3C Members, by software developers,
278 and by other W3C groups and interested parties, and is endorsed by the
279 Director as a W3C Recommendation. It is a stable document and may be
280 used as reference material or cited from another document. W3C's role in
281 making the Recommendation is to draw attention to the specification and
282 to promote its widespread deployment. This enhances the functionality
283 and interoperability of the Web.
284 </p>
285 <p>
286 This document is governed by the
287 <a href="http://www.w3.org/TR/2002/NOTE-patent-practice-20020124"
288 >24 January 2002 CPP</a
289 >
290 as amended by the
291 <a href="http://www.w3.org/2004/02/05-pp-transition"
292 >W3C Patent Policy Transition Procedure</a
293 >. W3C maintains a
294 <a
295 href="http://www.w3.org/2002/08/xmlcore-IPR-statements"
296 rel="disclosure"
297 >public list of any patent disclosures</a
298 >
299 made in connection with the deliverables of the group; that page also
300 includes instructions for disclosing a patent. An individual who has
301 actual knowledge of a patent which the individual believes contains
302 <a
303 href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential"
304 >Essential Claim(s)</a
305 >
306 must disclose the information in accordance with
307 <a
308 href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure"
309 >section 6 of the W3C Patent Policy</a
310 >.
311 </p>
312 </div>
313 <div class="toc">
314 <h2><a name="contents" id="contents" />Table of Contents</h2>
315 <p class="toc">
316 1 <a href="#sec-intro">Introduction</a><br />
317 &nbsp;&nbsp;&nbsp;&nbsp;1.1
318 <a href="#sec-origin-goals">Origin and Goals</a><br />
319 &nbsp;&nbsp;&nbsp;&nbsp;1.2 <a href="#sec-terminology">Terminology</a
320 ><br />
321 &nbsp;&nbsp;&nbsp;&nbsp;1.3
322 <a href="#sec-xml11">Rationale and list of changes for XML 1.1</a><br />
323 2 <a href="#sec-documents">Documents</a><br />
324 &nbsp;&nbsp;&nbsp;&nbsp;2.1
325 <a href="#sec-well-formed">Well-Formed XML Documents</a><br />
326 &nbsp;&nbsp;&nbsp;&nbsp;2.2 <a href="#charsets">Characters</a><br />
327 &nbsp;&nbsp;&nbsp;&nbsp;2.3
328 <a href="#sec-common-syn">Common Syntactic Constructs</a><br />
329 &nbsp;&nbsp;&nbsp;&nbsp;2.4
330 <a href="#syntax">Character Data and Markup</a><br />
331 &nbsp;&nbsp;&nbsp;&nbsp;2.5 <a href="#sec-comments">Comments</a><br />
332 &nbsp;&nbsp;&nbsp;&nbsp;2.6 <a href="#sec-pi">Processing Instructions</a
333 ><br />
334 &nbsp;&nbsp;&nbsp;&nbsp;2.7 <a href="#sec-cdata-sect">CDATA Sections</a
335 ><br />
336 &nbsp;&nbsp;&nbsp;&nbsp;2.8
337 <a href="#sec-prolog-dtd">Prolog and Document Type Declaration</a><br />
338 &nbsp;&nbsp;&nbsp;&nbsp;2.9
339 <a href="#sec-rmd">Standalone Document Declaration</a><br />
340 &nbsp;&nbsp;&nbsp;&nbsp;2.10
341 <a href="#sec-white-space">White Space Handling</a><br />
342 &nbsp;&nbsp;&nbsp;&nbsp;2.11
343 <a href="#sec-line-ends">End-of-Line Handling</a><br />
344 &nbsp;&nbsp;&nbsp;&nbsp;2.12
345 <a href="#sec-lang-tag">Language Identification</a><br />
346 &nbsp;&nbsp;&nbsp;&nbsp;2.13
347 <a href="#sec-normalization-checking">Normalization Checking</a><br />
348 3 <a href="#sec-logical-struct">Logical Structures</a><br />
349 &nbsp;&nbsp;&nbsp;&nbsp;3.1
350 <a href="#sec-starttags">Start-Tags, End-Tags, and Empty-Element Tags</a
351 ><br />
352 &nbsp;&nbsp;&nbsp;&nbsp;3.2
353 <a href="#elemdecls">Element Type Declarations</a><br />
354 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.2.1
355 <a href="#sec-element-content">Element Content</a><br />
356 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.2.2
357 <a href="#sec-mixed-content">Mixed Content</a><br />
358 &nbsp;&nbsp;&nbsp;&nbsp;3.3
359 <a href="#attdecls">Attribute-List Declarations</a><br />
360 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.3.1
361 <a href="#sec-attribute-types">Attribute Types</a><br />
362 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.3.2
363 <a href="#sec-attr-defaults">Attribute Defaults</a><br />
364 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3.3.3
365 <a href="#AVNormalize">Attribute-Value Normalization</a><br />
366 &nbsp;&nbsp;&nbsp;&nbsp;3.4
367 <a href="#sec-condition-sect">Conditional Sections</a><br />
368 4 <a href="#sec-physical-struct">Physical Structures</a><br />
369 &nbsp;&nbsp;&nbsp;&nbsp;4.1
370 <a href="#sec-references">Character and Entity References</a><br />
371 &nbsp;&nbsp;&nbsp;&nbsp;4.2
372 <a href="#sec-entity-decl">Entity Declarations</a><br />
373 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.2.1
374 <a href="#sec-internal-ent">Internal Entities</a><br />
375 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.2.2
376 <a href="#sec-external-ent">External Entities</a><br />
377 &nbsp;&nbsp;&nbsp;&nbsp;4.3 <a href="#TextEntities">Parsed Entities</a
378 ><br />
379 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.3.1
380 <a href="#sec-TextDecl">The Text Declaration</a><br />
381 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.3.2
382 <a href="#wf-entities">Well-Formed Parsed Entities</a><br />
383 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.3.3
384 <a href="#charencoding">Character Encoding in Entities</a><br />
385 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.3.4
386 <a href="#sec-version-info">Version Information in Entities</a><br />
387 &nbsp;&nbsp;&nbsp;&nbsp;4.4
388 <a href="#entproc">XML Processor Treatment of Entities and References</a
389 ><br />
390 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.1
391 <a href="#not-recognized">Not Recognized</a><br />
392 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.2
393 <a href="#included">Included</a><br />
394 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.3
395 <a href="#include-if-valid">Included If Validating</a><br />
396 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.4
397 <a href="#forbidden">Forbidden</a><br />
398 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.5
399 <a href="#inliteral">Included in Literal</a><br />
400 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.6
401 <a href="#notify">Notify</a><br />
402 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.7
403 <a href="#bypass">Bypassed</a><br />
404 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.8
405 <a href="#as-PE">Included as PE</a><br />
406 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4.4.9
407 <a href="#error">Error</a><br />
408 &nbsp;&nbsp;&nbsp;&nbsp;4.5
409 <a href="#intern-replacement">Construction of Entity Replacement Text</a
410 ><br />
411 &nbsp;&nbsp;&nbsp;&nbsp;4.6
412 <a href="#sec-predefined-ent">Predefined Entities</a><br />
413 &nbsp;&nbsp;&nbsp;&nbsp;4.7
414 <a href="#Notations">Notation Declarations</a><br />
415 &nbsp;&nbsp;&nbsp;&nbsp;4.8 <a href="#sec-doc-entity">Document Entity</a
416 ><br />
417 5 <a href="#sec-conformance">Conformance</a><br />
418 &nbsp;&nbsp;&nbsp;&nbsp;5.1
419 <a href="#proc-types">Validating and Non-Validating Processors</a><br />
420 &nbsp;&nbsp;&nbsp;&nbsp;5.2
421 <a href="#safe-behavior">Using XML Processors</a><br />
422 6 <a href="#sec-notation">Notation</a><br />
423 </p>
424 <h3><a name="appendices" id="appendices" />Appendices</h3>
425 <p class="toc">
426 A <a href="#sec-bibliography">References</a><br />
427 &nbsp;&nbsp;&nbsp;&nbsp;A.1
428 <a href="#sec-existing-stds">Normative References</a><br />
429 &nbsp;&nbsp;&nbsp;&nbsp;A.2 <a href="#null">Other References</a><br />
430 B <a href="#sec-CharNorm">Definitions for Character Normalization</a
431 ><br />
432 C
433 <a href="#sec-entexpand"
434 >Expansion of Entity and Character References</a
435 >
436 (Non-Normative)<br />
437 D
438 <a href="#determinism">Deterministic Content Models</a>
439 (Non-Normative)<br />
440 E
441 <a href="#sec-guessing">Autodetection of Character Encodings</a>
442 (Non-Normative)<br />
443 &nbsp;&nbsp;&nbsp;&nbsp;E.1
444 <a href="#sec-guessing-no-ext-info"
445 >Detection Without External Encoding Information</a
446 ><br />
447 &nbsp;&nbsp;&nbsp;&nbsp;E.2
448 <a href="#sec-guessing-with-ext-info"
449 >Priorities in the Presence of External Encoding Information</a
450 ><br />
451 F <a href="#sec-xml-wg">W3C XML Working Group</a> (Non-Normative)<br />
452 G
453 <a href="#sec-core-wg">W3C XML Core Working Group</a>
454 (Non-Normative)<br />
455 H <a href="#prod-notes">Production Notes</a> (Non-Normative)<br />
456 I
457 <a href="#sec-suggested-names">Suggestions for XML Names</a>
458 (Non-Normative)<br />
459 </p>
460 </div>
461 <hr />
462 <div class="body">
463 <div class="div1">
464 <h2><a name="sec-intro" id="sec-intro" />1 Introduction</h2>
465 <p>
466 Extensible Markup Language, abbreviated XML, describes a class of data
467 objects called
468 <a title="XML Document" href="#dt-xml-doc">XML documents</a> and
469 partially describes the behavior of computer programs which process
470 them. XML is an application profile or restricted form of SGML, the
471 Standard Generalized Markup Language
472 <a href="#ISO8879">[ISO 8879]</a>. By construction, XML documents are
473 conforming SGML documents.
474 </p>
475 <p>
476 XML documents are made up of storage units called
477 <a title="Entity" href="#dt-entity">entities</a>, which contain either
478 parsed or unparsed data. Parsed data is made up of
479 <a title="Character" href="#dt-character">characters</a>, some of
480 which form
481 <a title="Character Data" href="#dt-chardata">character data</a>, and
482 some of which form <a title="Markup" href="#dt-markup">markup</a>.
483 Markup encodes a description of the document's storage layout and
484 logical structure. XML provides a mechanism to impose constraints on
485 the storage layout and logical structure.
486 </p>
487 <p>
488 [<a name="dt-xml-proc" id="dt-xml-proc" title="XML Processor"
489 >Definition</a
490 >: A software module called an <b>XML processor</b> is used to read
491 XML documents and provide access to their content and structure.] [<a
492 name="dt-app"
493 id="dt-app"
494 title="Application"
495 >Definition</a
496 >: It is assumed that an XML processor is doing its work on behalf of
497 another module, called the <b>application</b>.] This specification
498 describes the required behavior of an XML processor in terms of how it
499 must read XML data and the information it must provide to the
500 application.
501 </p>
502 <div class="div2">
503 <h3>
504 <a name="sec-origin-goals" id="sec-origin-goals" />1.1 Origin and
505 Goals
506 </h3>
507 <p>
508 XML was developed by an XML Working Group (originally known as the
509 SGML Editorial Review Board) formed under the auspices of the World
510 Wide Web Consortium (W3C) in 1996. It was chaired by Jon Bosak of
511 Sun Microsystems with the active participation of an XML Special
512 Interest Group (previously known as the SGML Working Group) also
513 organized by the W3C. The membership of the XML Working Group is
514 given in an appendix. Dan Connolly served as the Working Group's
515 contact with the W3C.
516 </p>
517 <p>The design goals for XML are:</p>
518 <ol class="enumar">
519 <li>
520 <p>XML shall be straightforwardly usable over the Internet.</p>
521 </li>
522 <li><p>XML shall support a wide variety of applications.</p></li>
523 <li><p>XML shall be compatible with SGML.</p></li>
524 <li>
525 <p>
526 It shall be easy to write programs which process XML documents.
527 </p>
528 </li>
529 <li>
530 <p>
531 The number of optional features in XML is to be kept to the
532 absolute minimum, ideally zero.
533 </p>
534 </li>
535 <li>
536 <p>XML documents should be human-legible and reasonably clear.</p>
537 </li>
538 <li><p>The XML design should be prepared quickly.</p></li>
539 <li><p>The design of XML shall be formal and concise.</p></li>
540 <li><p>XML documents shall be easy to create.</p></li>
541 <li><p>Terseness in XML markup is of minimal importance.</p></li>
542 </ol>
543 <p>
544 This specification, together with associated standards (Unicode
545 <a href="#Unicode">[Unicode]</a> and ISO/IEC 10646
546 <a href="#ISO10646">[ISO/IEC 10646]</a> for characters, Internet RFC
547 3066 <a href="#RFC1766">[IETF RFC 3066]</a> for language
548 identification tags, ISO 639 <a href="#ISO639">[ISO 639]</a> for
549 language name codes, and ISO 3166
550 <a href="#ISO3166">[ISO 3166]</a> for country name codes), provides
551 all the information necessary to understand XML Version 1.1 and
552 construct computer programs to process it.
553 </p>
554 <p>
555 This version of the XML specification may be distributed freely, as
556 long as all text and legal notices remain intact.
557 </p>
558 </div>
559 <div class="div2">
560 <h3>
561 <a name="sec-terminology" id="sec-terminology" />1.2 Terminology
562 </h3>
563 <p>
564 The terminology used to describe XML documents is defined in the
565 body of this specification. The key words
566 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>,
567 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST NOT</em
568 >,
569 <em class="rfc2119" title="Keyword in RFC 2119 context">REQUIRED</em
570 >,
571 <em class="rfc2119" title="Keyword in RFC 2119 context">SHALL</em>,
572 <em class="rfc2119" title="Keyword in RFC 2119 context"
573 >SHALL NOT</em
574 >,
575 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>,
576 <em class="rfc2119" title="Keyword in RFC 2119 context"
577 >SHOULD NOT</em
578 >,
579 <em class="rfc2119" title="Keyword in RFC 2119 context"
580 >RECOMMENDED</em
581 >, <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>,
582 and
583 <em class="rfc2119" title="Keyword in RFC 2119 context">OPTIONAL</em
584 >, when
585 <em class="rfc2119" title="Keyword in RFC 2119 context"
586 >EMPHASIZED</em
587 >, are to be interpreted as described in
588 <a href="#rfc2119">[IETF RFC 2119]</a>. In addition, the terms
589 defined in the following list are used in building those definitions
590 and in describing the actions of an XML processor:
591 </p>
592 <dl>
593 <dt class="label">error</dt>
594 <dd>
595 <p>
596 [<a name="dt-error" id="dt-error" title="Error">Definition</a>:
597 A violation of the rules of this specification; results are
598 undefined. Unless otherwise specified, failure to observe a
599 prescription of this specification indicated by one of the
600 keywords
601 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em
602 >,
603 <em class="rfc2119" title="Keyword in RFC 2119 context"
604 >REQUIRED</em
605 >,
606 <em class="rfc2119" title="Keyword in RFC 2119 context"
607 >MUST NOT</em
608 >,
609 <em class="rfc2119" title="Keyword in RFC 2119 context"
610 >SHALL</em
611 >
612 and
613 <em class="rfc2119" title="Keyword in RFC 2119 context"
614 >SHALL NOT</em
615 >
616 is an error. Conforming software
617 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
618 detect and report an error and
619 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
620 recover from it.]
621 </p>
622 </dd>
623 <dt class="label">fatal error</dt>
624 <dd>
625 <p>
626 [<a name="dt-fatal" id="dt-fatal" title="Fatal Error"
627 >Definition</a
628 >: An error which a conforming
629 <a title="XML Processor" href="#dt-xml-proc">XML processor</a>
630 <em class="rfc2119" title="Keyword in RFC 2119 context"
631 >MUST</em
632 >
633 detect and report to the application. After encountering a fatal
634 error, the processor
635 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
636 continue processing the data to search for further errors and
637 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
638 report such errors to the application. In order to support
639 correction of errors, the processor
640 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
641 make unprocessed data from the document (with intermingled
642 character data and markup) available to the application. Once a
643 fatal error is detected, however, the processor
644 <em class="rfc2119" title="Keyword in RFC 2119 context"
645 >MUST NOT</em
646 >
647 continue normal processing (i.e., it
648 <em class="rfc2119" title="Keyword in RFC 2119 context"
649 >MUST NOT</em
650 >
651 continue to pass character data and information about the
652 document's logical structure to the application in the normal
653 way).]
654 </p>
655 </dd>
656 <dt class="label">at user option</dt>
657 <dd>
658 <p>
659 [<a
660 name="dt-atuseroption"
661 id="dt-atuseroption"
662 title="At user option"
663 >Definition</a
664 >: Conforming software
665 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
666 or
667 <em class="rfc2119" title="Keyword in RFC 2119 context"
668 >MUST</em
669 >
670 (depending on the modal verb in the sentence) behave as
671 described; if it does, it
672 <em class="rfc2119" title="Keyword in RFC 2119 context"
673 >MUST</em
674 >
675 provide users a means to enable or disable the behavior
676 described.]
677 </p>
678 </dd>
679 <dt class="label">validity constraint</dt>
680 <dd>
681 <p>
682 [<a name="dt-vc" id="dt-vc" title="Validity constraint"
683 >Definition</a
684 >: A rule which applies to all
685 <a title="Validity" href="#dt-valid">valid</a> XML documents.
686 Violations of validity constraints are errors; they
687 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em
688 >, at user option, be reported by
689 <a title="Validating Processor" href="#dt-validating"
690 >validating XML processors</a
691 >.]
692 </p>
693 </dd>
694 <dt class="label">well-formedness constraint</dt>
695 <dd>
696 <p>
697 [<a name="dt-wfc" id="dt-wfc" title="Well-formedness constraint"
698 >Definition</a
699 >: A rule which applies to all
700 <a title="Well-Formed" href="#dt-wellformed">well-formed</a> XML
701 documents. Violations of well-formedness constraints are
702 <a title="Fatal Error" href="#dt-fatal">fatal errors</a>.]
703 </p>
704 </dd>
705 <dt class="label">match</dt>
706 <dd>
707 <p>
708 [<a name="dt-match" id="dt-match" title="match">Definition</a>:
709 (Of strings or names:) Two strings or names being compared
710 <span>are</span> identical. Characters with multiple possible
711 representations in Unicode (e.g. characters with both
712 precomposed and base+diacritic forms) match only if they have
713 the same representation in both strings. No case folding is
714 performed. (Of strings and rules in the grammar:) A string
715 matches a grammatical production if it belongs to the language
716 generated by that production. (Of content and content models:)
717 An element matches its declaration when it conforms in the
718 fashion described in the constraint
719 <b>[VC: <a href="#elementvalid">Element Valid</a>]</b>.]
720 </p>
721 </dd>
722 <dt class="label">for compatibility</dt>
723 <dd>
724 <p>
725 [<a name="dt-compat" id="dt-compat" title="For Compatibility"
726 >Definition</a
727 >: Marks a sentence describing a feature of XML included solely
728 to ensure that XML remains compatible with SGML.]
729 </p>
730 </dd>
731 <dt class="label">for interoperability</dt>
732 <dd>
733 <p>
734 [<a
735 name="dt-interop"
736 id="dt-interop"
737 title="For interoperability"
738 >Definition</a
739 >: Marks a sentence describing a non-binding recommendation
740 included to increase the chances that XML documents can be
741 processed by the existing installed base of SGML processors
742 which predate the WebSGML Adaptations Annex to ISO 8879.]
743 </p>
744 </dd>
745 </dl>
746 <p></p>
747 </div>
748 <div class="div2">
749 <h3>
750 <a name="sec-xml11" id="sec-xml11" />1.3 Rationale and list of
751 changes for XML 1.1
752 </h3>
753 <p>
754 The W3C's XML 1.0 Recommendation was first issued in 1998, and
755 despite the issuance of many errata culminating in a Third Edition
756 of 2004, has remained (by intention) unchanged with respect to what
757 is well-formed XML and what is not. This stability has been
758 extremely useful for interoperability. However, the Unicode Standard
759 on which XML 1.0 relies for character specifications has not
760 remained static, evolving from version 2.0 to version 4.0 and
761 beyond. Characters not present in Unicode 2.0 may already be used in
762 XML 1.0 character data. However, they are not allowed in XML names
763 such as element type names, attribute names, enumerated attribute
764 values, processing instruction targets, and so on. In addition, some
765 characters that should have been permitted in XML names were not,
766 due to oversights and inconsistencies in Unicode 2.0.
767 </p>
768 <p>
769 The overall philosophy of names has changed since XML 1.0. Whereas
770 XML 1.0 provided a rigid definition of names, wherein everything
771 that was not permitted was forbidden, XML 1.1 names are designed so
772 that everything that is not forbidden (for a specific reason) is
773 permitted. Since Unicode will continue to grow past version 4.0,
774 further changes to XML can be avoided by allowing almost any
775 character, including those not yet assigned, in names.
776 </p>
777 <p>
778 In addition, XML 1.0 attempts to adapt to the line-end conventions
779 of various modern operating systems, but discriminates against the
780 conventions used on IBM and IBM-compatible mainframes. As a result,
781 XML documents on mainframes are not plain text files according to
782 the local conventions. XML 1.0 documents generated on mainframes
783 must either violate the local line-end conventions, or employ
784 otherwise unnecessary translation phases before parsing and after
785 generation. Allowing straightforward interoperability is
786 particularly important when data stores are shared between mainframe
787 and non-mainframe systems (as opposed to being copied from one to
788 the other). Therefore XML 1.1 adds NEL (#x85) to the list of
789 line-end characters. For completeness, the Unicode line separator
790 character, #x2028, is also supported.
791 </p>
792 <p>
793 Finally, there is considerable demand to define a standard
794 representation of arbitrary Unicode characters in XML documents.
795 Therefore, XML 1.1 allows the use of character references to the
796 control characters #x1 through #x1F, most of which are forbidden in
797 XML 1.0. For reasons of robustness, however, these characters still
798 cannot be used directly in documents. In order to improve the
799 robustness of character encoding detection, the additional control
800 characters #x7F through #x9F, which were freely allowed in XML 1.0
801 documents, now must also appear only as character references.
802 (Whitespace characters are of course exempt.) The minor sacrifice of
803 backward compatibility is considered not significant. Due to
804 potential problems with APIs, #x0 is still forbidden both directly
805 and as a character reference.
806 </p>
807 <p>
808 Finally, XML 1.1 defines a set of constraints called "full
809 normalization" on XML documents, which document creators
810 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
811 adhere to, and document processors
812 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
813 verify. Using fully normalized documents ensures that identity
814 comparisons of names, attribute values, and character content can be
815 made correctly by simple binary comparison of Unicode strings.
816 </p>
817 <p>
818 A new XML version, rather than a set of errata to XML 1.0, is being
819 created because the changes affect the definition of well-formed
820 documents. XML 1.0 processors must continue to reject documents that
821 contain new characters in XML names, new line-end conventions, and
822 references to control characters. The distinction between XML 1.0
823 and XML 1.1 documents is indicated by the version number information
824 in the XML declaration at the start of each document.
825 </p>
826 </div>
827 </div>
828 <div class="div1">
829 <h2><a name="sec-documents" id="sec-documents" />2 Documents</h2>
830 <p>
831 [<a name="dt-xml-doc" id="dt-xml-doc" title="XML Document"
832 >Definition</a
833 >: A data object is an <b>XML document</b> if it is
834 <a title="Well-Formed" href="#dt-wellformed">well-formed</a>, as
835 defined in this specification.
836 <span>In addition, the XML document is</span>
837 <a title="Validity" href="#dt-valid">valid</a> if it meets certain
838 further constraints.]
839 </p>
840 <p>
841 Each XML document has both a logical and a physical structure.
842 Physically, the document is composed of units called
843 <a title="Entity" href="#dt-entity">entities</a>. An entity
844 <span>may</span>
845 <a title="Entity Reference" href="#dt-entref">refer</a> to other
846 entities to cause their inclusion in the document. A document begins
847 in a "root" or
848 <a title="Document Entity" href="#dt-docent">document entity</a>.
849 Logically, the document is composed of declarations, elements,
850 comments, character references, and processing instructions, all of
851 which are indicated in the document by explicit markup. The logical
852 and physical structures
853 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> nest
854 properly, as described in
855 <a href="#wf-entities"><b>4.3.2 Well-Formed Parsed Entities</b></a
856 >.
857 </p>
858 <div class="div2">
859 <h3>
860 <a name="sec-well-formed" id="sec-well-formed" />2.1 Well-Formed XML
861 Documents
862 </h3>
863 <p>
864 [<a name="dt-wellformed" id="dt-wellformed" title="Well-Formed"
865 >Definition</a
866 >: A textual object is a <b>well-formed</b>
867 XML document if:]
868 </p>
869 <ol class="enumar">
870 <li>
871 <p>
872 Taken as a whole, it matches the production labeled
873 <a href="#NT-document">document</a>.
874 </p>
875 </li>
876 <li>
877 <p>
878 It meets all the well-formedness constraints given in this
879 specification.
880 </p>
881 </li>
882 <li>
883 <p>
884 Each of the
885 <a title="Text Entity" href="#dt-parsedent">parsed entities</a>
886 which is referenced directly or indirectly within the document
887 is <a title="Well-Formed" href="#dt-wellformed">well-formed</a>.
888 </p>
889 </li>
890 </ol>
891 <h5><a name="document" id="document" />Document</h5>
892 <table class="scrap" summary="Scrap">
893 <tbody>
894 <tr valign="baseline">
895 <td>
896 <a name="NT-document" id="NT-document" />[1]&nbsp;&nbsp;&nbsp;
897 </td>
898 <td><code>document</code></td>
899 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
900 <td>
901 <code>
902 <span> (</span>
903 <a href="#NT-prolog">prolog</a>
904 <a href="#NT-element">element</a>
905 <a href="#NT-Misc">Misc</a>*<span> )</span> <span> </span>-
906 <span> (</span> <a href="#NT-Char">Char</a>*
907 <a href="#NT-RestrictedChar">RestrictedChar</a>
908 <span> </span>
909 <a href="#NT-Char">Char</a>*<span> )</span>
910 </code>
911 </td>
912 </tr>
913 </tbody>
914 </table>
915 <p>
916 Matching the <a href="#NT-document">document</a> production implies
917 that:
918 </p>
919 <ol class="enumar">
920 <li>
921 <p>
922 It contains one or more
923 <a title="Element" href="#dt-element">elements</a>.
924 </p>
925 </li>
926 <li>
927 <p>
928 [<a name="dt-root" id="dt-root" title="Root Element"
929 >Definition</a
930 >: There is exactly one element, called the <b>root</b>, or
931 document element, no part of which appears in the
932 <a title="Content" href="#dt-content">content</a> of any other
933 element.] For all other elements, if the
934 <a title="Start-Tag" href="#dt-stag">start-tag</a> is in the
935 content of another element, the
936 <a title="End Tag" href="#dt-etag">end-tag</a> is in the content
937 of the same element. More simply stated, the elements, delimited
938 by start- and end-tags, nest properly within each other.
939 </p>
940 </li>
941 </ol>
942 <p>
943 [<a name="dt-parentchild" id="dt-parentchild" title="Parent/Child"
944 >Definition</a
945 >: As a consequence of this, for each non-root element
946 <code>C</code> in the document, there is one other element
947 <code>P</code> in the document such that <code>C</code> is in the
948 content of <code>P</code>, but is not in the content of any other
949 element that is in the content of <code>P</code>. <code>P</code> is
950 referred to as the <b>parent</b> of <code>C</code>, and
951 <code>C</code> as a <b>child</b> of <code>P</code>.]
952 </p>
953 </div>
954 <div class="div2">
955 <h3><a name="charsets" id="charsets" />2.2 Characters</h3>
956 <p>
957 [<a name="dt-text" id="dt-text" title="Text">Definition</a>: A
958 parsed entity contains <b>text</b>, a sequence of
959 <a title="Character" href="#dt-character">characters</a>, which may
960 represent markup or character data.] [<a
961 name="dt-character"
962 id="dt-character"
963 title="Character"
964 >Definition</a
965 >: A <b>character</b> is an atomic unit of text as specified by
966 ISO/IEC 10646 <a href="#ISO10646">[ISO/IEC 10646]</a>. Legal
967 characters are tab, carriage return, line feed, and the legal
968 characters of Unicode and ISO/IEC 10646. The versions of these
969 standards cited in
970 <a href="#sec-existing-stds"><b>A.1 Normative References</b></a>
971 were current at the time this document was prepared. New characters
972 may be added to these standards by amendments or new editions.
973 Consequently, XML processors
974 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
975 accept any character in the range specified for
976 <a href="#NT-Char">Char</a>.]
977 </p>
978 <h5><a name="char32" id="char32" />Character Range</h5>
979 <table class="scrap" summary="Scrap">
980 <tbody>
981 <tr valign="baseline">
982 <td><a name="NT-Char" id="NT-Char" />[2]&nbsp;&nbsp;&nbsp;</td>
983 <td><code>Char</code></td>
984 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
985 <td>
986 <code
987 >[#x1-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF]</code
988 >
989 </td>
990 <td>
991 <i
992 >/* any Unicode character, excluding the surrogate blocks,
993 FFFE, and FFFF. */</i
994 >
995 </td>
996 </tr>
997 <tr valign="baseline">
998 <td>
999 <a
1000 name="NT-RestrictedChar"
1001 id="NT-RestrictedChar"
1002 />[2a]&nbsp;&nbsp;&nbsp;
1003 </td>
1004 <td><code>RestrictedChar</code></td>
1005 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1006 <td>
1007 <code
1008 >[#x1-#x8] | [#xB-#xC] | [#xE-#x1F] | [#x7F-#x84] |
1009 [#x86-#x9F]</code
1010 >
1011 </td>
1012 </tr>
1013 </tbody>
1014 </table>
1015 <p>
1016 The mechanism for encoding character code points into bit patterns
1017 <span>may</span> vary from entity to entity. All XML processors
1018 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
1019 accept the UTF-8 and UTF-16 encodings of Unicode
1020 <a href="#Unicode">[Unicode]</a>; the mechanisms for signaling which
1021 of the two is in use, or for bringing other encodings into play, are
1022 discussed later, in
1023 <a href="#charencoding"
1024 ><b>4.3.3 Character Encoding in Entities</b></a
1025 >.
1026 </p>
1027 <div class="note">
1028 <p class="prefix"><b>Note:</b></p>
1029 <p>
1030 Document authors are encouraged to avoid "compatibility
1031 characters", as defined in Unicode
1032 <a href="#Unicode">[Unicode]</a>. The characters defined in the
1033 following ranges are also discouraged. They are either control
1034 characters or permanently undefined Unicode characters:
1035 </p>
1036 <div class="exampleInner">
1037 <pre><span>[#x1-#x8], [#xB-#xC], [#xE-#x1F], </span>[#x7F-#x84], [#x86-#x9F], [#xFDD0-#xFDDF],
1038 [#<span>x</span>1FFFE-#x1FFFF], [#<span>x</span>2FFFE-#x2FFFF], [#<span>x</span>3FFFE-#x3FFFF],
1039 [#<span>x</span>4FFFE-#x4FFFF], [#<span>x</span>5FFFE-#x5FFFF], [#<span>x</span>6FFFE-#x6FFFF],
1040 [#<span>x</span>7FFFE-#x7FFFF], [#<span>x</span>8FFFE-#x8FFFF], [#<span>x</span>9FFFE-#x9FFFF],
1041 [#<span>x</span>AFFFE-#xAFFFF], [#<span>x</span>BFFFE-#xBFFFF], [#<span>x</span>CFFFE-#xCFFFF],
1042 [#<span>x</span>DFFFE-#xDFFFF], [#<span>x</span>EFFFE-#xEFFFF], [#<span>x</span>FFFFE-#xFFFFF],
1043 [#<span>x</span>10FFFE-#x10FFFF].</pre>
1044 </div>
1045 </div>
1046 </div>
1047 <div class="div2">
1048 <h3>
1049 <a name="sec-common-syn" id="sec-common-syn" />2.3 Common Syntactic
1050 Constructs
1051 </h3>
1052 <p>This section defines some symbols used widely in the grammar.</p>
1053 <p>
1054 <a href="#NT-S">S</a> (white space) consists of one or more space
1055 (#x20) characters, carriage returns, line feeds, or tabs.
1056 </p>
1057 <h5><a name="white" id="white" />White Space</h5>
1058 <table class="scrap" summary="Scrap">
1059 <tbody>
1060 <tr valign="baseline">
1061 <td><a name="NT-S" id="NT-S" />[3]&nbsp;&nbsp;&nbsp;</td>
1062 <td><code>S</code></td>
1063 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1064 <td><code>(#x20 | #x9 | #xD | #xA)+</code></td>
1065 </tr>
1066 </tbody>
1067 </table>
1068 <div class="note">
1069 <p class="prefix"><b>Note:</b></p>
1070 <p>
1071 The presence of #xD in the above production is maintained purely
1072 for backward compatibility with the
1073 <a href="http://www.w3.org/TR/1998/REC-xml-19980210"
1074 >First Edition</a
1075 >. As explained in
1076 <a href="#sec-line-ends"><b>2.11 End-of-Line Handling</b></a
1077 >, all #xD characters literally present in an XML document are
1078 either removed or replaced by #xA characters before any other
1079 processing is done. The only way to get a #xD character to match
1080 this production is to use a character reference in an entity value
1081 literal.
1082 </p>
1083 </div>
1084 <p>
1085 [<a name="dt-name" id="dt-name" title="Name">Definition</a>: A
1086 <b>Name</b> is a token beginning with a letter or one of a few
1087 punctuation characters, and continuing with letters, digits,
1088 hyphens, underscores, colons, or full stops, together known as name
1089 characters.] Names beginning with the string "<code>xml</code>", or
1090 with any string which would match
1091 <code>(('X'|'x') ('M'|'m') ('L'|'l'))</code>, are reserved for
1092 standardization in this or future versions of this specification.
1093 </p>
1094 <div class="note">
1095 <p class="prefix"><b>Note:</b></p>
1096 <p>
1097 The Namespaces in XML Recommendation
1098 <a href="#xml-names">[XML Names]</a> assigns a meaning to names
1099 containing colon characters. Therefore, authors should not use the
1100 colon in XML names except for namespace purposes, but XML
1101 processors must accept the colon as a name character.
1102 </p>
1103 </div>
1104 <p>
1105 An <a href="#NT-Nmtoken">Nmtoken</a> (name token) is any mixture of
1106 name characters.
1107 </p>
1108 <p>
1109 The first character of a Name
1110 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
1111 a NameStartChar, and any other characters
1112 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
1113 NameChars; this mechanism is used to prevent names from beginning
1114 with European (ASCII) digits or with basic combining characters.
1115 Almost all characters are permitted in names, except those which
1116 either are or reasonably could be used as delimiters. The intention
1117 is to be inclusive rather than exclusive, so that writing systems
1118 not yet encoded in Unicode can be used in XML names. See
1119 <a href="#sec-suggested-names"
1120 ><b>I Suggestions for XML Names</b></a
1121 >
1122 for suggestions on the creation of names.
1123 </p>
1124 <p>
1125 Document authors are encouraged to use names which are meaningful
1126 words or combinations of words in natural languages, and to avoid
1127 symbolic or white space characters in names. Note that COLON,
1128 HYPHEN-MINUS, FULL STOP (period), LOW LINE (underscore), and MIDDLE
1129 DOT are explicitly permitted.
1130 </p>
1131 <p>
1132 The ASCII symbols and punctuation marks, along with a fairly large
1133 group of Unicode symbol characters, are excluded from names because
1134 they are more useful as delimiters in contexts where XML names are
1135 used outside XML documents; providing this group gives those
1136 contexts hard guarantees about what <em>cannot</em> be part of an
1137 XML name. The character #x037E, GREEK QUESTION MARK, is excluded
1138 because when normalized it becomes a semicolon, which could change
1139 the meaning of entity references.
1140 </p>
1141 <h5><a name="IDAKUDS" id="IDAKUDS" />Names and Tokens</h5>
1142 <table class="scrap" summary="Scrap">
1143 <tbody>
1144 <tr valign="baseline">
1145 <td>
1146 <a
1147 name="NT-NameStartChar"
1148 id="NT-NameStartChar"
1149 />[4]&nbsp;&nbsp;&nbsp;
1150 </td>
1151 <td><code>NameStartChar</code></td>
1152 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1153 <td>
1154 <code
1155 >":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] |
1156 [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] |
1157 [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] |
1158 [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] |
1159 [#x10000-#xEFFFF]</code
1160 >
1161 </td>
1162 </tr>
1163 </tbody>
1164 <tbody>
1165 <tr valign="baseline">
1166 <td>
1167 <a
1168 name="NT-NameChar"
1169 id="NT-NameChar"
1170 />[4a]&nbsp;&nbsp;&nbsp;
1171 </td>
1172 <td><code>NameChar</code></td>
1173 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1174 <td>
1175 <code>
1176 <a href="#NT-NameStartChar">NameStartChar</a> | "-" | "." |
1177 [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]</code
1178 >
1179 </td>
1180 </tr>
1181 </tbody>
1182 <tbody>
1183 <tr valign="baseline">
1184 <td><a name="NT-Name" id="NT-Name" />[5]&nbsp;&nbsp;&nbsp;</td>
1185 <td><code>Name</code></td>
1186 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1187 <td>
1188 <code>
1189 <a href="#NT-NameStartChar">NameStartChar</a> (<a
1190 href="#NT-NameChar"
1191 >NameChar</a
1192 >)*</code
1193 >
1194 </td>
1195 </tr>
1196 </tbody>
1197 <tbody>
1198 <tr valign="baseline">
1199 <td>
1200 <a name="NT-Names" id="NT-Names" />[6]&nbsp;&nbsp;&nbsp;
1201 </td>
1202 <td><code>Names</code></td>
1203 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1204 <td>
1205 <code>
1206 <a href="#NT-Name">Name</a> (#x20
1207 <a href="#NT-Name">Name</a>)*</code
1208 >
1209 </td>
1210 </tr>
1211 </tbody>
1212 <tbody>
1213 <tr valign="baseline">
1214 <td>
1215 <a name="NT-Nmtoken" id="NT-Nmtoken" />[7]&nbsp;&nbsp;&nbsp;
1216 </td>
1217 <td><code>Nmtoken</code></td>
1218 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1219 <td>
1220 <code>(<a href="#NT-NameChar">NameChar</a>)+</code>
1221 </td>
1222 </tr>
1223 </tbody>
1224 <tbody>
1225 <tr valign="baseline">
1226 <td>
1227 <a name="NT-Nmtokens" id="NT-Nmtokens" />[8]&nbsp;&nbsp;&nbsp;
1228 </td>
1229 <td><code>Nmtokens</code></td>
1230 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1231 <td>
1232 <code>
1233 <a href="#NT-Nmtoken">Nmtoken</a> (#x20
1234 <a href="#NT-Nmtoken">Nmtoken</a>)*</code
1235 >
1236 </td>
1237 </tr>
1238 </tbody>
1239 </table>
1240 <div class="note">
1241 <p class="prefix"><b>Note:</b></p>
1242 <p>
1243 The <a href="#NT-Names">Names</a> and
1244 <a href="#NT-Nmtokens">Nmtokens</a> productions are used to define
1245 the validity of tokenized attribute values after normalization
1246 (see
1247 <a href="#sec-attribute-types"><b>3.3.1 Attribute Types</b></a
1248 >).
1249 </p>
1250 </div>
1251 <p>
1252 Literal data is any quoted string not containing the quotation mark
1253 used as a delimiter for that string. Literals are used for
1254 specifying the content of internal entities (<a
1255 href="#NT-EntityValue"
1256 >EntityValue</a
1257 >), the values of attributes (<a href="#NT-AttValue">AttValue</a>),
1258 and external identifiers (<a href="#NT-SystemLiteral"
1259 >SystemLiteral</a
1260 >). Note that a <a href="#NT-SystemLiteral">SystemLiteral</a> can be
1261 parsed without scanning for markup.
1262 </p>
1263 <h5><a name="IDAKYDS" id="IDAKYDS" />Literals</h5>
1264 <table class="scrap" summary="Scrap">
1265 <tbody>
1266 <tr valign="baseline">
1267 <td>
1268 <a
1269 name="NT-EntityValue"
1270 id="NT-EntityValue"
1271 />[9]&nbsp;&nbsp;&nbsp;
1272 </td>
1273 <td><code>EntityValue</code></td>
1274 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1275 <td>
1276 <code
1277 >'"' ([^%&amp;"] |
1278 <a href="#NT-PEReference">PEReference</a> |
1279 <a href="#NT-Reference">Reference</a>)* '"'
1280 </code>
1281 </td>
1282 </tr>
1283 <tr valign="baseline">
1284 <td />
1285 <td />
1286 <td />
1287 <td>
1288 <code
1289 >|&nbsp; "'" ([^%&amp;'] |
1290 <a href="#NT-PEReference">PEReference</a> |
1291 <a href="#NT-Reference">Reference</a>)* "'"</code
1292 >
1293 </td>
1294 </tr>
1295 </tbody>
1296 <tbody>
1297 <tr valign="baseline">
1298 <td>
1299 <a
1300 name="NT-AttValue"
1301 id="NT-AttValue"
1302 />[10]&nbsp;&nbsp;&nbsp;
1303 </td>
1304 <td><code>AttValue</code></td>
1305 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1306 <td>
1307 <code
1308 >'"' ([^&lt;&amp;"] |
1309 <a href="#NT-Reference">Reference</a>)* '"'
1310 </code>
1311 </td>
1312 </tr>
1313 <tr valign="baseline">
1314 <td />
1315 <td />
1316 <td />
1317 <td>
1318 <code
1319 >|&nbsp; "'" ([^&lt;&amp;'] |
1320 <a href="#NT-Reference">Reference</a>)* "'"</code
1321 >
1322 </td>
1323 </tr>
1324 </tbody>
1325 <tbody>
1326 <tr valign="baseline">
1327 <td>
1328 <a
1329 name="NT-SystemLiteral"
1330 id="NT-SystemLiteral"
1331 />[11]&nbsp;&nbsp;&nbsp;
1332 </td>
1333 <td><code>SystemLiteral</code></td>
1334 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1335 <td><code>('"' [^"]* '"') |&nbsp;("'" [^']* "'") </code></td>
1336 </tr>
1337 </tbody>
1338 <tbody>
1339 <tr valign="baseline">
1340 <td>
1341 <a
1342 name="NT-PubidLiteral"
1343 id="NT-PubidLiteral"
1344 />[12]&nbsp;&nbsp;&nbsp;
1345 </td>
1346 <td><code>PubidLiteral</code></td>
1347 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1348 <td>
1349 <code
1350 >'"' <a href="#NT-PubidChar">PubidChar</a>* '"' | "'" (<a
1351 href="#NT-PubidChar"
1352 >PubidChar</a
1353 >
1354 - "'")* "'"</code
1355 >
1356 </td>
1357 </tr>
1358 </tbody>
1359 <tbody>
1360 <tr valign="baseline">
1361 <td>
1362 <a
1363 name="NT-PubidChar"
1364 id="NT-PubidChar"
1365 />[13]&nbsp;&nbsp;&nbsp;
1366 </td>
1367 <td><code>PubidChar</code></td>
1368 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1369 <td>
1370 <code
1371 >#x20 | #xD | #xA |&nbsp;[a-zA-Z0-9]
1372 |&nbsp;[-'()+,./:=?;!*#@$_%]</code
1373 >
1374 </td>
1375 </tr>
1376 </tbody>
1377 </table>
1378 <div class="note">
1379 <p class="prefix"><b>Note:</b></p>
1380 <p>
1381 Although the <a href="#NT-EntityValue">EntityValue</a> production
1382 allows the definition of a general entity consisting of a single
1383 explicit <code>&lt;</code> in the literal (e.g.,
1384 <code>&lt;!ENTITY mylt "&lt;"&gt;</code>), it is strongly advised
1385 to avoid this practice since any reference to that entity will
1386 cause a well-formedness error.
1387 </p>
1388 </div>
1389 </div>
1390 <div class="div2">
1391 <h3><a name="syntax" id="syntax" />2.4 Character Data and Markup</h3>
1392 <p>
1393 <a title="Text" href="#dt-text">Text</a> consists of intermingled
1394 <a title="Character Data" href="#dt-chardata">character data</a> and
1395 markup. [<a name="dt-markup" id="dt-markup" title="Markup"
1396 >Definition</a
1397 >: <b>Markup</b> takes the form of
1398 <a title="Start-Tag" href="#dt-stag">start-tags</a>,
1399 <a title="End Tag" href="#dt-etag">end-tags</a>,
1400 <a title="Empty" href="#dt-empty">empty-element tags</a>,
1401 <a title="Entity Reference" href="#dt-entref">entity references</a>,
1402 <a title="Character Reference" href="#dt-charref"
1403 >character references</a
1404 >, <a title="Comment" href="#dt-comment">comments</a>,
1405 <a title="CDATA Section" href="#dt-cdsection">CDATA section</a>
1406 delimiters,
1407 <a title="Document Type Declaration" href="#dt-doctype"
1408 >document type declarations</a
1409 >,
1410 <a title="Processing instruction" href="#dt-pi"
1411 >processing instructions</a
1412 >, <a href="#NT-XMLDecl">XML declarations</a>,
1413 <a href="#NT-TextDecl">text declarations</a>, and any white space
1414 that is at the top level of the document entity (that is, outside
1415 the document element and not inside any other markup).]
1416 </p>
1417 <p>
1418 [<a name="dt-chardata" id="dt-chardata" title="Character Data"
1419 >Definition</a
1420 >: All text that is not markup constitutes the
1421 <b>character data</b> of the document.]
1422 </p>
1423 <p>
1424 The ampersand character (&amp;) and the left angle bracket (&lt;)
1425 <em class="rfc2119" title="Keyword in RFC 2119 context"
1426 >MUST NOT</em
1427 >
1428 appear in their literal form, except when used as markup delimiters,
1429 or within a <a title="Comment" href="#dt-comment">comment</a>, a
1430 <a title="Processing instruction" href="#dt-pi"
1431 >processing instruction</a
1432 >, or a
1433 <a title="CDATA Section" href="#dt-cdsection">CDATA section</a>. If
1434 they are needed elsewhere, they
1435 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
1436 <a title="escape" href="#dt-escape">escaped</a> using either
1437 <a title="Character Reference" href="#dt-charref"
1438 >numeric character references</a
1439 >
1440 or the strings "<code>&amp;amp;</code>" and "<code>&amp;lt;</code>"
1441 respectively. The right angle bracket (&gt;) <span>may</span> be
1442 represented using the string "<code>&amp;gt;</code>", and
1443 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>,
1444 <a title="For Compatibility" href="#dt-compat">for compatibility</a
1445 >, be escaped using either "<code>&amp;gt;</code>" or a character
1446 reference when it appears in the string "<code>]]&gt;</code>" in
1447 content, when that string is not marking the end of a
1448 <a title="CDATA Section" href="#dt-cdsection">CDATA section</a>.
1449 </p>
1450 <p>
1451 In the content of elements, character data is any string of
1452 characters which does not contain the start-delimiter of any markup
1453 or the CDATA-section-close delimiter, "<code>]]&gt;</code>". In a
1454 CDATA section, character data is any string of characters not
1455 including the CDATA-section-close delimiter.
1456 </p>
1457 <p>
1458 To allow attribute values to contain both single and double quotes,
1459 the apostrophe or single-quote character (') <span>may</span> be
1460 represented as "<code>&amp;apos;</code>", and the double-quote
1461 character (") as "<code>&amp;quot;</code>".
1462 </p>
1463 <h5><a name="IDAABES" id="IDAABES" />Character Data</h5>
1464 <table class="scrap" summary="Scrap">
1465 <tbody>
1466 <tr valign="baseline">
1467 <td>
1468 <a
1469 name="NT-CharData"
1470 id="NT-CharData"
1471 />[14]&nbsp;&nbsp;&nbsp;
1472 </td>
1473 <td><code>CharData</code></td>
1474 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1475 <td>
1476 <code
1477 >[^&lt;&amp;]* - ([^&lt;&amp;]* ']]&gt;'
1478 [^&lt;&amp;]*)</code
1479 >
1480 </td>
1481 </tr>
1482 </tbody>
1483 </table>
1484 </div>
1485 <div class="div2">
1486 <h3><a name="sec-comments" id="sec-comments" />2.5 Comments</h3>
1487 <p>
1488 [<a name="dt-comment" id="dt-comment" title="Comment">Definition</a
1489 >: <b>Comments</b> <span>may</span> appear anywhere in a document
1490 outside other <a title="Markup" href="#dt-markup">markup</a>; in
1491 addition, they <span>may</span> appear within the document type
1492 declaration at places allowed by the grammar. They are not part of
1493 the document's
1494 <a title="Character Data" href="#dt-chardata">character data</a>; an
1495 XML processor
1496 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>,
1497 but need not, make it possible for an application to retrieve the
1498 text of comments.
1499 <a title="For Compatibility" href="#dt-compat">For compatibility</a
1500 >, the string "<code>--</code>" (double-hyphen)
1501 <em class="rfc2119" title="Keyword in RFC 2119 context"
1502 >MUST NOT</em
1503 >
1504 occur within comments.] Parameter entity references
1505 <em class="rfc2119" title="Keyword in RFC 2119 context"
1506 >MUST NOT</em
1507 >
1508 be recognized within comments.
1509 </p>
1510 <h5><a name="IDA5CES" id="IDA5CES" />Comments</h5>
1511 <table class="scrap" summary="Scrap">
1512 <tbody>
1513 <tr valign="baseline">
1514 <td>
1515 <a name="NT-Comment" id="NT-Comment" />[15]&nbsp;&nbsp;&nbsp;
1516 </td>
1517 <td><code>Comment</code></td>
1518 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1519 <td>
1520 <code
1521 >'&lt;!--' ((<a href="#NT-Char">Char</a> - '-') | ('-' (<a
1522 href="#NT-Char"
1523 >Char</a
1524 >
1525 - '-')))* '--&gt;'</code
1526 >
1527 </td>
1528 </tr>
1529 </tbody>
1530 </table>
1531 <p>An example of a comment:</p>
1532 <div class="exampleInner">
1533 <pre>
1534 &lt;!-- declarations for &lt;head&gt; &amp; &lt;body&gt; --&gt;</pre
1535 >
1536 </div>
1537 <p>
1538 Note that the grammar does not allow a comment ending in
1539 <code>---&gt;</code>. The following example is
1540 <em>not</em> well-formed.
1541 </p>
1542 <div class="exampleInner"><pre>&lt;!-- B+, B, or B---&gt;</pre></div>
1543 </div>
1544 <div class="div2">
1545 <h3><a name="sec-pi" id="sec-pi" />2.6 Processing Instructions</h3>
1546 <p>
1547 [<a name="dt-pi" id="dt-pi" title="Processing instruction"
1548 >Definition</a
1549 >:
1550 <b>Processing instructions</b>
1551 (PIs) allow documents to contain instructions for applications.]
1552 </p>
1553 <h5><a name="IDAREES" id="IDAREES" />Processing Instructions</h5>
1554 <table class="scrap" summary="Scrap">
1555 <tbody>
1556 <tr valign="baseline">
1557 <td><a name="NT-PI" id="NT-PI" />[16]&nbsp;&nbsp;&nbsp;</td>
1558 <td><code>PI</code></td>
1559 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1560 <td>
1561 <code
1562 >'&lt;?' <a href="#NT-PITarget">PITarget</a> (<a
1563 href="#NT-S"
1564 >S</a
1565 >
1566 (<a href="#NT-Char">Char</a>* - (<a href="#NT-Char">Char</a
1567 >* '?&gt;' <a href="#NT-Char">Char</a>*)))? '?&gt;'</code
1568 >
1569 </td>
1570 </tr>
1571 </tbody>
1572 <tbody>
1573 <tr valign="baseline">
1574 <td>
1575 <a
1576 name="NT-PITarget"
1577 id="NT-PITarget"
1578 />[17]&nbsp;&nbsp;&nbsp;
1579 </td>
1580 <td><code>PITarget</code></td>
1581 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1582 <td>
1583 <code>
1584 <a href="#NT-Name">Name</a> - (('X' | 'x') ('M' | 'm') ('L'
1585 | 'l'))</code
1586 >
1587 </td>
1588 </tr>
1589 </tbody>
1590 </table>
1591 <p>
1592 PIs are not part of the document's
1593 <a title="Character Data" href="#dt-chardata">character data</a>,
1594 but
1595 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
1596 passed through to the application. The PI begins with a target (<a
1597 href="#NT-PITarget"
1598 >PITarget</a
1599 >) used to identify the application to which the instruction is
1600 directed. The target names "<code>XML</code>", "<code>xml</code>",
1601 and so on are reserved for standardization in this or future
1602 versions of this specification. The XML
1603 <a title="Notation" href="#dt-notation">Notation</a> mechanism
1604 <span>may</span> be used for formal declaration of PI targets.
1605 Parameter entity references
1606 <em class="rfc2119" title="Keyword in RFC 2119 context"
1607 >MUST NOT</em
1608 >
1609 be recognized within processing instructions.
1610 </p>
1611 </div>
1612 <div class="div2">
1613 <h3>
1614 <a name="sec-cdata-sect" id="sec-cdata-sect" />2.7 CDATA Sections
1615 </h3>
1616 <p>
1617 [<a name="dt-cdsection" id="dt-cdsection" title="CDATA Section"
1618 >Definition</a
1619 >: <b>CDATA sections</b> <span>may</span> occur anywhere character
1620 data may occur; they are used to escape blocks of text containing
1621 characters which would otherwise be recognized as markup. CDATA
1622 sections begin with the string "<code>&lt;![CDATA[</code>" and end
1623 with the string "<code>]]&gt;</code>":]
1624 </p>
1625 <h5><a name="IDA2HES" id="IDA2HES" />CDATA Sections</h5>
1626 <table class="scrap" summary="Scrap">
1627 <tbody>
1628 <tr valign="baseline">
1629 <td>
1630 <a name="NT-CDSect" id="NT-CDSect" />[18]&nbsp;&nbsp;&nbsp;
1631 </td>
1632 <td><code>CDSect</code></td>
1633 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1634 <td>
1635 <code>
1636 <a href="#NT-CDStart">CDStart</a>
1637 <a href="#NT-CData">CData</a>
1638 <a href="#NT-CDEnd">CDEnd</a>
1639 </code>
1640 </td>
1641 </tr>
1642 </tbody>
1643 <tbody>
1644 <tr valign="baseline">
1645 <td>
1646 <a name="NT-CDStart" id="NT-CDStart" />[19]&nbsp;&nbsp;&nbsp;
1647 </td>
1648 <td><code>CDStart</code></td>
1649 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1650 <td><code>'&lt;![CDATA['</code></td>
1651 </tr>
1652 </tbody>
1653 <tbody>
1654 <tr valign="baseline">
1655 <td>
1656 <a name="NT-CData" id="NT-CData" />[20]&nbsp;&nbsp;&nbsp;
1657 </td>
1658 <td><code>CData</code></td>
1659 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1660 <td>
1661 <code
1662 >(<a href="#NT-Char">Char</a>* - (<a href="#NT-Char">Char</a
1663 >* ']]&gt;' <a href="#NT-Char">Char</a>*))
1664 </code>
1665 </td>
1666 </tr>
1667 </tbody>
1668 <tbody>
1669 <tr valign="baseline">
1670 <td>
1671 <a name="NT-CDEnd" id="NT-CDEnd" />[21]&nbsp;&nbsp;&nbsp;
1672 </td>
1673 <td><code>CDEnd</code></td>
1674 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1675 <td><code>']]&gt;'</code></td>
1676 </tr>
1677 </tbody>
1678 </table>
1679 <p>
1680 Within a CDATA section, only the
1681 <a href="#NT-CDEnd">CDEnd</a> string is recognized as markup, so
1682 that left angle brackets and ampersands may occur in their literal
1683 form; they need not (and cannot) be escaped using
1684 "<code>&amp;lt;</code>" and "<code>&amp;amp;</code>". CDATA sections
1685 cannot nest.
1686 </p>
1687 <p>
1688 An example of a CDATA section, in which
1689 "<code>&lt;greeting&gt;</code>" and "<code>&lt;/greeting&gt;</code>"
1690 are recognized as
1691 <a title="Character Data" href="#dt-chardata">character data</a>,
1692 not <a title="Markup" href="#dt-markup">markup</a>:
1693 </p>
1694 <div class="exampleInner">
1695 <pre>
1696 &lt;![CDATA[&lt;greeting&gt;Hello, world!&lt;/greeting&gt;]]&gt; </pre
1697 >
1698 </div>
1699 </div>
1700 <div class="div2">
1701 <h3>
1702 <a name="sec-prolog-dtd" id="sec-prolog-dtd" />2.8 Prolog and
1703 Document Type Declaration
1704 </h3>
1705 <p>
1706 [<a name="dt-xmldecl" id="dt-xmldecl" title="XML Declaration"
1707 >Definition</a
1708 >: XML 1.1 documents
1709 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
1710 begin with an <b>XML declaration</b> which specifies the version of
1711 XML being used.] For example, the following is a complete XML 1.1
1712 document,
1713 <a title="Well-Formed" href="#dt-wellformed">well-formed</a> but not
1714 <a title="Validity" href="#dt-valid">valid</a>:
1715 </p>
1716 <div class="exampleInner">
1717 <pre>
1718 &lt;?xml version="1.1"?&gt;
1719 &lt;greeting&gt;Hello, world!&lt;/greeting&gt; </pre
1720 >
1721 </div>
1722 <p>
1723 but the following is an XML 1.0 document because it does not have an
1724 XML declaration:
1725 </p>
1726 <div class="exampleInner">
1727 <pre>&lt;greeting&gt;Hello, world!&lt;/greeting&gt;</pre>
1728 </div>
1729 <p>
1730 The function of the markup in an XML document is to describe its
1731 storage and logical structure and to associate attribute name-value
1732 pairs with its logical structures. XML provides a mechanism, the
1733 <a title="Document Type Declaration" href="#dt-doctype"
1734 >document type declaration</a
1735 >, to define constraints on the logical structure and to support the
1736 use of predefined storage units. [<a
1737 name="dt-valid"
1738 id="dt-valid"
1739 title="Validity"
1740 >Definition</a
1741 >: An XML document is <b>valid</b> if it has an associated document
1742 type declaration and if the document complies with the constraints
1743 expressed in it.]
1744 </p>
1745 <p>
1746 The document type declaration
1747 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
1748 appear before the first
1749 <a title="Element" href="#dt-element">element</a> in the document.
1750 </p>
1751 <h5><a name="xmldoc" id="xmldoc" />Prolog</h5>
1752 <table class="scrap" summary="Scrap">
1753 <tbody>
1754 <tr valign="baseline">
1755 <td>
1756 <a name="NT-prolog" id="NT-prolog" />[22]&nbsp;&nbsp;&nbsp;
1757 </td>
1758 <td><code>prolog</code></td>
1759 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1760 <td>
1761 <code>
1762 <a href="#NT-XMLDecl">XMLDecl</a>
1763 <a href="#NT-Misc">Misc</a>* (<a href="#NT-doctypedecl"
1764 >doctypedecl</a
1765 >
1766 <a href="#NT-Misc">Misc</a>*)?</code
1767 >
1768 </td>
1769 </tr>
1770 <tr valign="baseline">
1771 <td>
1772 <a name="NT-XMLDecl" id="NT-XMLDecl" />[23]&nbsp;&nbsp;&nbsp;
1773 </td>
1774 <td><code>XMLDecl</code></td>
1775 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1776 <td>
1777 <code
1778 >'&lt;?xml' <a href="#NT-VersionInfo">VersionInfo</a>
1779 <a href="#NT-EncodingDecl">EncodingDecl</a>?
1780 <a href="#NT-SDDecl">SDDecl</a>? <a href="#NT-S">S</a>?
1781 '?&gt;'</code
1782 >
1783 </td>
1784 </tr>
1785 <tr valign="baseline">
1786 <td>
1787 <a
1788 name="NT-VersionInfo"
1789 id="NT-VersionInfo"
1790 />[24]&nbsp;&nbsp;&nbsp;
1791 </td>
1792 <td><code>VersionInfo</code></td>
1793 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1794 <td>
1795 <code>
1796 <a href="#NT-S">S</a> 'version' <a href="#NT-Eq">Eq</a> ("'"
1797 <a href="#NT-VersionNum">VersionNum</a> "'" | '"'
1798 <a href="#NT-VersionNum">VersionNum</a> '"')</code
1799 >
1800 </td>
1801 </tr>
1802 <tr valign="baseline">
1803 <td><a name="NT-Eq" id="NT-Eq" />[25]&nbsp;&nbsp;&nbsp;</td>
1804 <td><code>Eq</code></td>
1805 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1806 <td>
1807 <code>
1808 <a href="#NT-S">S</a>? '=' <a href="#NT-S">S</a>?</code
1809 >
1810 </td>
1811 </tr>
1812 <tr valign="baseline">
1813 <td>
1814 <a
1815 name="NT-VersionNum"
1816 id="NT-VersionNum"
1817 />[26]&nbsp;&nbsp;&nbsp;
1818 </td>
1819 <td><code>VersionNum</code></td>
1820 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1821 <td><code>'1.1'</code></td>
1822 </tr>
1823 <tr valign="baseline">
1824 <td><a name="NT-Misc" id="NT-Misc" />[27]&nbsp;&nbsp;&nbsp;</td>
1825 <td><code>Misc</code></td>
1826 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1827 <td>
1828 <code>
1829 <a href="#NT-Comment">Comment</a> |
1830 <a href="#NT-PI">PI</a> | <a href="#NT-S">S</a>
1831 </code>
1832 </td>
1833 </tr>
1834 </tbody>
1835 </table>
1836 <p>
1837 [<a
1838 name="dt-doctype"
1839 id="dt-doctype"
1840 title="Document Type Declaration"
1841 >Definition</a
1842 >: The XML <b>document type declaration</b> contains or points to
1843 <a title="markup declaration" href="#dt-markupdecl"
1844 >markup declarations</a
1845 >
1846 that provide a grammar for a class of documents. This grammar is
1847 known as a document type definition, or <b>DTD</b>. The document
1848 type declaration can point to an external subset (a special kind of
1849 <a title="External Entity" href="#dt-extent">external entity</a>)
1850 containing markup declarations, or can contain the markup
1851 declarations directly in an internal subset, or can do both. The DTD
1852 for a document consists of both subsets taken together.]
1853 </p>
1854 <p>
1855 [<a
1856 name="dt-markupdecl"
1857 id="dt-markupdecl"
1858 title="markup declaration"
1859 >Definition</a
1860 >: A <b>markup declaration</b> is an
1861 <a title="Element Type declaration" href="#dt-eldecl"
1862 >element type declaration</a
1863 >, an
1864 <a title="Attribute-List Declaration" href="#dt-attdecl"
1865 >attribute-list declaration</a
1866 >, an
1867 <a title="entity declaration" href="#dt-entdecl"
1868 >entity declaration</a
1869 >, or a
1870 <a title="Notation Declaration" href="#dt-notdecl"
1871 >notation declaration</a
1872 >.] These declarations <span>may</span> be contained in whole or in
1873 part within
1874 <a title="Parameter entity" href="#dt-PE">parameter entities</a>, as
1875 described in the well-formedness and validity constraints below. For
1876 further information, see
1877 <a href="#sec-physical-struct"><b>4 Physical Structures</b></a
1878 >.
1879 </p>
1880 <h5><a name="dtd" id="dtd" />Document Type Definition</h5>
1881 <table class="scrap" summary="Scrap">
1882 <tbody>
1883 <tr valign="baseline">
1884 <td>
1885 <a
1886 name="NT-doctypedecl"
1887 id="NT-doctypedecl"
1888 />[28]&nbsp;&nbsp;&nbsp;
1889 </td>
1890 <td><code>doctypedecl</code></td>
1891 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1892 <td>
1893 <code
1894 >'&lt;!DOCTYPE' <a href="#NT-S">S</a>
1895 <a href="#NT-Name">Name</a>
1896 (<a href="#NT-S">S</a>
1897 <a href="#NT-ExternalID">ExternalID</a>)?
1898 <a href="#NT-S">S</a>? ('['
1899 <a href="#NT-intSubset">intSubset</a> ']'
1900 <a href="#NT-S">S</a>?)? '&gt;'</code
1901 >
1902 </td>
1903 <td><a href="#vc-roottype">[VC: Root Element Type]</a></td>
1904 </tr>
1905 <tr valign="baseline">
1906 <td />
1907 <td />
1908 <td />
1909 <td />
1910 <td><a href="#ExtSubset">[WFC: External Subset]</a></td>
1911 </tr>
1912 <tr valign="baseline">
1913 <td>
1914 <a name="NT-DeclSep" id="NT-DeclSep" />[28a]&nbsp;&nbsp;&nbsp;
1915 </td>
1916 <td><code>DeclSep</code></td>
1917 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1918 <td>
1919 <code>
1920 <a href="#NT-PEReference">PEReference</a> |
1921 <a href="#NT-S">S</a>
1922 </code>
1923 </td>
1924 <td>
1925 <a href="#PE-between-Decls">[WFC: PE Between Declarations]</a>
1926 </td>
1927 </tr>
1928 <tr valign="baseline">
1929 <td>
1930 <a
1931 name="NT-intSubset"
1932 id="NT-intSubset"
1933 />[28b]&nbsp;&nbsp;&nbsp;
1934 </td>
1935 <td><code>intSubset</code></td>
1936 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1937 <td>
1938 <code
1939 >(<a href="#NT-markupdecl">markupdecl</a> |
1940 <a href="#NT-DeclSep">DeclSep</a>)*</code
1941 >
1942 </td>
1943 </tr>
1944 <tr valign="baseline">
1945 <td>
1946 <a
1947 name="NT-markupdecl"
1948 id="NT-markupdecl"
1949 />[29]&nbsp;&nbsp;&nbsp;
1950 </td>
1951 <td><code>markupdecl</code></td>
1952 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1953 <td>
1954 <code>
1955 <a href="#NT-elementdecl">elementdecl</a> |
1956 <a href="#NT-AttlistDecl">AttlistDecl</a> |
1957 <a href="#NT-EntityDecl">EntityDecl</a> |
1958 <a href="#NT-NotationDecl">NotationDecl</a> |
1959 <a href="#NT-PI">PI</a> | <a href="#NT-Comment">Comment</a>
1960 </code>
1961 </td>
1962 <td>
1963 <a href="#vc-PEinMarkupDecl"
1964 >[VC: Proper Declaration/PE Nesting]</a
1965 >
1966 </td>
1967 </tr>
1968 <tr valign="baseline">
1969 <td />
1970 <td />
1971 <td />
1972 <td />
1973 <td>
1974 <a href="#wfc-PEinInternalSubset"
1975 >[WFC: PEs in Internal Subset]</a
1976 >
1977 </td>
1978 </tr>
1979 </tbody>
1980 </table>
1981 <p>
1982 Note that it is possible to construct a well-formed document
1983 containing a <a href="#NT-doctypedecl">doctypedecl</a> that neither
1984 points to an external subset nor contains an internal subset.
1985 </p>
1986 <p>
1987 The markup declarations <span>may</span> be made up in whole or in
1988 part of the
1989 <a title="Replacement Text" href="#dt-repltext">replacement text</a>
1990 of <a title="Parameter entity" href="#dt-PE">parameter entities</a>.
1991 The productions later in this specification for individual
1992 nonterminals (<a href="#NT-elementdecl">elementdecl</a>,
1993 <a href="#NT-AttlistDecl">AttlistDecl</a>, and so on) describe the
1994 declarations <em>after</em> all the parameter entities have been
1995 <a title="Include" href="#dt-include">included</a>.
1996 </p>
1997 <p>
1998 Parameter entity references are recognized anywhere in the DTD
1999 (internal and external subsets and external parameter entities),
2000 except in literals, processing instructions, comments, and the
2001 contents of ignored conditional sections (see
2002 <a href="#sec-condition-sect"><b>3.4 Conditional Sections</b></a
2003 >). They are also recognized in entity value literals. The use of
2004 parameter entities in the internal subset is restricted as described
2005 below.
2006 </p>
2007 <div class="constraint">
2008 <p class="prefix">
2009 <a name="vc-roottype" id="vc-roottype" /><b
2010 >Validity constraint: Root Element Type</b
2011 >
2012 </p>
2013 <p>
2014 The <a href="#NT-Name">Name</a> in the document type declaration
2015 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2016 match the element type of the
2017 <a title="Root Element" href="#dt-root">root element</a>.
2018 </p>
2019 </div>
2020 <div class="constraint">
2021 <p class="prefix">
2022 <a name="vc-PEinMarkupDecl" id="vc-PEinMarkupDecl" /><b
2023 >Validity constraint: Proper Declaration/PE Nesting</b
2024 >
2025 </p>
2026 <p>
2027 Parameter-entity
2028 <a title="Replacement Text" href="#dt-repltext"
2029 >replacement text</a
2030 >
2031 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2032 be properly nested with markup declarations. That is to say, if
2033 either the first character or the last character of a markup
2034 declaration (<a href="#NT-markupdecl">markupdecl</a> above) is
2035 contained in the replacement text for a
2036 <a title="Parameter-entity reference" href="#dt-PERef"
2037 >parameter-entity reference</a
2038 >, both
2039 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2040 be contained in the same replacement text.
2041 </p>
2042 </div>
2043 <div class="constraint">
2044 <p class="prefix">
2045 <a name="wfc-PEinInternalSubset" id="wfc-PEinInternalSubset" /><b
2046 >Well-formedness constraint: PEs in Internal Subset</b
2047 >
2048 </p>
2049 <p>
2050 In the internal DTD subset,
2051 <a title="Parameter-entity reference" href="#dt-PERef"
2052 >parameter-entity references</a
2053 >
2054 <em class="rfc2119" title="Keyword in RFC 2119 context"
2055 >MUST NOT</em
2056 >
2057 occur within markup declarations; they <span>may</span> occur
2058 where markup declarations can occur. (This does not apply to
2059 references that occur in external parameter entities or to the
2060 external subset.)
2061 </p>
2062 </div>
2063 <div class="constraint">
2064 <p class="prefix">
2065 <a name="ExtSubset" id="ExtSubset" /><b
2066 >Well-formedness constraint: External Subset</b
2067 >
2068 </p>
2069 <p>
2070 The external subset, if any,
2071 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2072 match the production for <a href="#NT-extSubset">extSubset</a>.
2073 </p>
2074 </div>
2075 <div class="constraint">
2076 <p class="prefix">
2077 <a name="PE-between-Decls" id="PE-between-Decls" /><b
2078 >Well-formedness constraint: PE Between Declarations</b
2079 >
2080 </p>
2081 <p>
2082 The replacement text of a parameter entity reference in a
2083 <a href="#NT-DeclSep">DeclSep</a>
2084 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2085 match the production
2086 <a href="#NT-extSubsetDecl">extSubsetDecl</a>.
2087 </p>
2088 </div>
2089 <p>
2090 Like the internal subset, the external subset and any external
2091 parameter entities referenced in a
2092 <a href="#NT-DeclSep">DeclSep</a>
2093 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2094 consist of a series of complete markup declarations of the types
2095 allowed by the non-terminal symbol
2096 <a href="#NT-markupdecl">markupdecl</a>, interspersed with white
2097 space or
2098 <a title="Parameter-entity reference" href="#dt-PERef"
2099 >parameter-entity references</a
2100 >. However, portions of the contents of the external subset or of
2101 these external parameter entities <span>may</span> conditionally be
2102 ignored by using the
2103 <a title="conditional section" href="#dt-cond-section"
2104 >conditional section</a
2105 >
2106 construct; this is not allowed in the internal subset but is allowed
2107 in external parameter entities referenced in the internal subset.
2108 </p>
2109 <h5><a name="ext-Subset" id="ext-Subset" />External Subset</h5>
2110 <table class="scrap" summary="Scrap">
2111 <tbody>
2112 <tr valign="baseline">
2113 <td>
2114 <a
2115 name="NT-extSubset"
2116 id="NT-extSubset"
2117 />[30]&nbsp;&nbsp;&nbsp;
2118 </td>
2119 <td><code>extSubset</code></td>
2120 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
2121 <td>
2122 <code>
2123 <a href="#NT-TextDecl">TextDecl</a>?
2124 <a href="#NT-extSubsetDecl">extSubsetDecl</a>
2125 </code>
2126 </td>
2127 </tr>
2128 <tr valign="baseline">
2129 <td>
2130 <a
2131 name="NT-extSubsetDecl"
2132 id="NT-extSubsetDecl"
2133 />[31]&nbsp;&nbsp;&nbsp;
2134 </td>
2135 <td><code>extSubsetDecl</code></td>
2136 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
2137 <td>
2138 <code
2139 >( <a href="#NT-markupdecl">markupdecl</a> |
2140 <a href="#NT-conditionalSect">conditionalSect</a> |
2141 <a href="#NT-DeclSep">DeclSep</a>)*</code
2142 >
2143 </td>
2144 </tr>
2145 </tbody>
2146 </table>
2147 <p>
2148 The external subset and external parameter entities also differ from
2149 the internal subset in that in them,
2150 <a title="Parameter-entity reference" href="#dt-PERef"
2151 >parameter-entity references</a
2152 >
2153 are permitted <em>within</em> markup declarations, not only
2154 <em>between</em> markup declarations.
2155 </p>
2156 <p>An example of an XML document with a document type declaration:</p>
2157 <div class="exampleInner">
2158 <pre>
2159 &lt;?xml version="1.1"?&gt;
2160 &lt;!DOCTYPE greeting SYSTEM "hello.dtd"&gt;
2161 &lt;greeting&gt;Hello, world!&lt;/greeting&gt; </pre
2162 >
2163 </div>
2164 <p>
2165 The
2166 <a title="System Identifier" href="#dt-sysid">system identifier</a>
2167 "<code>hello.dtd</code>" gives the address (a URI reference) of a
2168 DTD for the document.
2169 </p>
2170 <p>The declarations can also be given locally, as in this example:</p>
2171 <div class="exampleInner">
2172 <pre>
2173 &lt;?xml version="1.1" encoding="UTF-8" ?&gt;
2174 &lt;!DOCTYPE greeting [
2175 &lt;!ELEMENT greeting (#PCDATA)&gt;
2176 ]&gt;
2177 &lt;greeting&gt;Hello, world!&lt;/greeting&gt;</pre
2178 >
2179 </div>
2180 <p>
2181 If both the external and internal subsets are used, the internal
2182 subset
2183 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
2184 considered to occur before the external subset. This has the effect
2185 that entity and attribute-list declarations in the internal subset
2186 take precedence over those in the external subset.
2187 </p>
2188 <p>
2189 If a document is well-formed or valid XML 1.0, and provided it does
2190 not contain any control characters in the range [#x7F-#x9F] other
2191 than as character escapes, it may be made well-formed or valid XML
2192 1.1 respectively simply by changing the version number.
2193 </p>
2194 </div>
2195 <div class="div2">
2196 <h3>
2197 <a name="sec-rmd" id="sec-rmd" />2.9 Standalone Document Declaration
2198 </h3>
2199 <p>
2200 Markup declarations can affect the content of the document, as
2201 passed from an
2202 <a title="XML Processor" href="#dt-xml-proc">XML processor</a> to an
2203 application; examples are attribute defaults and entity
2204 declarations. The standalone document declaration, which
2205 <span>may</span> appear as a component of the XML declaration,
2206 signals whether or not there are such declarations which appear
2207 external to the
2208 <a title="Document Entity" href="#dt-docent">document entity</a> or
2209 in parameter entities. [<a
2210 name="dt-extmkpdecl"
2211 id="dt-extmkpdecl"
2212 title="External Markup Declaration"
2213 >Definition</a
2214 >: An <b>external markup declaration</b> is defined as a markup
2215 declaration occurring in the external subset or in a parameter
2216 entity (external or internal, the latter being included because
2217 non-validating processors are not required to read them).]
2218 </p>
2219 <h5>
2220 <a name="fulldtd" id="fulldtd" />Standalone Document Declaration
2221 </h5>
2222 <table class="scrap" summary="Scrap">
2223 <tbody>
2224 <tr valign="baseline">
2225 <td>
2226 <a name="NT-SDDecl" id="NT-SDDecl" />[32]&nbsp;&nbsp;&nbsp;
2227 </td>
2228 <td><code>SDDecl</code></td>
2229 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
2230 <td>
2231 <code>
2232 <span>
2233 <a href="#NT-S">S</a>
2234 </span>
2235 'standalone' <a href="#NT-Eq">Eq</a> (("'" ('yes' | 'no')
2236 "'") | ('"' ('yes' | 'no') '"'))
2237 </code>
2238 </td>
2239 <td>
2240 <a href="#vc-check-rmd"
2241 >[VC: Standalone Document Declaration]</a
2242 >
2243 </td>
2244 </tr>
2245 </tbody>
2246 </table>
2247 <p>
2248 In a standalone document declaration, the value "yes" indicates that
2249 there are no
2250 <a title="External Markup Declaration" href="#dt-extmkpdecl"
2251 >external markup declarations</a
2252 >
2253 which affect the information passed from the XML processor to the
2254 application. The value "no" indicates that there are or may be such
2255 external markup declarations. Note that the standalone document
2256 declaration only denotes the presence of external
2257 <em>declarations</em>; the presence, in a document, of references to
2258 external <em>entities</em>, when those entities are internally
2259 declared, does not change its standalone status.
2260 </p>
2261 <p>
2262 If there are no external markup declarations, the standalone
2263 document declaration has no meaning. If there are external markup
2264 declarations but there is no standalone document declaration, the
2265 value "no" is assumed.
2266 </p>
2267 <p>
2268 Any XML document for which <code>standalone="no"</code> holds can be
2269 converted algorithmically to a standalone document, which may be
2270 desirable for some network delivery applications.
2271 </p>
2272 <div class="constraint">
2273 <p class="prefix">
2274 <a name="vc-check-rmd" id="vc-check-rmd" /><b
2275 >Validity constraint: Standalone Document Declaration</b
2276 >
2277 </p>
2278 <p>
2279 The standalone document declaration
2280 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2281 have the value "no" if any external markup declarations contain
2282 declarations of:
2283 </p>
2284 <ul>
2285 <li>
2286 <p>
2287 attributes with
2288 <a title="Attribute Default" href="#dt-default">default</a>
2289 values, if elements to which these attributes apply appear in
2290 the document without specifications of values for these
2291 attributes, or
2292 </p>
2293 </li>
2294 <li>
2295 <p>
2296 entities (other than <code>amp</code>, <code>lt</code>,
2297 <code>gt</code>, <code>apos</code>, <code>quot</code>), if
2298 <a title="Entity Reference" href="#dt-entref">references</a>
2299 to those entities appear in the document, or
2300 </p>
2301 </li>
2302 <li>
2303 <p>
2304 attributes with tokenized types, where the attribute appears
2305 in the document with a value such that
2306 <a href="#AVNormalize"><cite>normalization</cite></a>
2307 will produce a different value from that which would be
2308 produced in the absence of the declaration, or
2309 </p>
2310 </li>
2311 <li>
2312 <p>
2313 element types with
2314 <a title="Element content" href="#dt-elemcontent"
2315 >element content</a
2316 >, if white space occurs directly within any instance of those
2317 types.
2318 </p>
2319 </li>
2320 </ul>
2321 </div>
2322 <p>
2323 An example XML declaration with a standalone document declaration:
2324 </p>
2325 <div class="exampleInner">
2326 <pre>&lt;?xml version="1.1" standalone='yes'?&gt;</pre>
2327 </div>
2328 </div>
2329 <div class="div2">
2330 <h3>
2331 <a name="sec-white-space" id="sec-white-space" />2.10 White Space
2332 Handling
2333 </h3>
2334 <p>
2335 In editing XML documents, it is often convenient to use "white
2336 space" (spaces, tabs, and blank lines) to set apart the markup for
2337 greater readability. Such white space is typically not intended for
2338 inclusion in the delivered version of the document. On the other
2339 hand, "significant" white space that should be preserved in the
2340 delivered version is common, for example in poetry and source code.
2341 </p>
2342 <p>
2343 An <a title="XML Processor" href="#dt-xml-proc">XML processor</a>
2344 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2345 always pass all characters in a document that are not markup through
2346 to the application. A
2347 <a title="Validating Processor" href="#dt-validating">
2348 validating XML processor</a
2349 >
2350 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2351 also inform the application which of these characters constitute
2352 white space appearing in
2353 <a title="Element content" href="#dt-elemcontent">element content</a
2354 >.
2355 </p>
2356 <p>
2357 A special <a title="Attribute" href="#dt-attr">attribute</a> named
2358 <code>xml:space</code> <span>may</span> be attached to an element to
2359 signal an intention that in that element, white space should be
2360 preserved by applications. In valid documents, this attribute, like
2361 any other,
2362 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
2363 <a title="Attribute-List Declaration" href="#dt-attdecl"
2364 >declared</a
2365 >
2366 if it is used. When declared, it
2367 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
2368 given as an
2369 <a title="Enumerated Attribute&#xA;Values" href="#dt-enumerated"
2370 >enumerated type</a
2371 >
2372 whose values are one or both of "default" and "preserve". For
2373 example:
2374 </p>
2375 <div class="exampleInner">
2376 <pre>
2377 &lt;!ATTLIST poem xml:space (default|preserve) 'preserve'&gt;
2378 &lt;!ATTLIST pre xml:space (preserve) #FIXED 'preserve'&gt;</pre
2379 >
2380 </div>
2381 <p>
2382 The value "default" signals that applications' default white-space
2383 processing modes are acceptable for this element; the value
2384 "preserve" indicates the intent that applications preserve all the
2385 white space. This declared intent is considered to apply to all
2386 elements within the content of the element where it is specified,
2387 unless overridden with another instance of the
2388 <code>xml:space</code> attribute. This specification does not give
2389 meaning to any value of <code>xml:space</code> other than "default"
2390 and "preserve". It is an error for other values to be specified; the
2391 XML processor
2392 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
2393 report the error or
2394 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
2395 recover by ignoring the attribute specification or by reporting the
2396 (erroneous) value to the application. Applications may ignore or
2397 reject erroneous values.
2398 </p>
2399 <p>
2400 The <a title="Root Element" href="#dt-root">root element</a> of any
2401 document is considered to have signaled no intentions as regards
2402 application space handling, unless it provides a value for this
2403 attribute or the attribute is declared with a default value.
2404 </p>
2405 </div>
2406 <div class="div2">
2407 <h3>
2408 <a name="sec-line-ends" id="sec-line-ends" />2.11 End-of-Line
2409 Handling
2410 </h3>
2411 <p>
2412 XML
2413 <a title="Text Entity" href="#dt-parsedent">parsed entities</a> are
2414 often stored in computer files which, for editing convenience, are
2415 organized into lines. These lines are typically separated by some
2416 combination of the characters CARRIAGE RETURN (#xD) and LINE FEED
2417 (#xA).
2418 </p>
2419 <p>
2420 To simplify the tasks of
2421 <a title="Application" href="#dt-app">applications</a>, the
2422 <a title="XML Processor" href="#dt-xml-proc">XML processor</a>
2423 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2424 behave as if it normalized all line breaks in external parsed
2425 entities (including the document entity) on input, before parsing,
2426 by translating all of the following to a single #xA character:
2427 </p>
2428 <ol class="enumar">
2429 <li><p>the two-character sequence #xD #xA</p></li>
2430 <li><p>the two-character sequence #xD #x85</p></li>
2431 <li><p>the single character #x85</p></li>
2432 <li><p>the single character #x2028</p></li>
2433 <li>
2434 <p>
2435 any #xD character that is not immediately followed by #xA or
2436 #x85.
2437 </p>
2438 </li>
2439 </ol>
2440 <p>
2441 The characters #x85 and #x2028 cannot be reliably recognized and
2442 translated until an entity's encoding declaration (if present) has
2443 been read. Therefore, it is a fatal error to use them within the XML
2444 declaration or text declaration.
2445 </p>
2446 </div>
2447 <div class="div2">
2448 <h3>
2449 <a name="sec-lang-tag" id="sec-lang-tag" />2.12 Language
2450 Identification
2451 </h3>
2452 <p>
2453 In document processing, it is often useful to identify the natural
2454 or formal language in which the content is written. A special
2455 <a title="Attribute" href="#dt-attr">attribute</a> named
2456 <code>xml:lang</code> <span>may</span> be inserted in documents to
2457 specify the language used in the contents and attribute values of
2458 any element in an XML document. In valid documents, this attribute,
2459 like any other,
2460 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
2461 <a title="Attribute-List Declaration" href="#dt-attdecl"
2462 >declared</a
2463 >
2464 if it is used. The values of the attribute are language identifiers
2465 as defined by <a href="#RFC1766">[IETF RFC 3066]</a>,
2466 <cite>Tags for the Identification of Languages</cite>, or its
2467 successor; in addition, the empty string <span>may</span> be
2468 specified.
2469 </p>
2470 <p>(Productions 33 through 38 have been removed.)</p>
2471 <p>For example:</p>
2472 <div class="exampleInner">
2473 <pre>
2474 &lt;p xml:lang="en"&gt;The quick brown fox jumps over the lazy dog.&lt;/p&gt;
2475 &lt;p xml:lang="en-GB"&gt;What colour is it?&lt;/p&gt;
2476 &lt;p xml:lang="en-US"&gt;What color is it?&lt;/p&gt;
2477 &lt;sp who="Faust" desc='leise' xml:lang="de"&gt;
2478 &lt;l&gt;Habe nun, ach! Philosophie,&lt;/l&gt;
2479 &lt;l&gt;Juristerei, und Medizin&lt;/l&gt;
2480 &lt;l&gt;und leider auch Theologie&lt;/l&gt;
2481 &lt;l&gt;durchaus studiert mit hei&amp;#xDF;em Bem&amp;#xFC;h'n.&lt;/l&gt;
2482 &lt;/sp&gt;</pre
2483 >
2484 </div>
2485 <p>
2486 The <span> language specified by</span>
2487 <code>xml:lang</code>
2488
2489 <span> applies</span>
2490 to the element where it is specified<span>
2491 (including the values of its attributes), and to all elements in
2492 its content</span
2493 >
2494 unless overridden with <span> another</span> instance of
2495 <code>xml:lang</code>. In particular, the empty value of
2496 <code>xml:lang</code> is used on an element B to override a
2497 specification of <code>xml:lang</code> on an enclosing element A,
2498 without specifying another language. Within B, it is considered that
2499 there is no language information available, just as if
2500 <code>xml:lang</code> had not been specified on B or any of its
2501 ancestors.<span>
2502 Applications determine which of an element's attribute values and
2503 which parts of its character content, if any, are treated as
2504 language-dependent values described by
2505 <code>xml:lang</code>.</span
2506 >
2507 </p>
2508 <div class="note">
2509 <p class="prefix"><b>Note:</b></p>
2510 <p>
2511 Language information may also be provided by external transport
2512 protocols (e.g. HTTP or MIME). When available, this information
2513 may be used by XML applications, but the more local information
2514 provided by <code>xml:lang</code> should be considered to override
2515 it.
2516 </p>
2517 </div>
2518 <p>
2519 A simple declaration for <code>xml:lang</code> might take the form
2520 </p>
2521 <div class="exampleInner"><pre>xml:lang CDATA #IMPLIED</pre></div>
2522 <p>
2523 but specific default values <span>may</span> also be given, if
2524 appropriate. In a collection of French poems for English students,
2525 with glosses and notes in English, the
2526 <code>xml:lang</code> attribute might be declared this way:
2527 </p>
2528 <div class="exampleInner">
2529 <pre>
2530 &lt;!ATTLIST poem xml:lang CDATA 'fr'&gt;
2531 &lt;!ATTLIST gloss xml:lang CDATA 'en'&gt;
2532 &lt;!ATTLIST note xml:lang CDATA 'en'&gt;</pre
2533 >
2534 </div>
2535 </div>
2536 <div class="div2">
2537 <h3>
2538 <a
2539 name="sec-normalization-checking"
2540 id="sec-normalization-checking"
2541 />2.13 Normalization Checking
2542 </h3>
2543 <p>
2544 All XML
2545 <a title="Text Entity" href="#dt-parsedent"> parsed entities</a>
2546 (including
2547 <a title="Document Entity" href="#dt-docent"> document entities</a>)
2548 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
2549 be
2550 <a title="fully normalized" href="#dt-fullnorm">fully normalized</a>
2551 as per the definition of
2552 <a href="#sec-CharNorm"
2553 ><b>B Definitions for Character Normalization</b></a
2554 >
2555 supplemented by the following definitions of
2556 <em
2557 ><a name="dt-relconst" id="dt-relconst" />relevant constructs</em
2558 >
2559 for XML:
2560 </p>
2561 <ol class="enumar">
2562 <li>
2563 <p>
2564 The
2565 <a title="Replacement Text" href="#dt-repltext">
2566 replacement text</a
2567 >
2568 of all
2569 <a title="Text Entity" href="#dt-parsedent">parsed entities</a>
2570 </p>
2571 </li>
2572 <li>
2573 <p>
2574 All text matching, in context, one of the following productions:
2575 </p>
2576 <ol class="enumla">
2577 <li>
2578 <p>
2579 <a href="#NT-CData"> CData</a>
2580 </p>
2581 </li>
2582 <li>
2583 <p>
2584 <a href="#NT-CharData"> CharData</a>
2585 </p>
2586 </li>
2587 <li>
2588 <p>
2589 <a href="#NT-content"> content</a>
2590 </p>
2591 </li>
2592 <li>
2593 <p>
2594 <a href="#NT-Name"> Name</a>
2595 </p>
2596 </li>
2597 <li>
2598 <p>
2599 <a href="#NT-Nmtoken"> Nmtoken</a>
2600 </p>
2601 </li>
2602 </ol>
2603 </li>
2604 </ol>
2605 <p>
2606 However, a document is still well-formed even if it is not
2607 <a title="fully normalized" href="#dt-fullnorm">fully normalized</a
2608 >. XML processors
2609 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
2610 provide a user option to verify that the document being processed is
2611 in
2612 <a title="fully normalized" href="#dt-fullnorm">fully normalized</a>
2613 form, and report to the application whether it is or not. The option
2614 to not verify
2615 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
2616 be chosen only when the input text is
2617 <a title="certified" href="#dt-certified">certified</a>, as defined
2618 by
2619 <a href="#sec-CharNorm"
2620 ><b>B Definitions for Character Normalization</b></a
2621 >.
2622 </p>
2623 <p>
2624 The verification of full normalization
2625 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
2626 carried out as if by first verifying that the entity is in
2627 <a title="include-normalized" href="#dt-inclnorm"
2628 >include-normalized</a
2629 >
2630 form as defined by
2631 <a href="#sec-CharNorm"
2632 ><b>B Definitions for Character Normalization</b></a
2633 >
2634 and by then verifying that none of the relevant constructs listed
2635 above begins (after character references are expanded) with a
2636 <a title="composing character" href="#dt-compchar"
2637 >composing character</a
2638 >
2639 as defined by
2640 <a href="#sec-CharNorm"
2641 ><b>B Definitions for Character Normalization</b></a
2642 >. Non-validating processors
2643 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2644 ignore possible denormalizations that would be caused by inclusion
2645 of external entities that they do not read.
2646 </p>
2647 <div class="note">
2648 <p class="prefix"><b>Note:</b></p>
2649 <p>
2650 The
2651 <a title="composing character" href="#dt-compchar"
2652 >composing character</a
2653 >
2654 are all Unicode characters of non-zero combining class, plus a
2655 small number of class-zero characters that nevertheless take part
2656 as a non-initial character in certain Unicode canonical
2657 decompositions. Since these characters are meant to follow base
2658 characters, restricting relevant constructs (including content)
2659 from beginning with a
2660 <a title="composing character" href="#dt-compchar"
2661 >composing character</a
2662 >
2663 does not meaningfully diminish the expressiveness of XML.
2664 </p>
2665 </div>
2666 <p>
2667 If, while verifying full normalization, a processor encounters
2668 characters for which it cannot determine the normalization
2669 properties (i.e., characters introduced in a version of Unicode
2670 <a href="#Unicode">[Unicode]</a> later than the one used in the
2671 implementation of the processor), then the processor
2672 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>, at
2673 user option, ignore any possible denormalizations caused by these
2674 characters. The option to ignore those denormalizations
2675 <em class="rfc2119" title="Keyword in RFC 2119 context"
2676 >SHOULD NOT</em
2677 >
2678 be chosen by applications when reliability or security are critical.
2679 </p>
2680 <p>
2681 XML processors
2682 <em class="rfc2119" title="Keyword in RFC 2119 context"
2683 >MUST NOT</em
2684 >
2685 transform the input to be in
2686 <a title="fully normalized" href="#dt-fullnorm">fully normalized</a>
2687 form. XML applications that create XML 1.1 output from either XML
2688 1.1 or XML 1.0 input
2689 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
2690 ensure that the output is
2691 <a title="fully normalized" href="#dt-fullnorm">fully normalized</a
2692 >; it is not necessary for internal processing forms to be
2693 <a title="fully normalized" href="#dt-fullnorm">fully normalized</a
2694 >.
2695 </p>
2696 <p>
2697 The purpose of this section is to strongly encourage XML processors
2698 to ensure that the creators of XML documents have properly
2699 normalized them, so that XML applications can make tests such as
2700 identity comparisons of strings without having to worry about the
2701 different possible "spellings" of strings which Unicode allows.
2702 </p>
2703 <p>
2704 When entities are in a non-Unicode encoding, if the processor
2705 transcodes them to Unicode, it
2706 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
2707 use a normalizing transcoder.
2708 </p>
2709 </div>
2710 </div>
2711 <div class="div1">
2712 <h2>
2713 <a name="sec-logical-struct" id="sec-logical-struct" />3 Logical
2714 Structures
2715 </h2>
2716 <p>
2717 [<a name="dt-element" id="dt-element" title="Element">Definition</a>:
2718 Each
2719 <a title="XML Document" href="#dt-xml-doc">XML document</a> contains
2720 one or more <b>elements</b>, the boundaries of which are either
2721 delimited by <a title="Start-Tag" href="#dt-stag">start-tags</a> and
2722 <a title="End Tag" href="#dt-etag">end-tags</a>, or, for
2723 <a title="Empty" href="#dt-empty">empty</a> elements, by an
2724 <a title="empty-element tag" href="#dt-eetag">empty-element tag</a>.
2725 Each element has a type, identified by name, sometimes called its
2726 "generic identifier" (GI), and <span>may</span> have a set of
2727 attribute specifications.] Each attribute specification has a
2728 <a title="Attribute Name" href="#dt-attrname">name</a> and a
2729 <a title="Attribute Value" href="#dt-attrval">value</a>.
2730 </p>
2731 <h5><a name="IDALUFS" id="IDALUFS" />Element</h5>
2732 <table class="scrap" summary="Scrap">
2733 <tbody>
2734 <tr valign="baseline">
2735 <td>
2736 <a name="NT-element" id="NT-element" />[39]&nbsp;&nbsp;&nbsp;
2737 </td>
2738 <td><code>element</code></td>
2739 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
2740 <td>
2741 <code>
2742 <a href="#NT-EmptyElemTag">EmptyElemTag</a>
2743 </code>
2744 </td>
2745 </tr>
2746 <tr valign="baseline">
2747 <td />
2748 <td />
2749 <td />
2750 <td>
2751 <code
2752 >| <a href="#NT-STag">STag</a>
2753 <a href="#NT-content">content</a>
2754 <a href="#NT-ETag">ETag</a>
2755 </code>
2756 </td>
2757 <td><a href="#GIMatch">[WFC: Element Type Match]</a></td>
2758 </tr>
2759 <tr valign="baseline">
2760 <td />
2761 <td />
2762 <td />
2763 <td />
2764 <td><a href="#elementvalid">[VC: Element Valid]</a></td>
2765 </tr>
2766 </tbody>
2767 </table>
2768 <p>
2769 This specification does not constrain the
2770 <span> application </span>semantics, use, or (beyond syntax) names of
2771 the element types and attributes, except that names beginning with a
2772 match to <code>(('X'|'x')('M'|'m')('L'|'l'))</code> are reserved for
2773 standardization in this or future versions of this specification.
2774 </p>
2775 <div class="constraint">
2776 <p class="prefix">
2777 <a name="GIMatch" id="GIMatch" /><b
2778 >Well-formedness constraint: Element Type Match</b
2779 >
2780 </p>
2781 <p>
2782 The <a href="#NT-Name">Name</a> in an element's end-tag
2783 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2784 match the element type in the start-tag.
2785 </p>
2786 </div>
2787 <div class="constraint">
2788 <p class="prefix">
2789 <a name="elementvalid" id="elementvalid" /><b
2790 >Validity constraint: Element Valid</b
2791 >
2792 </p>
2793 <p>
2794 An element is valid if there is a declaration matching
2795 <a href="#NT-elementdecl">elementdecl</a> where the
2796 <a href="#NT-Name">Name</a> matches the element type, and one of the
2797 following holds:
2798 </p>
2799 <ol class="enumar">
2800 <li>
2801 <p>
2802 The declaration matches <b>EMPTY</b> and the element has no
2803 <a title="Content" href="#dt-content">content</a> (not even
2804 entity references, comments, PIs or white space).
2805 </p>
2806 </li>
2807 <li>
2808 <p>
2809 The declaration matches <a href="#NT-children">children</a> and
2810 the sequence of
2811 <a title="Parent/Child" href="#dt-parentchild"
2812 >child elements</a
2813 >
2814 belongs to the language generated by the regular expression in
2815 the content model, with optional white space, comments and PIs
2816 (i.e. markup matching production [27]
2817 <a href="#NT-Misc">Misc</a>) between the start-tag and the first
2818 child element, between child elements, or between the last child
2819 element and the end-tag. Note that a CDATA section containing
2820 only white space or a reference to an entity whose replacement
2821 text is character references expanding to white space do not
2822 match the nonterminal <a href="#NT-S">S</a>, and hence cannot
2823 appear in these positions; however, a reference to an internal
2824 entity with a literal value consisting of character references
2825 expanding to white space does match <a href="#NT-S">S</a>, since
2826 its replacement text is the white space resulting from expansion
2827 of the character references.
2828 </p>
2829 </li>
2830 <li>
2831 <p>
2832 The declaration matches <a href="#NT-Mixed">Mixed</a>
2833 <span> ,</span> and the content (after replacing any entity
2834 references with their replacement text) consists of
2835 <a title="Character Data" href="#dt-chardata">character data</a>
2836 <span>
2837 (including
2838 <a title="CDATA Section" href="#dt-cdsection"
2839 >CDATA sections</a
2840 >)</span
2841 >, <a title="Comment" href="#dt-comment">comments</a>,
2842 <a title="Processing instruction" href="#dt-pi">PIs</a> and
2843 <a title="Parent/Child" href="#dt-parentchild"
2844 >child elements</a
2845 >
2846 whose types match names in the content model.
2847 </p>
2848 </li>
2849 <li>
2850 <p>
2851 The declaration matches <b>ANY</b>, and the content (after
2852 replacing any entity references with their replacement text)
2853 consists of character data<span>
2854 ,
2855 <a title="CDATA Section" href="#dt-cdsection"
2856 >CDATA sections</a
2857 >, <a title="Comment" href="#dt-comment">comments</a>,
2858 <a title="Processing instruction" href="#dt-pi">PIs</a>
2859 </span>
2860 and
2861 <a title="Parent/Child" href="#dt-parentchild"
2862 >child elements</a
2863 >
2864 whose types have been declared.
2865 </p>
2866 </li>
2867 </ol>
2868 </div>
2869 <div class="div2">
2870 <h3>
2871 <a name="sec-starttags" id="sec-starttags" />3.1 Start-Tags,
2872 End-Tags, and Empty-Element Tags
2873 </h3>
2874 <p>
2875 [<a name="dt-stag" id="dt-stag" title="Start-Tag">Definition</a>:
2876 The beginning of every non-empty XML element is marked by a
2877 <b>start-tag</b>.]
2878 </p>
2879 <h5><a name="IDA10FS" id="IDA10FS" />Start-tag</h5>
2880 <table class="scrap" summary="Scrap">
2881 <tbody>
2882 <tr valign="baseline">
2883 <td><a name="NT-STag" id="NT-STag" />[40]&nbsp;&nbsp;&nbsp;</td>
2884 <td><code>STag</code></td>
2885 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
2886 <td>
2887 <code
2888 >'&lt;' <a href="#NT-Name">Name</a> (<a href="#NT-S">S</a>
2889 <a href="#NT-Attribute">Attribute</a>)*
2890 <a href="#NT-S">S</a>? '&gt;'</code
2891 >
2892 </td>
2893 <td><a href="#uniqattspec">[WFC: Unique Att Spec]</a></td>
2894 </tr>
2895 <tr valign="baseline">
2896 <td>
2897 <a
2898 name="NT-Attribute"
2899 id="NT-Attribute"
2900 />[41]&nbsp;&nbsp;&nbsp;
2901 </td>
2902 <td><code>Attribute</code></td>
2903 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
2904 <td>
2905 <code>
2906 <a href="#NT-Name">Name</a>
2907 <a href="#NT-Eq">Eq</a>
2908 <a href="#NT-AttValue">AttValue</a>
2909 </code>
2910 </td>
2911 <td><a href="#ValueType">[VC: Attribute Value Type]</a></td>
2912 </tr>
2913 <tr valign="baseline">
2914 <td />
2915 <td />
2916 <td />
2917 <td />
2918 <td>
2919 <a href="#NoExternalRefs"
2920 >[WFC: No External Entity References]</a
2921 >
2922 </td>
2923 </tr>
2924 <tr valign="baseline">
2925 <td />
2926 <td />
2927 <td />
2928 <td />
2929 <td>
2930 <a href="#CleanAttrVals"
2931 >[WFC: No &lt; in Attribute Values]</a
2932 >
2933 </td>
2934 </tr>
2935 </tbody>
2936 </table>
2937 <p>
2938 The <a href="#NT-Name">Name</a> in the start- and end-tags gives the
2939 element's <b>type</b>. [<a
2940 name="dt-attr"
2941 id="dt-attr"
2942 title="Attribute"
2943 >Definition</a
2944 >: The <a href="#NT-Name">Name</a>-<a href="#NT-AttValue"
2945 >AttValue</a
2946 >
2947 pairs are referred to as the <b>attribute specifications</b> of the
2948 element], [<a
2949 name="dt-attrname"
2950 id="dt-attrname"
2951 title="Attribute Name"
2952 >Definition</a
2953 >: with the <a href="#NT-Name">Name</a> in each pair referred to as
2954 the <b>attribute name</b> ] and [<a
2955 name="dt-attrval"
2956 id="dt-attrval"
2957 title="Attribute Value"
2958 >Definition</a
2959 >: the content of the <a href="#NT-AttValue">AttValue</a> (the text
2960 between the <code>'</code> or <code>"</code> delimiters) as the
2961 <b>attribute value</b>.] Note that the order of attribute
2962 specifications in a start-tag or empty-element tag is not
2963 significant.
2964 </p>
2965 <div class="constraint">
2966 <p class="prefix">
2967 <a name="uniqattspec" id="uniqattspec" /><b
2968 >Well-formedness constraint: Unique Att Spec</b
2969 >
2970 </p>
2971 <p>
2972 An attribute name
2973 <em class="rfc2119" title="Keyword in RFC 2119 context"
2974 >MUST NOT</em
2975 >
2976 appear more than once in the same start-tag or empty-element tag.
2977 </p>
2978 </div>
2979 <div class="constraint">
2980 <p class="prefix">
2981 <a name="ValueType" id="ValueType" /><b
2982 >Validity constraint: Attribute Value Type</b
2983 >
2984 </p>
2985 <p>
2986 The attribute
2987 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2988 have been declared; the value
2989 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
2990 be of the type declared for it. (For attribute types, see
2991 <a href="#attdecls"><b>3.3 Attribute-List Declarations</b></a
2992 >.)
2993 </p>
2994 </div>
2995 <div class="constraint">
2996 <p class="prefix">
2997 <a name="NoExternalRefs" id="NoExternalRefs" /><b
2998 >Well-formedness constraint: No External Entity References</b
2999 >
3000 </p>
3001 <p>
3002 Attribute values
3003 <em class="rfc2119" title="Keyword in RFC 2119 context"
3004 >MUST NOT</em
3005 >
3006 contain direct or indirect entity references to external entities.
3007 </p>
3008 </div>
3009 <div class="constraint">
3010 <p class="prefix">
3011 <a name="CleanAttrVals" id="CleanAttrVals" /><b
3012 >Well-formedness constraint: No <code>&lt;</code> in Attribute
3013 Values</b
3014 >
3015 </p>
3016 <p>
3017 The
3018 <a title="Replacement Text" href="#dt-repltext"
3019 >replacement text</a
3020 >
3021 of any entity referred to directly or indirectly in an attribute
3022 value
3023 <em class="rfc2119" title="Keyword in RFC 2119 context"
3024 >MUST NOT</em
3025 >
3026 contain a <code>&lt;</code>.
3027 </p>
3028 </div>
3029 <p>An example of a start-tag:</p>
3030 <div class="exampleInner">
3031 <pre>&lt;termdef id="dt-dog" term="dog"&gt;</pre>
3032 </div>
3033 <p>
3034 [<a name="dt-etag" id="dt-etag" title="End Tag">Definition</a>: The
3035 end of every element that begins with a start-tag
3036 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
3037 marked by an <b>end-tag</b> containing a name that echoes the
3038 element's type as given in the start-tag:]
3039 </p>
3040 <h5><a name="IDAZIIS" id="IDAZIIS" />End-tag</h5>
3041 <table class="scrap" summary="Scrap">
3042 <tbody>
3043 <tr valign="baseline">
3044 <td><a name="NT-ETag" id="NT-ETag" />[42]&nbsp;&nbsp;&nbsp;</td>
3045 <td><code>ETag</code></td>
3046 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3047 <td>
3048 <code
3049 >'&lt;/' <a href="#NT-Name">Name</a> <a href="#NT-S">S</a>?
3050 '&gt;'</code
3051 >
3052 </td>
3053 </tr>
3054 </tbody>
3055 </table>
3056 <p>An example of an end-tag:</p>
3057 <div class="exampleInner"><pre>&lt;/termdef&gt;</pre></div>
3058 <p>
3059 [<a name="dt-content" id="dt-content" title="Content">Definition</a
3060 >: The <a title="Text" href="#dt-text">text</a> between the
3061 start-tag and end-tag is called the element's <b>content</b>:]
3062 </p>
3063 <h5><a name="IDAHKIS" id="IDAHKIS" />Content of Elements</h5>
3064 <table class="scrap" summary="Scrap">
3065 <tbody>
3066 <tr valign="baseline">
3067 <td>
3068 <a name="NT-content" id="NT-content" />[43]&nbsp;&nbsp;&nbsp;
3069 </td>
3070 <td><code>content</code></td>
3071 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3072 <td>
3073 <code>
3074 <a href="#NT-CharData">CharData</a>? ((<a href="#NT-element"
3075 >element</a
3076 >
3077 | <a href="#NT-Reference">Reference</a> |
3078 <a href="#NT-CDSect">CDSect</a> | <a href="#NT-PI">PI</a> |
3079 <a href="#NT-Comment">Comment</a>)
3080 <a href="#NT-CharData">CharData</a>?)*</code
3081 >
3082 </td>
3083 </tr>
3084 </tbody>
3085 </table>
3086 <p>
3087 [<a name="dt-empty" id="dt-empty" title="Empty">Definition</a>: An
3088 element with no <a href="#NT-content">content</a> is said to be
3089 <b>empty</b>.] The representation of an empty element is either a
3090 start-tag immediately followed by an end-tag, or an empty-element
3091 tag. [<a name="dt-eetag" id="dt-eetag" title="empty-element tag"
3092 >Definition</a
3093 >: An <b>empty-element tag</b> takes a special form:]
3094 </p>
3095 <h5><a name="IDAMMIS" id="IDAMMIS" />Tags for Empty Elements</h5>
3096 <table class="scrap" summary="Scrap">
3097 <tbody>
3098 <tr valign="baseline">
3099 <td>
3100 <a
3101 name="NT-EmptyElemTag"
3102 id="NT-EmptyElemTag"
3103 />[44]&nbsp;&nbsp;&nbsp;
3104 </td>
3105 <td><code>EmptyElemTag</code></td>
3106 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3107 <td>
3108 <code
3109 >'&lt;' <a href="#NT-Name">Name</a> (<a href="#NT-S">S</a>
3110 <a href="#NT-Attribute">Attribute</a>)*
3111 <a href="#NT-S">S</a>? '/&gt;'</code
3112 >
3113 </td>
3114 <td><a href="#uniqattspec">[WFC: Unique Att Spec]</a></td>
3115 </tr>
3116 </tbody>
3117 </table>
3118 <p>
3119 Empty-element tags <span>may</span> be used for any element which
3120 has no content, whether or not it is declared using the keyword
3121 <b>EMPTY</b>.
3122 <a title="For interoperability" href="#dt-interop"
3123 >For interoperability</a
3124 >, the empty-element tag
3125 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
3126 be used, and
3127 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
3128 only be used, for elements which are declared EMPTY.
3129 </p>
3130 <p>Examples of empty elements:</p>
3131 <div class="exampleInner">
3132 <pre>
3133 &lt;IMG align="left"
3134 src="http://www.w3.org/Icons/WWW/w3c_home" /&gt;
3135 &lt;br&gt;&lt;/br&gt;
3136 &lt;br/&gt;</pre
3137 >
3138 </div>
3139 </div>
3140 <div class="div2">
3141 <h3>
3142 <a name="elemdecls" id="elemdecls" />3.2 Element Type Declarations
3143 </h3>
3144 <p>
3145 The <a title="Element" href="#dt-element">element</a> structure of
3146 an <a title="XML Document" href="#dt-xml-doc">XML document</a>
3147 <span>may</span>, for
3148 <a title="Validity" href="#dt-valid">validation</a> purposes, be
3149 constrained using element type and attribute-list declarations. An
3150 element type declaration constrains the element's
3151 <a title="Content" href="#dt-content">content</a>.
3152 </p>
3153 <p>
3154 Element type declarations often constrain which element types can
3155 appear as
3156 <a title="Parent/Child" href="#dt-parentchild">children</a> of the
3157 element. At user option, an XML processor
3158 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
3159 issue a warning when a declaration mentions an element type for
3160 which no declaration is provided, but this is not an error.
3161 </p>
3162 <p>
3163 [<a name="dt-eldecl" id="dt-eldecl" title="Element Type declaration"
3164 >Definition</a
3165 >: An <b>element type declaration</b> takes the form:]
3166 </p>
3167 <h5><a name="IDAYPIS" id="IDAYPIS" />Element Type Declaration</h5>
3168 <table class="scrap" summary="Scrap">
3169 <tbody>
3170 <tr valign="baseline">
3171 <td>
3172 <a
3173 name="NT-elementdecl"
3174 id="NT-elementdecl"
3175 />[45]&nbsp;&nbsp;&nbsp;
3176 </td>
3177 <td><code>elementdecl</code></td>
3178 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3179 <td>
3180 <code
3181 >'&lt;!ELEMENT' <a href="#NT-S">S</a>
3182 <a href="#NT-Name">Name</a>
3183 <a href="#NT-S">S</a>
3184 <a href="#NT-contentspec">contentspec</a>
3185 <a href="#NT-S">S</a>? '&gt;'</code
3186 >
3187 </td>
3188 <td>
3189 <a href="#EDUnique">[VC: Unique Element Type Declaration]</a>
3190 </td>
3191 </tr>
3192 <tr valign="baseline">
3193 <td>
3194 <a
3195 name="NT-contentspec"
3196 id="NT-contentspec"
3197 />[46]&nbsp;&nbsp;&nbsp;
3198 </td>
3199 <td><code>contentspec</code></td>
3200 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3201 <td>
3202 <code
3203 >'EMPTY' | 'ANY' | <a href="#NT-Mixed">Mixed</a> |
3204 <a href="#NT-children">children</a>
3205 </code>
3206 </td>
3207 </tr>
3208 </tbody>
3209 </table>
3210 <p>
3211 where the <a href="#NT-Name">Name</a> gives the element type being
3212 declared.
3213 </p>
3214 <div class="constraint">
3215 <p class="prefix">
3216 <a name="EDUnique" id="EDUnique" /><b
3217 >Validity constraint: Unique Element Type Declaration</b
3218 >
3219 </p>
3220 <p>
3221 An element type
3222 <em class="rfc2119" title="Keyword in RFC 2119 context"
3223 >MUST NOT</em
3224 >
3225 be declared more than once.
3226 </p>
3227 </div>
3228 <p>Examples of element type declarations:</p>
3229 <div class="exampleInner">
3230 <pre>
3231 &lt;!ELEMENT br EMPTY&gt;
3232 &lt;!ELEMENT p (#PCDATA|emph)* &gt;
3233 &lt;!ELEMENT %name.para; %content.para; &gt;
3234 &lt;!ELEMENT container ANY&gt;</pre
3235 >
3236 </div>
3237 <div class="div3">
3238 <h4>
3239 <a name="sec-element-content" id="sec-element-content" />3.2.1
3240 Element Content
3241 </h4>
3242 <p>
3243 [<a
3244 name="dt-elemcontent"
3245 id="dt-elemcontent"
3246 title="Element content"
3247 >Definition</a
3248 >: An element <a title="Start-Tag" href="#dt-stag">type</a> has
3249 <b>element content</b> when elements of that type
3250 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
3251 contain only
3252 <a title="Parent/Child" href="#dt-parentchild">child</a> elements
3253 (no character data), optionally separated by white space
3254 (characters matching the nonterminal <a href="#NT-S">S</a>).] [<a
3255 name="dt-content-model"
3256 id="dt-content-model"
3257 title="Content model"
3258 >Definition</a
3259 >: In this case, the constraint includes a <b>content model</b>, a
3260 simple grammar governing the allowed types of the child elements
3261 and the order in which they are allowed to appear.] The grammar is
3262 built on content particles (<a href="#NT-cp">cp</a>s), which
3263 consist of names, choice lists of content particles, or sequence
3264 lists of content particles:
3265 </p>
3266 <h5><a name="IDATTIS" id="IDATTIS" />Element-content Models</h5>
3267 <table class="scrap" summary="Scrap">
3268 <tbody>
3269 <tr valign="baseline">
3270 <td>
3271 <a
3272 name="NT-children"
3273 id="NT-children"
3274 />[47]&nbsp;&nbsp;&nbsp;
3275 </td>
3276 <td><code>children</code></td>
3277 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3278 <td>
3279 <code
3280 >(<a href="#NT-choice">choice</a> |
3281 <a href="#NT-seq">seq</a>) ('?' | '*' | '+')?</code
3282 >
3283 </td>
3284 </tr>
3285 <tr valign="baseline">
3286 <td><a name="NT-cp" id="NT-cp" />[48]&nbsp;&nbsp;&nbsp;</td>
3287 <td><code>cp</code></td>
3288 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3289 <td>
3290 <code
3291 >(<a href="#NT-Name">Name</a> |
3292 <a href="#NT-choice">choice</a> |
3293 <a href="#NT-seq">seq</a>) ('?' | '*' | '+')?</code
3294 >
3295 </td>
3296 </tr>
3297 <tr valign="baseline">
3298 <td>
3299 <a name="NT-choice" id="NT-choice" />[49]&nbsp;&nbsp;&nbsp;
3300 </td>
3301 <td><code>choice</code></td>
3302 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3303 <td>
3304 <code
3305 >'(' <a href="#NT-S">S</a>? <a href="#NT-cp">cp</a> (
3306 <a href="#NT-S">S</a>? '|' <a href="#NT-S">S</a>?
3307 <a href="#NT-cp">cp</a> )+ <a href="#NT-S">S</a>?
3308 ')'</code
3309 >
3310 </td>
3311 <td>
3312 <a href="#vc-PEinGroup">[VC: Proper Group/PE Nesting]</a>
3313 </td>
3314 </tr>
3315 <tr valign="baseline">
3316 <td><a name="NT-seq" id="NT-seq" />[50]&nbsp;&nbsp;&nbsp;</td>
3317 <td><code>seq</code></td>
3318 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3319 <td>
3320 <code
3321 >'(' <a href="#NT-S">S</a>? <a href="#NT-cp">cp</a> (
3322 <a href="#NT-S">S</a>? ',' <a href="#NT-S">S</a>?
3323 <a href="#NT-cp">cp</a> )* <a href="#NT-S">S</a>?
3324 ')'</code
3325 >
3326 </td>
3327 <td>
3328 <a href="#vc-PEinGroup">[VC: Proper Group/PE Nesting]</a>
3329 </td>
3330 </tr>
3331 </tbody>
3332 </table>
3333 <p>
3334 where each <a href="#NT-Name">Name</a> is the type of an element
3335 which <span>may</span> appear as a
3336 <a title="Parent/Child" href="#dt-parentchild">child</a>. Any
3337 content particle in a choice list <span>may</span> appear in the
3338 <a title="Element content" href="#dt-elemcontent"
3339 >element content</a
3340 >
3341 at the location where the choice list appears in the grammar;
3342 content particles occurring in a sequence list
3343 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
3344 each appear in the
3345 <a title="Element content" href="#dt-elemcontent"
3346 >element content</a
3347 >
3348 in the order given in the list. The optional character following a
3349 name or list governs whether the element or the content particles
3350 in the list may occur one or more (<code>+</code>), zero or more
3351 (<code>*</code>), or zero or one times (<code>?</code>). The
3352 absence of such an operator means that the element or content
3353 particle
3354 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
3355 appear exactly once. This syntax and meaning are identical to
3356 those used in the productions in this specification.
3357 </p>
3358 <p>
3359 The content of an element matches a content model if and only if
3360 it is possible to trace out a path through the content model,
3361 obeying the sequence, choice, and repetition operators and
3362 matching each element in the content against an element type in
3363 the content model.
3364 <a title="For Compatibility" href="#dt-compat"
3365 >For compatibility</a
3366 >, it is an error if the content model allows an element to match
3367 more than one occurrence of an element type in the content model.
3368 For more information, see
3369 <a href="#determinism"><b>D Deterministic Content Models</b></a
3370 >.
3371 </p>
3372 <div class="constraint">
3373 <p class="prefix">
3374 <a name="vc-PEinGroup" id="vc-PEinGroup" /><b
3375 >Validity constraint: Proper Group/PE Nesting</b
3376 >
3377 </p>
3378 <p>
3379 Parameter-entity
3380 <a title="Replacement Text" href="#dt-repltext"
3381 >replacement text</a
3382 >
3383 <em class="rfc2119" title="Keyword in RFC 2119 context"
3384 >MUST</em
3385 >
3386 be properly nested with parenthesized groups. That is to say, if
3387 either of the opening or closing parentheses in a
3388 <a href="#NT-choice">choice</a>, <a href="#NT-seq">seq</a>, or
3389 <a href="#NT-Mixed">Mixed</a> construct is contained in the
3390 replacement text for a
3391 <a title="Parameter-entity reference" href="#dt-PERef"
3392 >parameter entity</a
3393 >, both
3394 <em class="rfc2119" title="Keyword in RFC 2119 context"
3395 >MUST</em
3396 >
3397 be contained in the same replacement text.
3398 </p>
3399 <p>
3400 <a title="For interoperability" href="#dt-interop"
3401 >For interoperability</a
3402 >, if a parameter-entity reference appears in a
3403 <a href="#NT-choice">choice</a>, <a href="#NT-seq">seq</a>, or
3404 <a href="#NT-Mixed">Mixed</a> construct, its replacement text
3405 <em class="rfc2119" title="Keyword in RFC 2119 context"
3406 >SHOULD</em
3407 >
3408 contain at least one non-blank character, and neither the first
3409 nor last non-blank character of the replacement text
3410 <em class="rfc2119" title="Keyword in RFC 2119 context"
3411 >SHOULD</em
3412 >
3413 be a connector (<code>|</code> or <code>,</code>).
3414 </p>
3415 </div>
3416 <p>Examples of element-content models:</p>
3417 <div class="exampleInner">
3418 <pre>
3419 &lt;!ELEMENT spec (front, body, back?)&gt;
3420 &lt;!ELEMENT div1 (head, (p | list | note)*, div2*)&gt;
3421 &lt;!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*&gt;</pre
3422 >
3423 </div>
3424 </div>
3425 <div class="div3">
3426 <h4>
3427 <a name="sec-mixed-content" id="sec-mixed-content" />3.2.2 Mixed
3428 Content
3429 </h4>
3430 <p>
3431 [<a name="dt-mixed" id="dt-mixed" title="Mixed Content"
3432 >Definition</a
3433 >: An element <a title="Start-Tag" href="#dt-stag">type</a> has
3434 <b>mixed content</b> when elements of that type
3435 <span>may</span> contain character data, optionally interspersed
3436 with
3437 <a title="Parent/Child" href="#dt-parentchild">child</a>
3438 elements.] In this case, the types of the child elements
3439 <span>may</span> be constrained, but not their order or their
3440 number of occurrences:
3441 </p>
3442 <h5><a name="IDAC2IS" id="IDAC2IS" />Mixed-content Declaration</h5>
3443 <table class="scrap" summary="Scrap">
3444 <tbody>
3445 <tr valign="baseline">
3446 <td>
3447 <a name="NT-Mixed" id="NT-Mixed" />[51]&nbsp;&nbsp;&nbsp;
3448 </td>
3449 <td><code>Mixed</code></td>
3450 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3451 <td>
3452 <code
3453 >'(' <a href="#NT-S">S</a>? '#PCDATA' (<a href="#NT-S"
3454 >S</a
3455 >? '|' <a href="#NT-S">S</a>?
3456 <a href="#NT-Name">Name</a>)* <a href="#NT-S">S</a>? ')*'
3457 </code>
3458 </td>
3459 </tr>
3460 <tr valign="baseline">
3461 <td />
3462 <td />
3463 <td />
3464 <td>
3465 <code
3466 >| '(' <a href="#NT-S">S</a>? '#PCDATA'
3467 <a href="#NT-S">S</a>? ')'
3468 </code>
3469 </td>
3470 <td>
3471 <a href="#vc-PEinGroup">[VC: Proper Group/PE Nesting]</a>
3472 </td>
3473 </tr>
3474 <tr valign="baseline">
3475 <td />
3476 <td />
3477 <td />
3478 <td />
3479 <td>
3480 <a href="#vc-MixedChildrenUnique"
3481 >[VC: No Duplicate Types]</a
3482 >
3483 </td>
3484 </tr>
3485 </tbody>
3486 </table>
3487 <p>
3488 where the <a href="#NT-Name">Name</a>s give the types of elements
3489 that may appear as children. The keyword <b>#PCDATA</b> derives
3490 historically from the term "parsed character data."
3491 </p>
3492 <div class="constraint">
3493 <p class="prefix">
3494 <a
3495 name="vc-MixedChildrenUnique"
3496 id="vc-MixedChildrenUnique"
3497 /><b>Validity constraint: No Duplicate Types</b>
3498 </p>
3499 <p>
3500 The same name
3501 <em class="rfc2119" title="Keyword in RFC 2119 context"
3502 >MUST NOT</em
3503 >
3504 appear more than once in a single mixed-content declaration.
3505 </p>
3506 </div>
3507 <p>Examples of mixed content declarations:</p>
3508 <div class="exampleInner">
3509 <pre>
3510 &lt;!ELEMENT p (#PCDATA|a|ul|b|i|em)*&gt;
3511 &lt;!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* &gt;
3512 &lt;!ELEMENT b (#PCDATA)&gt;</pre
3513 >
3514 </div>
3515 </div>
3516 </div>
3517 <div class="div2">
3518 <h3>
3519 <a name="attdecls" id="attdecls" />3.3 Attribute-List Declarations
3520 </h3>
3521 <p>
3522 <a title="Attribute" href="#dt-attr">Attributes</a> are used to
3523 associate name-value pairs with
3524 <a title="Element" href="#dt-element">elements</a>. Attribute
3525 specifications
3526 <em class="rfc2119" title="Keyword in RFC 2119 context"
3527 >MUST NOT</em
3528 >
3529 appear outside of
3530 <a title="Start-Tag" href="#dt-stag">start-tags</a> and
3531 <a title="empty-element tag" href="#dt-eetag">empty-element tags</a
3532 >; thus, the productions used to recognize them appear in
3533 <a href="#sec-starttags"
3534 ><b>3.1 Start-Tags, End-Tags, and Empty-Element Tags</b></a
3535 >. Attribute-list declarations <span>may</span> be used:
3536 </p>
3537 <ul>
3538 <li>
3539 <p>
3540 To define the set of attributes pertaining to a given element
3541 type.
3542 </p>
3543 </li>
3544 <li><p>To establish type constraints for these attributes.</p></li>
3545 <li>
3546 <p>
3547 To provide
3548 <a title="Attribute Default" href="#dt-default"
3549 >default values</a
3550 >
3551 for attributes.
3552 </p>
3553 </li>
3554 </ul>
3555 <p>
3556 [<a
3557 name="dt-attdecl"
3558 id="dt-attdecl"
3559 title="Attribute-List Declaration"
3560 >Definition</a
3561 >: <b>Attribute-list declarations</b> specify the name, data type,
3562 and default value (if any) of each attribute associated with a given
3563 element type:]
3564 </p>
3565 <h5><a name="IDAUAJS" id="IDAUAJS" />Attribute-list Declaration</h5>
3566 <table class="scrap" summary="Scrap">
3567 <tbody>
3568 <tr valign="baseline">
3569 <td>
3570 <a
3571 name="NT-AttlistDecl"
3572 id="NT-AttlistDecl"
3573 />[52]&nbsp;&nbsp;&nbsp;
3574 </td>
3575 <td><code>AttlistDecl</code></td>
3576 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3577 <td>
3578 <code
3579 >'&lt;!ATTLIST' <a href="#NT-S">S</a>
3580 <a href="#NT-Name">Name</a>
3581 <a href="#NT-AttDef">AttDef</a>* <a href="#NT-S">S</a>?
3582 '&gt;'</code
3583 >
3584 </td>
3585 </tr>
3586 </tbody>
3587 <tbody>
3588 <tr valign="baseline">
3589 <td>
3590 <a name="NT-AttDef" id="NT-AttDef" />[53]&nbsp;&nbsp;&nbsp;
3591 </td>
3592 <td><code>AttDef</code></td>
3593 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3594 <td>
3595 <code>
3596 <a href="#NT-S">S</a>
3597 <a href="#NT-Name">Name</a>
3598 <a href="#NT-S">S</a>
3599 <a href="#NT-AttType">AttType</a>
3600 <a href="#NT-S">S</a>
3601 <a href="#NT-DefaultDecl">DefaultDecl</a>
3602 </code>
3603 </td>
3604 </tr>
3605 </tbody>
3606 </table>
3607 <p>
3608 The <a href="#NT-Name">Name</a> in the
3609 <a href="#NT-AttlistDecl">AttlistDecl</a> rule is the type of an
3610 element. At user option, an XML processor
3611 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
3612 issue a warning if attributes are declared for an element type not
3613 itself declared, but this is not an error. The
3614 <a href="#NT-Name">Name</a> in the
3615 <a href="#NT-AttDef">AttDef</a> rule is the name of the attribute.
3616 </p>
3617 <p>
3618 When more than one <a href="#NT-AttlistDecl">AttlistDecl</a> is
3619 provided for a given element type, the contents of all those
3620 provided are merged. When more than one definition is provided for
3621 the same attribute of a given element type, the first declaration is
3622 binding and later declarations are ignored.
3623 <a title="For interoperability" href="#dt-interop"
3624 >For interoperability,</a
3625 >
3626 writers of DTDs <span>may</span> choose to provide at most one
3627 attribute-list declaration for a given element type, at most one
3628 attribute definition for a given attribute name in an attribute-list
3629 declaration, and at least one attribute definition in each
3630 attribute-list declaration. For interoperability, an XML processor
3631 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em> at
3632 user option issue a warning when more than one attribute-list
3633 declaration is provided for a given element type, or more than one
3634 attribute definition is provided for a given attribute, but this is
3635 not an error.
3636 </p>
3637 <div class="div3">
3638 <h4>
3639 <a name="sec-attribute-types" id="sec-attribute-types" />3.3.1
3640 Attribute Types
3641 </h4>
3642 <p>
3643 XML attribute types are of three kinds: a string type, a set of
3644 tokenized types, and enumerated types. The string type may take
3645 any literal string as a value; the tokenized types
3646 <span> are more constrained</span>. The validity constraints noted
3647 in the grammar are applied after the attribute value has been
3648 normalized as described in
3649 <a href="#AVNormalize"
3650 ><b>3.3.3 Attribute-Value Normalization</b></a
3651 >.
3652 </p>
3653 <h5><a name="IDAVEJS" id="IDAVEJS" />Attribute Types</h5>
3654 <table class="scrap" summary="Scrap">
3655 <tbody>
3656 <tr valign="baseline">
3657 <td>
3658 <a
3659 name="NT-AttType"
3660 id="NT-AttType"
3661 />[54]&nbsp;&nbsp;&nbsp;
3662 </td>
3663 <td><code>AttType</code></td>
3664 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3665 <td>
3666 <code>
3667 <a href="#NT-StringType">StringType</a> |
3668 <a href="#NT-TokenizedType">TokenizedType</a> |
3669 <a href="#NT-EnumeratedType">EnumeratedType</a>
3670 </code>
3671 </td>
3672 </tr>
3673 <tr valign="baseline">
3674 <td>
3675 <a
3676 name="NT-StringType"
3677 id="NT-StringType"
3678 />[55]&nbsp;&nbsp;&nbsp;
3679 </td>
3680 <td><code>StringType</code></td>
3681 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3682 <td><code>'CDATA'</code></td>
3683 </tr>
3684 <tr valign="baseline">
3685 <td>
3686 <a
3687 name="NT-TokenizedType"
3688 id="NT-TokenizedType"
3689 />[56]&nbsp;&nbsp;&nbsp;
3690 </td>
3691 <td><code>TokenizedType</code></td>
3692 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3693 <td><code>'ID'</code></td>
3694 <td><a href="#id">[VC: ID]</a></td>
3695 </tr>
3696 <tr valign="baseline">
3697 <td />
3698 <td />
3699 <td />
3700 <td />
3701 <td>
3702 <a href="#one-id-per-el">[VC: One ID per Element Type]</a>
3703 </td>
3704 </tr>
3705 <tr valign="baseline">
3706 <td />
3707 <td />
3708 <td />
3709 <td />
3710 <td><a href="#id-default">[VC: ID Attribute Default]</a></td>
3711 </tr>
3712 <tr valign="baseline">
3713 <td />
3714 <td />
3715 <td />
3716 <td><code>| 'IDREF'</code></td>
3717 <td><a href="#idref">[VC: IDREF]</a></td>
3718 </tr>
3719 <tr valign="baseline">
3720 <td />
3721 <td />
3722 <td />
3723 <td><code>| 'IDREFS'</code></td>
3724 <td><a href="#idref">[VC: IDREF]</a></td>
3725 </tr>
3726 <tr valign="baseline">
3727 <td />
3728 <td />
3729 <td />
3730 <td><code>| 'ENTITY'</code></td>
3731 <td><a href="#entname">[VC: Entity Name]</a></td>
3732 </tr>
3733 <tr valign="baseline">
3734 <td />
3735 <td />
3736 <td />
3737 <td><code>| 'ENTITIES'</code></td>
3738 <td><a href="#entname">[VC: Entity Name]</a></td>
3739 </tr>
3740 <tr valign="baseline">
3741 <td />
3742 <td />
3743 <td />
3744 <td><code>| 'NMTOKEN'</code></td>
3745 <td><a href="#nmtok">[VC: Name Token]</a></td>
3746 </tr>
3747 <tr valign="baseline">
3748 <td />
3749 <td />
3750 <td />
3751 <td><code>| 'NMTOKENS'</code></td>
3752 <td><a href="#nmtok">[VC: Name Token]</a></td>
3753 </tr>
3754 </tbody>
3755 </table>
3756 <div class="constraint">
3757 <p class="prefix">
3758 <a name="id" id="id" /><b>Validity constraint: ID</b>
3759 </p>
3760 <p>
3761 Values of type <b>ID</b>
3762 <em class="rfc2119" title="Keyword in RFC 2119 context"
3763 >MUST</em
3764 >
3765 match the <a href="#NT-Name">Name</a> production. A name
3766 <em class="rfc2119" title="Keyword in RFC 2119 context"
3767 >MUST NOT</em
3768 >
3769 appear more than once in an XML document as a value of this
3770 type; i.e., ID values
3771 <em class="rfc2119" title="Keyword in RFC 2119 context"
3772 >MUST</em
3773 >
3774 uniquely identify the elements which bear them.
3775 </p>
3776 </div>
3777 <div class="constraint">
3778 <p class="prefix">
3779 <a name="one-id-per-el" id="one-id-per-el" /><b
3780 >Validity constraint: One ID per Element Type</b
3781 >
3782 </p>
3783 <p>
3784 An element type
3785 <em class="rfc2119" title="Keyword in RFC 2119 context"
3786 >MUST NOT</em
3787 >
3788 have more than one ID attribute specified.
3789 </p>
3790 </div>
3791 <div class="constraint">
3792 <p class="prefix">
3793 <a name="id-default" id="id-default" /><b
3794 >Validity constraint: ID Attribute Default</b
3795 >
3796 </p>
3797 <p>
3798 An ID attribute
3799 <em class="rfc2119" title="Keyword in RFC 2119 context"
3800 >MUST</em
3801 >
3802 have a declared default of <b>#IMPLIED</b> or <b>#REQUIRED</b>.
3803 </p>
3804 </div>
3805 <div class="constraint">
3806 <p class="prefix">
3807 <a name="idref" id="idref" /><b>Validity constraint: IDREF</b>
3808 </p>
3809 <p>
3810 Values of type <b>IDREF</b>
3811 <em class="rfc2119" title="Keyword in RFC 2119 context"
3812 >MUST</em
3813 >
3814 match the <a href="#NT-Name">Name</a> production, and values of
3815 type <b>IDREFS</b>
3816 <em class="rfc2119" title="Keyword in RFC 2119 context"
3817 >MUST</em
3818 >
3819 match <a href="#NT-Names">Names</a>; each
3820 <a href="#NT-Name">Name</a>
3821 <em class="rfc2119" title="Keyword in RFC 2119 context"
3822 >MUST</em
3823 >
3824 match the value of an ID attribute on some element in the XML
3825 document; i.e. <b>IDREF</b> values
3826 <em class="rfc2119" title="Keyword in RFC 2119 context"
3827 >MUST</em
3828 >
3829 match the value of some ID attribute.
3830 </p>
3831 </div>
3832 <div class="constraint">
3833 <p class="prefix">
3834 <a name="entname" id="entname" /><b
3835 >Validity constraint: Entity Name</b
3836 >
3837 </p>
3838 <p>
3839 Values of type <b>ENTITY</b>
3840 <em class="rfc2119" title="Keyword in RFC 2119 context"
3841 >MUST</em
3842 >
3843 match the <a href="#NT-Name">Name</a> production, values of type
3844 <b>ENTITIES</b>
3845 <em class="rfc2119" title="Keyword in RFC 2119 context"
3846 >MUST</em
3847 >
3848 match <a href="#NT-Names">Names</a>; each
3849 <a href="#NT-Name">Name</a>
3850 <em class="rfc2119" title="Keyword in RFC 2119 context"
3851 >MUST</em
3852 >
3853 match the name of an
3854 <a title="Unparsed Entity" href="#dt-unparsed"
3855 >unparsed entity</a
3856 >
3857 declared in the
3858 <a title="Document Type Declaration" href="#dt-doctype">DTD</a>.
3859 </p>
3860 </div>
3861 <div class="constraint">
3862 <p class="prefix">
3863 <a name="nmtok" id="nmtok" /><b
3864 >Validity constraint: Name Token</b
3865 >
3866 </p>
3867 <p>
3868 Values of type <b>NMTOKEN</b>
3869 <em class="rfc2119" title="Keyword in RFC 2119 context"
3870 >MUST</em
3871 >
3872 match the <a href="#NT-Nmtoken">Nmtoken</a> production; values
3873 of type <b>NMTOKENS</b>
3874 <em class="rfc2119" title="Keyword in RFC 2119 context"
3875 >MUST</em
3876 >
3877 match <a href="#NT-Nmtokens">Nmtokens</a>.
3878 </p>
3879 </div>
3880 <p>
3881 [<a
3882 name="dt-enumerated"
3883 id="dt-enumerated"
3884 title="Enumerated Attribute&#xA;Values"
3885 >Definition</a
3886 >:
3887 <b>Enumerated attributes</b>
3888
3889 <span>have a list of allowed values in their declaration</span>
3890 ].
3891 <span
3892 >They
3893 <em class="rfc2119" title="Keyword in RFC 2119 context"
3894 >MUST</em
3895 >
3896 take one of those values. </span
3897 >There are two kinds of enumerated<span> attribute</span> types:
3898 </p>
3899 <h5><a name="IDAANJS" id="IDAANJS" />Enumerated Attribute Types</h5>
3900 <table class="scrap" summary="Scrap">
3901 <tbody>
3902 <tr valign="baseline">
3903 <td>
3904 <a
3905 name="NT-EnumeratedType"
3906 id="NT-EnumeratedType"
3907 />[57]&nbsp;&nbsp;&nbsp;
3908 </td>
3909 <td><code>EnumeratedType</code></td>
3910 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3911 <td>
3912 <code>
3913 <a href="#NT-NotationType">NotationType</a>
3914 | <a href="#NT-Enumeration">Enumeration</a>
3915 </code>
3916 </td>
3917 </tr>
3918 </tbody>
3919 <tbody>
3920 <tr valign="baseline">
3921 <td>
3922 <a
3923 name="NT-NotationType"
3924 id="NT-NotationType"
3925 />[58]&nbsp;&nbsp;&nbsp;
3926 </td>
3927 <td><code>NotationType</code></td>
3928 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3929 <td>
3930 <code
3931 >'NOTATION' <a href="#NT-S">S</a> '('
3932 <a href="#NT-S">S</a>? <a href="#NT-Name">Name</a> (<a
3933 href="#NT-S"
3934 >S</a
3935 >? '|' <a href="#NT-S">S</a>?
3936 <a href="#NT-Name">Name</a>)* <a href="#NT-S">S</a>? ')'
3937 </code>
3938 </td>
3939 <td><a href="#notatn">[VC: Notation Attributes]</a></td>
3940 </tr>
3941 <tr valign="baseline">
3942 <td />
3943 <td />
3944 <td />
3945 <td />
3946 <td>
3947 <a href="#OneNotationPer"
3948 >[VC: One Notation Per Element Type]</a
3949 >
3950 </td>
3951 </tr>
3952 <tr valign="baseline">
3953 <td />
3954 <td />
3955 <td />
3956 <td />
3957 <td>
3958 <a href="#NoNotationEmpty"
3959 >[VC: No Notation on Empty Element]</a
3960 >
3961 </td>
3962 </tr>
3963 <tr valign="baseline">
3964 <td />
3965 <td />
3966 <td />
3967 <td />
3968 <td>
3969 <a href="#NoDuplicateTokens">[VC: No Duplicate Tokens]</a>
3970 </td>
3971 </tr>
3972 </tbody>
3973 <tbody>
3974 <tr valign="baseline">
3975 <td>
3976 <a
3977 name="NT-Enumeration"
3978 id="NT-Enumeration"
3979 />[59]&nbsp;&nbsp;&nbsp;
3980 </td>
3981 <td><code>Enumeration</code></td>
3982 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
3983 <td>
3984 <code
3985 >'(' <a href="#NT-S">S</a>?
3986 <a href="#NT-Nmtoken">Nmtoken</a> (<a href="#NT-S">S</a>?
3987 '|' <a href="#NT-S">S</a>?
3988 <a href="#NT-Nmtoken">Nmtoken</a>)* <a href="#NT-S">S</a>?
3989 ')'</code
3990 >
3991 </td>
3992 <td><a href="#enum">[VC: Enumeration]</a></td>
3993 </tr>
3994 <tr valign="baseline">
3995 <td />
3996 <td />
3997 <td />
3998 <td />
3999 <td>
4000 <a href="#NoDuplicateTokens">[VC: No Duplicate Tokens]</a>
4001 </td>
4002 </tr>
4003 </tbody>
4004 </table>
4005 <p>
4006 A <b>NOTATION</b> attribute identifies a
4007 <a title="Notation" href="#dt-notation">notation</a>, declared in
4008 the DTD with associated system and/or public identifiers, to be
4009 used in interpreting the element to which the attribute is
4010 attached.
4011 </p>
4012 <div class="constraint">
4013 <p class="prefix">
4014 <a name="notatn" id="notatn" /><b
4015 >Validity constraint: Notation Attributes</b
4016 >
4017 </p>
4018 <p>
4019 Values of this type
4020 <em class="rfc2119" title="Keyword in RFC 2119 context"
4021 >MUST</em
4022 >
4023 match one of the
4024 <a href="#Notations"><cite>notation</cite></a> names included in
4025 the declaration; all notation names in the declaration
4026 <em class="rfc2119" title="Keyword in RFC 2119 context"
4027 >MUST</em
4028 >
4029 be declared.
4030 </p>
4031 </div>
4032 <div class="constraint">
4033 <p class="prefix">
4034 <a name="OneNotationPer" id="OneNotationPer" /><b
4035 >Validity constraint: One Notation Per Element Type</b
4036 >
4037 </p>
4038 <p>
4039 An element type
4040 <em class="rfc2119" title="Keyword in RFC 2119 context"
4041 >MUST NOT</em
4042 >
4043 have more than one <b>NOTATION</b> attribute specified.
4044 </p>
4045 </div>
4046 <div class="constraint">
4047 <p class="prefix">
4048 <a name="NoNotationEmpty" id="NoNotationEmpty" /><b
4049 >Validity constraint: No Notation on Empty Element</b
4050 >
4051 </p>
4052 <p>
4053 <a title="For Compatibility" href="#dt-compat"
4054 >For compatibility</a
4055 >, an attribute of type <b>NOTATION</b>
4056 <em class="rfc2119" title="Keyword in RFC 2119 context"
4057 >MUST NOT</em
4058 >
4059 be declared on an element declared <b>EMPTY</b>.
4060 </p>
4061 </div>
4062 <div class="constraint">
4063 <p class="prefix">
4064 <a name="NoDuplicateTokens" id="NoDuplicateTokens" /><b
4065 >Validity constraint: No Duplicate Tokens</b
4066 >
4067 </p>
4068 <p>
4069 The notation names in a single
4070 <a href="#NT-NotationType">NotationType</a> attribute
4071 declaration, as well as the <a href="#NT-Nmtoken">NmToken</a>s
4072 in a single <a href="#NT-Enumeration">Enumeration</a> attribute
4073 declaration,
4074 <em class="rfc2119" title="Keyword in RFC 2119 context"
4075 >MUST</em
4076 >
4077 all be distinct.
4078 </p>
4079 </div>
4080 <div class="constraint">
4081 <p class="prefix">
4082 <a name="enum" id="enum" /><b
4083 >Validity constraint: Enumeration</b
4084 >
4085 </p>
4086 <p>
4087 Values of this type
4088 <em class="rfc2119" title="Keyword in RFC 2119 context"
4089 >MUST</em
4090 >
4091 match one of the <a href="#NT-Nmtoken">Nmtoken</a> tokens in the
4092 declaration.
4093 </p>
4094 </div>
4095 <p>
4096 <a title="For interoperability" href="#dt-interop"
4097 >For interoperability,</a
4098 >
4099 the same <a href="#NT-Nmtoken">Nmtoken</a>
4100 <em class="rfc2119" title="Keyword in RFC 2119 context"
4101 >SHOULD NOT</em
4102 >
4103 occur more than once in the enumerated attribute types of a single
4104 element type.
4105 </p>
4106 </div>
4107 <div class="div3">
4108 <h4>
4109 <a name="sec-attr-defaults" id="sec-attr-defaults" />3.3.2
4110 Attribute Defaults
4111 </h4>
4112 <p>
4113 An
4114 <a title="Attribute-List Declaration" href="#dt-attdecl"
4115 >attribute declaration</a
4116 >
4117 provides information on whether the attribute's presence is
4118 <em class="rfc2119" title="Keyword in RFC 2119 context"
4119 >REQUIRED</em
4120 >, and if not, how an XML processor is to react if a declared
4121 attribute is absent in a document.
4122 </p>
4123 <h5><a name="IDAGUJS" id="IDAGUJS" />Attribute Defaults</h5>
4124 <table class="scrap" summary="Scrap">
4125 <tbody>
4126 <tr valign="baseline">
4127 <td>
4128 <a
4129 name="NT-DefaultDecl"
4130 id="NT-DefaultDecl"
4131 />[60]&nbsp;&nbsp;&nbsp;
4132 </td>
4133 <td><code>DefaultDecl</code></td>
4134 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4135 <td><code>'#REQUIRED' |&nbsp;'#IMPLIED' </code></td>
4136 </tr>
4137 <tr valign="baseline">
4138 <td />
4139 <td />
4140 <td />
4141 <td>
4142 <code
4143 >| (('#FIXED' <a href="#NT-S">S</a>)?
4144 <a href="#NT-AttValue">AttValue</a>)</code
4145 >
4146 </td>
4147 <td><a href="#RequiredAttr">[VC: Required Attribute]</a></td>
4148 </tr>
4149 <tr valign="baseline">
4150 <td />
4151 <td />
4152 <td />
4153 <td />
4154 <td>
4155 <a href="#defattrvalid"
4156 >[VC: Attribute Default Value Syntactically Correct]</a
4157 >
4158 </td>
4159 </tr>
4160 <tr valign="baseline">
4161 <td />
4162 <td />
4163 <td />
4164 <td />
4165 <td>
4166 <a href="#CleanAttrVals"
4167 >[WFC: No &lt; in Attribute Values]</a
4168 >
4169 </td>
4170 </tr>
4171 <tr valign="baseline">
4172 <td />
4173 <td />
4174 <td />
4175 <td />
4176 <td>
4177 <a href="#FixedAttr">[VC: Fixed Attribute Default]</a>
4178 </td>
4179 </tr>
4180 <tr valign="baseline">
4181 <td />
4182 <td />
4183 <td />
4184 <td />
4185 <td>
4186 <a href="#NoExternalRefs"
4187 >[WFC: No External Entity References]</a
4188 >
4189 </td>
4190 </tr>
4191 </tbody>
4192 </table>
4193 <p>
4194 In an attribute declaration, <b>#REQUIRED</b> means that the
4195 attribute
4196 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4197 always be provided, <b>#IMPLIED</b> that no default value is
4198 provided. [<a
4199 name="dt-default"
4200 id="dt-default"
4201 title="Attribute Default"
4202 >Definition</a
4203 >: If the declaration is neither <b>#REQUIRED</b> nor
4204 <b>#IMPLIED</b>, then the
4205 <a href="#NT-AttValue">AttValue</a> value contains the declared
4206 <b>default</b> value; the <b>#FIXED</b> keyword states that the
4207 attribute
4208 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4209 always have the default value. When an XML processor encounters an
4210 element without a specification for an attribute for which it has
4211 read a default value declaration, it
4212 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4213 report the attribute with the declared default value to the
4214 application.]
4215 </p>
4216 <div class="constraint">
4217 <p class="prefix">
4218 <a name="RequiredAttr" id="RequiredAttr" /><b
4219 >Validity constraint: Required Attribute</b
4220 >
4221 </p>
4222 <p>
4223 If the default declaration is the keyword <b>#REQUIRED</b>, then
4224 the attribute
4225 <em class="rfc2119" title="Keyword in RFC 2119 context"
4226 >MUST</em
4227 >
4228 be specified for all elements of the type in the attribute-list
4229 declaration.
4230 </p>
4231 </div>
4232 <div class="constraint">
4233 <p class="prefix">
4234 <a name="defattrvalid" id="defattrvalid" /><b
4235 >Validity constraint: Attribute Default Value Syntactically
4236 Correct</b
4237 >
4238 </p>
4239 <p>
4240 The declared default value
4241 <em class="rfc2119" title="Keyword in RFC 2119 context"
4242 >MUST</em
4243 >
4244 meet the syntactic constraints of the declared attribute
4245 type.<span> That is, the default value of an attribute:</span>
4246 </p>
4247 <ul>
4248 <li>
4249 <p>
4250 of type IDREF or ENTITY must match the
4251 <a href="#NT-Name">Name</a> production;
4252 </p>
4253 </li>
4254 <li>
4255 <p>
4256 of type IDREFS or ENTITIES must match the
4257 <a href="#NT-Names">Names</a> production;
4258 </p>
4259 </li>
4260 <li>
4261 <p>
4262 of type NMTOKEN must match the
4263 <a href="#NT-Nmtoken">Nmtoken</a> production;
4264 </p>
4265 </li>
4266 <li>
4267 <p>
4268 of type NMTOKENS must match the
4269 <a href="#NT-Nmtokens">Nmtokens</a> production;
4270 </p>
4271 </li>
4272 <li>
4273 <p>
4274 of an
4275 <a href="#NT-EnumeratedType">enumerated type</a> (either a
4276 <a href="#NT-NotationType">NOTATION</a> type or an
4277 <a href="#NT-Enumeration">enumeration</a>) must match one of
4278 the enumerated values.
4279 </p>
4280 </li>
4281 </ul>
4282 <p>
4283 Note that only the syntactic constraints of the type are
4284 required here; other constraints (e.g. that the value be the
4285 name of a declared unparsed entity, for an attribute of type
4286 ENTITY)
4287 <span>
4288 will be reported by a validating parser only if an element
4289 without a specification for this attribute actually
4290 occurs</span
4291 >.
4292 </p>
4293 </div>
4294 <div class="constraint">
4295 <p class="prefix">
4296 <a name="FixedAttr" id="FixedAttr" /><b
4297 >Validity constraint: Fixed Attribute Default</b
4298 >
4299 </p>
4300 <p>
4301 If an attribute has a default value declared with the
4302 <b>#FIXED</b> keyword, instances of that attribute
4303 <em class="rfc2119" title="Keyword in RFC 2119 context"
4304 >MUST</em
4305 >
4306 match the default value.
4307 </p>
4308 </div>
4309 <p>Examples of attribute-list declarations:</p>
4310 <div class="exampleInner">
4311 <pre>
4312 &lt;!ATTLIST termdef
4313 id ID #REQUIRED
4314 name CDATA #IMPLIED&gt;
4315 &lt;!ATTLIST list
4316 type (bullets|ordered|glossary) "ordered"&gt;
4317 &lt;!ATTLIST form
4318 method CDATA #FIXED "POST"&gt;</pre
4319 >
4320 </div>
4321 </div>
4322 <div class="div3">
4323 <h4>
4324 <a name="AVNormalize" id="AVNormalize" />3.3.3 Attribute-Value
4325 Normalization
4326 </h4>
4327 <p>
4328 Before the value of an attribute is passed to the application or
4329 checked for validity, the XML processor
4330 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4331 normalize the attribute value by applying the algorithm below, or
4332 by using some other method such that the value passed to the
4333 application is the same as that produced by the algorithm.
4334 </p>
4335 <ol class="enumar">
4336 <li>
4337 <p>
4338 All line breaks
4339 <em class="rfc2119" title="Keyword in RFC 2119 context"
4340 >MUST</em
4341 >
4342 have been normalized on input to #xA as described in
4343 <a href="#sec-line-ends"><b>2.11 End-of-Line Handling</b></a
4344 >, so the rest of this algorithm operates on text normalized
4345 in this way.
4346 </p>
4347 </li>
4348 <li>
4349 <p>
4350 Begin with a normalized value consisting of the empty string.
4351 </p>
4352 </li>
4353 <li>
4354 <p>
4355 For each character, entity reference, or character reference
4356 in the unnormalized attribute value, beginning with the first
4357 and continuing to the last, do the following:
4358 </p>
4359 <ul>
4360 <li>
4361 <p>
4362 For a character reference, append the referenced character
4363 to the normalized value.
4364 </p>
4365 </li>
4366 <li>
4367 <p>
4368 For an entity reference, recursively apply step 3 of this
4369 algorithm to the replacement text of the entity.
4370 </p>
4371 </li>
4372 <li>
4373 <p>
4374 For a white space character (#x20, #xD, #xA, #x9), append
4375 a space character (#x20) to the normalized value.
4376 </p>
4377 </li>
4378 <li>
4379 <p>
4380 For another character, append the character to the
4381 normalized value.
4382 </p>
4383 </li>
4384 </ul>
4385 </li>
4386 </ol>
4387 <p>
4388 If the attribute type is not CDATA, then the XML processor
4389 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4390 further process the normalized attribute value by discarding any
4391 leading and trailing space (#x20) characters, and by replacing
4392 sequences of space (#x20) characters by a single space (#x20)
4393 character.
4394 </p>
4395 <p>
4396 Note that if the unnormalized attribute value contains a character
4397 reference to a white space character other than space (#x20), the
4398 normalized value contains the referenced character itself (#xD,
4399 #xA or #x9). This contrasts with the case where the unnormalized
4400 value contains a white space character (not a reference), which is
4401 replaced with a space character (#x20) in the normalized value and
4402 also contrasts with the case where the unnormalized value contains
4403 an entity reference whose replacement text contains a white space
4404 character; being recursively processed, the white space character
4405 is replaced with a space character (#x20) in the normalized value.
4406 </p>
4407 <p>
4408 All attributes for which no declaration has been read
4409 <em class="rfc2119" title="Keyword in RFC 2119 context"
4410 >SHOULD</em
4411 >
4412 be treated by a non-validating processor as if declared
4413 <b>CDATA</b>.
4414 </p>
4415 <p>
4416 It is an error if an
4417 <a title="Attribute Value" href="#dt-attrval">attribute value</a>
4418 contains a
4419 <a title="Entity Reference" href="#dt-entref">reference</a> to an
4420 entity for which no declaration has been read.
4421 </p>
4422 <p>
4423 Following are examples of attribute normalization. Given the
4424 following declarations:
4425 </p>
4426 <div class="exampleInner">
4427 <pre>
4428 &lt;!ENTITY d "&amp;#xD;"&gt;
4429 &lt;!ENTITY a "&amp;#xA;"&gt;
4430 &lt;!ENTITY da "&amp;#xD;&amp;#xA;"&gt;</pre
4431 >
4432 </div>
4433 <p>
4434 the attribute specifications in the left column below would be
4435 normalized to the character sequences of the middle column if the
4436 attribute <code>a</code> is declared <b>NMTOKENS</b> and to those
4437 of the right columns if <code>a</code> is declared <b>CDATA</b>.
4438 </p>
4439 <table
4440 border="1"
4441 frame="border"
4442 summary="Attribute normalization summary"
4443 >
4444 <thead>
4445 <tr>
4446 <th>Attribute specification</th>
4447 <th>a is NMTOKENS</th>
4448 <th>a is CDATA</th>
4449 </tr>
4450 </thead>
4451 <tbody>
4452 <tr>
4453 <td>
4454 <div class="exampleInner">
4455 <pre>
4456 a="
4457 xyz"</pre
4458 >
4459 </div>
4460 </td>
4461 <td>
4462 <div class="exampleInner"><pre>x y z</pre></div>
4463 </td>
4464 <td>
4465 <div class="exampleInner"><pre>#x20 #x20 x y z</pre></div>
4466 </td>
4467 </tr>
4468 <tr>
4469 <td>
4470 <div class="exampleInner">
4471 <pre>
4472 a="&amp;d;&amp;d;A&amp;a;&amp;#x20;&amp;a;B&amp;da;"</pre
4473 >
4474 </div>
4475 </td>
4476 <td>
4477 <div class="exampleInner"><pre>A #x20 B</pre></div>
4478 </td>
4479 <td>
4480 <div class="exampleInner">
4481 <pre>#x20 #x20 A #x20 #x20 #x20 B #x20 #x20</pre>
4482 </div>
4483 </td>
4484 </tr>
4485 <tr>
4486 <td>
4487 <div class="exampleInner">
4488 <pre>
4489 a=
4490 "&amp;#xd;&amp;#xd;A&amp;#xa;&amp;#xa;B&amp;#xd;&amp;#xa;"</pre
4491 >
4492 </div>
4493 </td>
4494 <td>
4495 <div class="exampleInner">
4496 <pre>#xD #xD A #xA #xA B #xD #xA</pre>
4497 </div>
4498 </td>
4499 <td>
4500 <div class="exampleInner">
4501 <pre>#xD #xD A #xA #xA B #xD #xA</pre>
4502 </div>
4503 </td>
4504 </tr>
4505 </tbody>
4506 </table>
4507 <p>
4508 Note that the last example is invalid (but well-formed) if
4509 <code>a</code> is declared to be of type <b>NMTOKENS</b>.
4510 </p>
4511 </div>
4512 </div>
4513 <div class="div2">
4514 <h3>
4515 <a name="sec-condition-sect" id="sec-condition-sect" />3.4
4516 Conditional Sections
4517 </h3>
4518 <p>
4519 [<a
4520 name="dt-cond-section"
4521 id="dt-cond-section"
4522 title="conditional section"
4523 >Definition</a
4524 >: <b>Conditional sections</b> are portions of the
4525 <a title="Document Type Declaration" href="#dt-doctype"
4526 >document type declaration external subset</a
4527 >
4528 or of external parameter entities which are included in, or excluded
4529 from, the logical structure of the DTD based on the keyword which
4530 governs them.]
4531 </p>
4532 <h5><a name="IDA1AKS" id="IDA1AKS" />Conditional Section</h5>
4533 <table class="scrap" summary="Scrap">
4534 <tbody>
4535 <tr valign="baseline">
4536 <td>
4537 <a
4538 name="NT-conditionalSect"
4539 id="NT-conditionalSect"
4540 />[61]&nbsp;&nbsp;&nbsp;
4541 </td>
4542 <td><code>conditionalSect</code></td>
4543 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4544 <td>
4545 <code>
4546 <a href="#NT-includeSect">includeSect</a> |
4547 <a href="#NT-ignoreSect">ignoreSect</a>
4548 </code>
4549 </td>
4550 </tr>
4551 <tr valign="baseline">
4552 <td>
4553 <a
4554 name="NT-includeSect"
4555 id="NT-includeSect"
4556 />[62]&nbsp;&nbsp;&nbsp;
4557 </td>
4558 <td><code>includeSect</code></td>
4559 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4560 <td>
4561 <code
4562 >'&lt;![' <a href="#NT-S">S</a>? 'INCLUDE'
4563 <a href="#NT-S">S</a>? '['
4564 <a href="#NT-extSubsetDecl">extSubsetDecl</a> ']]&gt;'
4565 </code>
4566 </td>
4567 <td>
4568 <a href="#condsec-nesting"
4569 >[VC: Proper Conditional Section/PE Nesting]</a
4570 >
4571 </td>
4572 </tr>
4573 <tr valign="baseline">
4574 <td>
4575 <a
4576 name="NT-ignoreSect"
4577 id="NT-ignoreSect"
4578 />[63]&nbsp;&nbsp;&nbsp;
4579 </td>
4580 <td><code>ignoreSect</code></td>
4581 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4582 <td>
4583 <code
4584 >'&lt;![' <a href="#NT-S">S</a>? 'IGNORE'
4585 <a href="#NT-S">S</a>? '['
4586 <a href="#NT-ignoreSectContents">ignoreSectContents</a>*
4587 ']]&gt;'</code
4588 >
4589 </td>
4590 <td>
4591 <a href="#condsec-nesting"
4592 >[VC: Proper Conditional Section/PE Nesting]</a
4593 >
4594 </td>
4595 </tr>
4596 <tr valign="baseline">
4597 <td>
4598 <a
4599 name="NT-ignoreSectContents"
4600 id="NT-ignoreSectContents"
4601 />[64]&nbsp;&nbsp;&nbsp;
4602 </td>
4603 <td><code>ignoreSectContents</code></td>
4604 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4605 <td>
4606 <code>
4607 <a href="#NT-Ignore">Ignore</a> ('&lt;!['
4608 <a href="#NT-ignoreSectContents">ignoreSectContents</a>
4609 ']]&gt;' <a href="#NT-Ignore">Ignore</a>)*</code
4610 >
4611 </td>
4612 </tr>
4613 <tr valign="baseline">
4614 <td>
4615 <a name="NT-Ignore" id="NT-Ignore" />[65]&nbsp;&nbsp;&nbsp;
4616 </td>
4617 <td><code>Ignore</code></td>
4618 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4619 <td>
4620 <code>
4621 <a href="#NT-Char">Char</a>* - (<a href="#NT-Char">Char</a>*
4622 ('&lt;![' | ']]&gt;') <a href="#NT-Char">Char</a>*)
4623 </code>
4624 </td>
4625 </tr>
4626 </tbody>
4627 </table>
4628 <div class="constraint">
4629 <p class="prefix">
4630 <a name="condsec-nesting" id="condsec-nesting" /><b
4631 >Validity constraint: Proper Conditional Section/PE Nesting</b
4632 >
4633 </p>
4634 <p>
4635 If any of the "<code>&lt;![</code>", "<code>[</code>", or
4636 "<code>]]&gt;</code>" of a conditional section is contained in the
4637 replacement text for a parameter-entity reference, all of them
4638 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4639 be contained in the same replacement text.
4640 </p>
4641 </div>
4642 <p>
4643 Like the internal and external DTD subsets, a conditional section
4644 may contain one or more complete declarations, comments, processing
4645 instructions, or nested conditional sections, intermingled with
4646 white space.
4647 </p>
4648 <p>
4649 If the keyword of the conditional section is <b>INCLUDE</b>, then
4650 the contents of the conditional section
4651 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
4652 <span>processed as</span>
4653 part of the DTD. If the keyword of the conditional section is
4654 <b>IGNORE</b>, then the contents of the conditional section
4655 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4656
4657 <span>
4658 <em class="rfc2119" title="Keyword in RFC 2119 context">NOT</em>
4659 be processed as</span
4660 >
4661 part of the DTD. If a conditional section with a keyword of
4662 <b>INCLUDE</b> occurs within a larger conditional section with a
4663 keyword of <b>IGNORE</b>, both the outer and the inner conditional
4664 sections
4665 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
4666 ignored. The contents of an ignored conditional section
4667 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
4668 parsed by ignoring all characters after the "<code>[</code>"
4669 following the keyword, except conditional section starts
4670 "<code>&lt;![</code>" and ends "<code>]]&gt;</code>", until the
4671 matching conditional section end is found. Parameter entity
4672 references
4673 <em class="rfc2119" title="Keyword in RFC 2119 context"
4674 >MUST NOT</em
4675 >
4676 be recognized in this process.
4677 </p>
4678 <p>
4679 If the keyword of the conditional section is a parameter-entity
4680 reference, the parameter entity
4681 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
4682 replaced by its content before the processor decides whether to
4683 include or ignore the conditional section.
4684 </p>
4685 <p>An example:</p>
4686 <div class="exampleInner">
4687 <pre>
4688 &lt;!ENTITY % draft 'INCLUDE' &gt;
4689 &lt;!ENTITY % final 'IGNORE' &gt;
4690 &lt;![%draft;[
4691 &lt;!ELEMENT book (comments*, title, body, supplements?)&gt;
4692 ]]&gt;
4693 &lt;![%final;[
4694 &lt;!ELEMENT book (title, body, supplements?)&gt;
4695 ]]&gt;</pre
4696 >
4697 </div>
4698 </div>
4699 </div>
4700 <div class="div1">
4701 <h2>
4702 <a name="sec-physical-struct" id="sec-physical-struct" />4 Physical
4703 Structures
4704 </h2>
4705 <p>
4706 [<a name="dt-entity" id="dt-entity" title="Entity">Definition</a>: An
4707 XML document may consist of one or many storage units. These are
4708 called <b>entities</b>; they all have <b>content</b> and are all
4709 (except for the
4710 <a title="Document Entity" href="#dt-docent">document entity</a> and
4711 the
4712 <a title="Document Type Declaration" href="#dt-doctype"
4713 >external DTD subset</a
4714 >) identified by entity <b>name</b>.] Each XML document has one entity
4715 called the
4716 <a title="Document Entity" href="#dt-docent">document entity</a>,
4717 which serves as the starting point for the
4718 <a title="XML Processor" href="#dt-xml-proc">XML processor</a> and may
4719 contain the whole document.
4720 </p>
4721 <p>
4722 Entities may be either parsed or unparsed. [<a
4723 name="dt-parsedent"
4724 id="dt-parsedent"
4725 title="Text Entity"
4726 >Definition</a
4727 >: The contents of a <b>parsed entity</b> are referred to as its
4728 <a title="Replacement Text" href="#dt-repltext">replacement text</a>;
4729 this <a title="Text" href="#dt-text">text</a> is considered an
4730 integral part of the document.]
4731 </p>
4732 <p>
4733 [<a name="dt-unparsed" id="dt-unparsed" title="Unparsed Entity"
4734 >Definition</a
4735 >: An <b>unparsed entity</b> is a resource whose contents may or may
4736 not be <a title="Text" href="#dt-text">text</a>, and if text, may be
4737 other than XML. Each unparsed entity has an associated
4738 <a title="Notation" href="#dt-notation">notation</a>, identified by
4739 name. Beyond a requirement that an XML processor make the identifiers
4740 for the entity and notation available to the application, XML places
4741 no constraints on the contents of unparsed entities.]
4742 </p>
4743 <p>
4744 Parsed entities are invoked by name using entity references; unparsed
4745 entities by name, given in the value of <b>ENTITY</b> or
4746 <b>ENTITIES</b> attributes.
4747 </p>
4748 <p>
4749 [<a name="gen-entity" id="gen-entity" title="general entity"
4750 >Definition</a
4751 >:
4752 <b>General entities</b>
4753 are entities for use within the document content. In this
4754 specification, general entities are sometimes referred to with the
4755 unqualified term <em>entity</em> when this leads to no ambiguity.] [<a
4756 name="dt-PE"
4757 id="dt-PE"
4758 title="Parameter entity"
4759 >Definition</a
4760 >: <b>Parameter entities</b> are parsed entities for use within the
4761 DTD.] These two types of entities use different forms of reference and
4762 are recognized in different contexts. Furthermore, they occupy
4763 different namespaces; a parameter entity and a general entity with the
4764 same name are two distinct entities.
4765 </p>
4766 <div class="div2">
4767 <h3>
4768 <a name="sec-references" id="sec-references" />4.1 Character and
4769 Entity References
4770 </h3>
4771 <p>
4772 [<a name="dt-charref" id="dt-charref" title="Character Reference"
4773 >Definition</a
4774 >: A <b>character reference</b> refers to a specific character in
4775 the ISO/IEC 10646 character set, for example one not directly
4776 accessible from available input devices.]
4777 </p>
4778 <h5><a name="IDAOKKS" id="IDAOKKS" />Character Reference</h5>
4779 <table class="scrap" summary="Scrap">
4780 <tbody>
4781 <tr valign="baseline">
4782 <td>
4783 <a name="NT-CharRef" id="NT-CharRef" />[66]&nbsp;&nbsp;&nbsp;
4784 </td>
4785 <td><code>CharRef</code></td>
4786 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4787 <td><code>'&amp;#' [0-9]+ ';' </code></td>
4788 </tr>
4789 <tr valign="baseline">
4790 <td />
4791 <td />
4792 <td />
4793 <td><code>| '&amp;#x' [0-9a-fA-F]+ ';'</code></td>
4794 <td><a href="#wf-Legalchar">[WFC: Legal Character]</a></td>
4795 </tr>
4796 </tbody>
4797 </table>
4798 <div class="constraint">
4799 <p class="prefix">
4800 <a name="wf-Legalchar" id="wf-Legalchar" /><b
4801 >Well-formedness constraint: Legal Character</b
4802 >
4803 </p>
4804 <p>
4805 Characters referred to using character references
4806 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4807 match the production for <a href="#NT-Char">Char</a>.
4808 </p>
4809 </div>
4810 <p>
4811 If the character reference begins with "<code>&amp;#x</code>", the
4812 digits and letters up to the terminating <code>;</code> provide a
4813 hexadecimal representation of the character's code point in ISO/IEC
4814 10646. If it begins just with "<code>&amp;#</code>", the digits up
4815 to the terminating <code>;</code> provide a decimal representation
4816 of the character's code point.
4817 </p>
4818 <p>
4819 [<a name="dt-entref" id="dt-entref" title="Entity Reference"
4820 >Definition</a
4821 >: An <b>entity reference</b> refers to the content of a named
4822 entity.] [<a
4823 name="dt-GERef"
4824 id="dt-GERef"
4825 title="General Entity Reference"
4826 >Definition</a
4827 >: References to parsed general entities use ampersand
4828 (<code>&amp;</code>) and semicolon (<code>;</code>) as delimiters.]
4829 [<a name="dt-PERef" id="dt-PERef" title="Parameter-entity reference"
4830 >Definition</a
4831 >:
4832 <b>Parameter-entity references</b>
4833 use percent-sign (<code>%</code>) and semicolon (<code>;</code>) as
4834 delimiters.]
4835 </p>
4836 <h5><a name="IDA1MKS" id="IDA1MKS" />Entity Reference</h5>
4837 <table class="scrap" summary="Scrap">
4838 <tbody>
4839 <tr valign="baseline">
4840 <td>
4841 <a
4842 name="NT-Reference"
4843 id="NT-Reference"
4844 />[67]&nbsp;&nbsp;&nbsp;
4845 </td>
4846 <td><code>Reference</code></td>
4847 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4848 <td>
4849 <code>
4850 <a href="#NT-EntityRef">EntityRef</a> |
4851 <a href="#NT-CharRef">CharRef</a>
4852 </code>
4853 </td>
4854 </tr>
4855 </tbody>
4856 <tbody>
4857 <tr valign="baseline">
4858 <td>
4859 <a
4860 name="NT-EntityRef"
4861 id="NT-EntityRef"
4862 />[68]&nbsp;&nbsp;&nbsp;
4863 </td>
4864 <td><code>EntityRef</code></td>
4865 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4866 <td>
4867 <code>'&amp;' <a href="#NT-Name">Name</a> ';'</code>
4868 </td>
4869 <td><a href="#wf-entdeclared">[WFC: Entity Declared]</a></td>
4870 </tr>
4871 <tr valign="baseline">
4872 <td />
4873 <td />
4874 <td />
4875 <td />
4876 <td><a href="#vc-entdeclared">[VC: Entity Declared]</a></td>
4877 </tr>
4878 <tr valign="baseline">
4879 <td />
4880 <td />
4881 <td />
4882 <td />
4883 <td><a href="#textent">[WFC: Parsed Entity]</a></td>
4884 </tr>
4885 <tr valign="baseline">
4886 <td />
4887 <td />
4888 <td />
4889 <td />
4890 <td><a href="#norecursion">[WFC: No Recursion]</a></td>
4891 </tr>
4892 </tbody>
4893 <tbody>
4894 <tr valign="baseline">
4895 <td>
4896 <a
4897 name="NT-PEReference"
4898 id="NT-PEReference"
4899 />[69]&nbsp;&nbsp;&nbsp;
4900 </td>
4901 <td><code>PEReference</code></td>
4902 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
4903 <td>
4904 <code>'%' <a href="#NT-Name">Name</a> ';'</code>
4905 </td>
4906 <td><a href="#vc-entdeclared">[VC: Entity Declared]</a></td>
4907 </tr>
4908 <tr valign="baseline">
4909 <td />
4910 <td />
4911 <td />
4912 <td />
4913 <td><a href="#norecursion">[WFC: No Recursion]</a></td>
4914 </tr>
4915 <tr valign="baseline">
4916 <td />
4917 <td />
4918 <td />
4919 <td />
4920 <td><a href="#indtd">[WFC: In DTD]</a></td>
4921 </tr>
4922 </tbody>
4923 </table>
4924 <div class="constraint">
4925 <p class="prefix">
4926 <a name="wf-entdeclared" id="wf-entdeclared" /><b
4927 >Well-formedness constraint: Entity Declared</b
4928 >
4929 </p>
4930 <p>
4931 In a document without any DTD, a document with only an internal
4932 DTD subset which contains no parameter entity references, or a
4933 document with "<code>standalone='yes'</code>", for an entity
4934 reference that does not occur within the external subset or a
4935 parameter entity, the <a href="#NT-Name">Name</a> given in the
4936 entity reference
4937 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4938 <a title="match" href="#dt-match">match</a> that in an
4939 <a href="#sec-entity-decl"><cite>entity declaration</cite></a>
4940 that does not occur within the external subset or a parameter
4941 entity, except that well-formed documents need not declare any of
4942 the following entities: <code>amp</code>, <code>lt</code>,
4943 <code>gt</code>, <code>apos</code>, <code>quot</code>. The
4944 declaration of a general entity
4945 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4946 precede any reference to it which appears in a default value in an
4947 attribute-list declaration.
4948 </p>
4949 <p>
4950 Note that non-validating processors are
4951 <a href="#include-if-valid"><cite>not obligated to</cite></a> to
4952 read and process entity declarations occurring in parameter
4953 entities or in the external subset; for such documents, the rule
4954 that an entity must be declared is a well-formedness constraint
4955 only if <a href="#sec-rmd"><cite>standalone='yes'</cite></a
4956 >.
4957 </p>
4958 </div>
4959 <div class="constraint">
4960 <p class="prefix">
4961 <a name="vc-entdeclared" id="vc-entdeclared" /><b
4962 >Validity constraint: Entity Declared</b
4963 >
4964 </p>
4965 <p>
4966 In a document with an external subset or parameter
4967 <span> entity references</span> with
4968 "<code>standalone='no'</code>", the
4969 <a href="#NT-Name">Name</a> given in the entity reference
4970 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4971 <a title="match" href="#dt-match">match</a> that in an
4972 <a href="#sec-entity-decl"><cite>entity declaration</cite></a
4973 >. For interoperability, valid documents
4974 <em class="rfc2119" title="Keyword in RFC 2119 context"
4975 >SHOULD</em
4976 >
4977 declare the entities <code>amp</code>, <code>lt</code>,
4978 <code>gt</code>, <code>apos</code>, <code>quot</code>, in the form
4979 specified in
4980 <a href="#sec-predefined-ent"><b>4.6 Predefined Entities</b></a
4981 >. The declaration of a parameter entity
4982 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4983 precede any reference to it. Similarly, the declaration of a
4984 general entity
4985 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
4986 precede any attribute-list declaration containing a default value
4987 with a direct or indirect reference to that general entity.
4988 </p>
4989 </div>
4990 <div class="constraint">
4991 <p class="prefix">
4992 <a name="textent" id="textent" /><b
4993 >Well-formedness constraint: Parsed Entity</b
4994 >
4995 </p>
4996 <p>
4997 An entity reference
4998 <em class="rfc2119" title="Keyword in RFC 2119 context"
4999 >MUST NOT</em
5000 >
5001 contain the name of an
5002 <a title="Unparsed Entity" href="#dt-unparsed">unparsed entity</a
5003 >. Unparsed entities may be referred to only in
5004 <a title="Attribute Value" href="#dt-attrval">attribute values</a>
5005 declared to be of type <b>ENTITY</b> or <b>ENTITIES</b>.
5006 </p>
5007 </div>
5008 <div class="constraint">
5009 <p class="prefix">
5010 <a name="norecursion" id="norecursion" /><b
5011 >Well-formedness constraint: No Recursion</b
5012 >
5013 </p>
5014 <p>
5015 A parsed entity
5016 <em class="rfc2119" title="Keyword in RFC 2119 context"
5017 >MUST NOT</em
5018 >
5019 contain a recursive reference to itself, either directly or
5020 indirectly.
5021 </p>
5022 </div>
5023 <div class="constraint">
5024 <p class="prefix">
5025 <a name="indtd" id="indtd" /><b
5026 >Well-formedness constraint: In DTD</b
5027 >
5028 </p>
5029 <p>
5030 Parameter-entity references
5031 <em class="rfc2119" title="Keyword in RFC 2119 context"
5032 >MUST NOT</em
5033 >
5034 appear outside the
5035 <a title="Document Type Declaration" href="#dt-doctype">DTD</a>.
5036 </p>
5037 </div>
5038 <p>Examples of character and entity references:</p>
5039 <div class="exampleInner">
5040 <pre>
5041 Type &lt;key&gt;less-than&lt;/key&gt; (&amp;#x3C;) to save options.
5042 This document was prepared on &amp;docdate; and
5043 is classified &amp;security-level;.</pre
5044 >
5045 </div>
5046 <p>Example of a parameter-entity reference:</p>
5047 <div class="exampleInner">
5048 <pre>
5049 &lt;!-- declare the parameter entity "ISOLat2"... --&gt;
5050 &lt;!ENTITY % ISOLat2
5051 SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" &gt;
5052 &lt;!-- ... now reference it. --&gt;
5053 %ISOLat2;</pre
5054 >
5055 </div>
5056 </div>
5057 <div class="div2">
5058 <h3>
5059 <a name="sec-entity-decl" id="sec-entity-decl" />4.2 Entity
5060 Declarations
5061 </h3>
5062 <p>
5063 [<a name="dt-entdecl" id="dt-entdecl" title="entity declaration"
5064 >Definition</a
5065 >: Entities are declared thus:]
5066 </p>
5067 <h5><a name="IDABVKS" id="IDABVKS" />Entity Declaration</h5>
5068 <table class="scrap" summary="Scrap">
5069 <tbody>
5070 <tr valign="baseline">
5071 <td>
5072 <a
5073 name="NT-EntityDecl"
5074 id="NT-EntityDecl"
5075 />[70]&nbsp;&nbsp;&nbsp;
5076 </td>
5077 <td><code>EntityDecl</code></td>
5078 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5079 <td>
5080 <code>
5081 <a href="#NT-GEDecl">GEDecl</a>
5082 | <a href="#NT-PEDecl">PEDecl</a>
5083 </code>
5084 </td>
5085 </tr>
5086 <tr valign="baseline">
5087 <td>
5088 <a name="NT-GEDecl" id="NT-GEDecl" />[71]&nbsp;&nbsp;&nbsp;
5089 </td>
5090 <td><code>GEDecl</code></td>
5091 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5092 <td>
5093 <code
5094 >'&lt;!ENTITY' <a href="#NT-S">S</a>
5095 <a href="#NT-Name">Name</a>
5096 <a href="#NT-S">S</a>
5097 <a href="#NT-EntityDef">EntityDef</a>
5098 <a href="#NT-S">S</a>? '&gt;'</code
5099 >
5100 </td>
5101 </tr>
5102 <tr valign="baseline">
5103 <td>
5104 <a name="NT-PEDecl" id="NT-PEDecl" />[72]&nbsp;&nbsp;&nbsp;
5105 </td>
5106 <td><code>PEDecl</code></td>
5107 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5108 <td>
5109 <code
5110 >'&lt;!ENTITY' <a href="#NT-S">S</a> '%'
5111 <a href="#NT-S">S</a>
5112 <a href="#NT-Name">Name</a>
5113 <a href="#NT-S">S</a>
5114 <a href="#NT-PEDef">PEDef</a>
5115 <a href="#NT-S">S</a>? '&gt;'</code
5116 >
5117 </td>
5118 </tr>
5119 <tr valign="baseline">
5120 <td>
5121 <a
5122 name="NT-EntityDef"
5123 id="NT-EntityDef"
5124 />[73]&nbsp;&nbsp;&nbsp;
5125 </td>
5126 <td><code>EntityDef</code></td>
5127 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5128 <td>
5129 <code>
5130 <a href="#NT-EntityValue">EntityValue</a>
5131 | (<a href="#NT-ExternalID">ExternalID</a>
5132 <a href="#NT-NDataDecl">NDataDecl</a>?)</code
5133 >
5134 </td>
5135 </tr>
5136 <tr valign="baseline">
5137 <td>
5138 <a name="NT-PEDef" id="NT-PEDef" />[74]&nbsp;&nbsp;&nbsp;
5139 </td>
5140 <td><code>PEDef</code></td>
5141 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5142 <td>
5143 <code>
5144 <a href="#NT-EntityValue">EntityValue</a> |
5145 <a href="#NT-ExternalID">ExternalID</a>
5146 </code>
5147 </td>
5148 </tr>
5149 </tbody>
5150 </table>
5151 <p>
5152 The <a href="#NT-Name">Name</a> identifies the entity in an
5153 <a title="Entity Reference" href="#dt-entref">entity reference</a>
5154 or, in the case of an unparsed entity, in the value of an
5155 <b>ENTITY</b> or <b>ENTITIES</b> attribute. If the same entity is
5156 declared more than once, the first declaration encountered is
5157 binding; at user option, an XML processor
5158 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
5159 issue a warning if entities are declared multiple times.
5160 </p>
5161 <div class="div3">
5162 <h4>
5163 <a name="sec-internal-ent" id="sec-internal-ent" />4.2.1 Internal
5164 Entities
5165 </h4>
5166 <p>
5167 [<a
5168 name="dt-internent"
5169 id="dt-internent"
5170 title="Internal Entity Replacement Text"
5171 >Definition</a
5172 >: If the entity definition is an
5173 <a href="#NT-EntityValue">EntityValue</a>, the defined entity is
5174 called an <b>internal entity</b>. There is no separate physical
5175 storage object, and the content of the entity is given in the
5176 declaration.] Note that some processing of entity and character
5177 references in the
5178 <a title="Literal Entity Value" href="#dt-litentval"
5179 >literal entity value</a
5180 >
5181 may be required to produce the correct
5182 <a title="Replacement Text" href="#dt-repltext"
5183 >replacement text</a
5184 >: see
5185 <a href="#intern-replacement"
5186 ><b>4.5 Construction of Entity Replacement Text</b></a
5187 >.
5188 </p>
5189 <p>
5190 An internal entity is a
5191 <a title="Text Entity" href="#dt-parsedent">parsed entity</a>.
5192 </p>
5193 <p>Example of an internal entity declaration:</p>
5194 <div class="exampleInner">
5195 <pre>
5196 &lt;!ENTITY Pub-Status "This is a pre-release of the
5197 specification."&gt;</pre
5198 >
5199 </div>
5200 </div>
5201 <div class="div3">
5202 <h4>
5203 <a name="sec-external-ent" id="sec-external-ent" />4.2.2 External
5204 Entities
5205 </h4>
5206 <p>
5207 [<a name="dt-extent" id="dt-extent" title="External Entity"
5208 >Definition</a
5209 >: If the entity is not internal, it is an <b>external entity</b>,
5210 declared as follows:]
5211 </p>
5212 <h5>
5213 <a name="IDAX1KS" id="IDAX1KS" />External Entity Declaration
5214 </h5>
5215 <table class="scrap" summary="Scrap">
5216 <tbody>
5217 <tr valign="baseline">
5218 <td>
5219 <a
5220 name="NT-ExternalID"
5221 id="NT-ExternalID"
5222 />[75]&nbsp;&nbsp;&nbsp;
5223 </td>
5224 <td><code>ExternalID</code></td>
5225 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5226 <td>
5227 <code
5228 >'SYSTEM' <a href="#NT-S">S</a>
5229 <a href="#NT-SystemLiteral">SystemLiteral</a>
5230 </code>
5231 </td>
5232 </tr>
5233 <tr valign="baseline">
5234 <td />
5235 <td />
5236 <td />
5237 <td>
5238 <code
5239 >| 'PUBLIC' <a href="#NT-S">S</a>
5240 <a href="#NT-PubidLiteral">PubidLiteral</a>
5241 <a href="#NT-S">S</a>
5242 <a href="#NT-SystemLiteral">SystemLiteral</a>
5243 </code>
5244 </td>
5245 </tr>
5246 </tbody>
5247 <tbody>
5248 <tr valign="baseline">
5249 <td>
5250 <a
5251 name="NT-NDataDecl"
5252 id="NT-NDataDecl"
5253 />[76]&nbsp;&nbsp;&nbsp;
5254 </td>
5255 <td><code>NDataDecl</code></td>
5256 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5257 <td>
5258 <code>
5259 <a href="#NT-S">S</a> 'NDATA' <a href="#NT-S">S</a>
5260 <a href="#NT-Name">Name</a>
5261 </code>
5262 </td>
5263 <td><a href="#not-declared">[VC: Notation Declared]</a></td>
5264 </tr>
5265 </tbody>
5266 </table>
5267 <p>
5268 If the <a href="#NT-NDataDecl">NDataDecl</a> is present, this is a
5269 general
5270 <a title="Unparsed Entity" href="#dt-unparsed">unparsed entity</a
5271 >; otherwise it is a parsed entity.
5272 </p>
5273 <div class="constraint">
5274 <p class="prefix">
5275 <a name="not-declared" id="not-declared" /><b
5276 >Validity constraint: Notation Declared</b
5277 >
5278 </p>
5279 <p>
5280 The <a href="#NT-Name">Name</a>
5281 <em class="rfc2119" title="Keyword in RFC 2119 context"
5282 >MUST</em
5283 >
5284 match the declared name of a
5285 <a title="Notation" href="#dt-notation">notation</a>.
5286 </p>
5287 </div>
5288 <p>
5289 [<a name="dt-sysid" id="dt-sysid" title="System Identifier"
5290 >Definition</a
5291 >: The <a href="#NT-SystemLiteral">SystemLiteral</a> is called the
5292 entity's <b>system identifier</b>. It is meant to be converted to
5293 a URI reference (as defined in
5294 <a href="#rfc3986">[IETF RFC 3986]</a>), as part of the process of
5295 dereferencing it to obtain input for the XML processor to
5296 construct the entity's replacement text.] It is an error for a
5297 fragment identifier (beginning with a <code>#</code> character) to
5298 be part of a system identifier. Unless otherwise provided by
5299 information outside the scope of this specification (e.g. a
5300 special XML element type defined by a particular DTD, or a
5301 processing instruction defined by a particular application
5302 specification), relative URIs are relative to the location of the
5303 resource within which the entity declaration occurs. This is
5304 defined to be the external entity containing the '&lt;' which
5305 starts the declaration, at the point when it is parsed as a
5306 declaration. A URI might thus be relative to the
5307 <a title="Document Entity" href="#dt-docent">document entity</a>,
5308 to the entity containing the
5309 <a title="Document Type Declaration" href="#dt-doctype"
5310 >external DTD subset</a
5311 >, or to some other
5312 <a title="External Entity" href="#dt-extent"
5313 >external parameter entity</a
5314 >. Attempts to retrieve the resource identified by a URI
5315 <span>may</span> be redirected at the parser level (for example,
5316 in an entity resolver) or below (at the protocol level, for
5317 example, via an HTTP <code>Location:</code> header). In the
5318 absence of additional information outside the scope of this
5319 specification within the resource, the base URI of a resource is
5320 always the URI of the actual resource returned. In other words, it
5321 is the URI of the resource retrieved after all redirection has
5322 occurred.
5323 </p>
5324 <p>
5325 System identifiers (and other XML strings meant to be used as URI
5326 references) <span>may</span> contain characters that, according to
5327 <a href="#rfc3986">[IETF RFC 3986]</a>, must be escaped before a
5328 URI can be used to retrieve the referenced resource. The
5329 characters to be escaped are the control characters #x0 to #x1F
5330 and #x7F (most of which cannot appear in XML), space #x20, the
5331 delimiters '&lt;' #x3C, '&gt;' #x3E and '"' #x22, the
5332 <em>unwise</em> characters '{' #x7B, '}' #x7D, '|' #x7C, '\' #x5C,
5333 '^' #x5E and '`' #x60, as well as all characters above #x7F. Since
5334 escaping is not always a fully reversible process, it
5335 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5336 be performed only when absolutely necessary and as late as
5337 possible in a processing chain. In particular, neither the process
5338 of converting a relative URI to an absolute one nor the process of
5339 passing a URI reference to a process or software component
5340 responsible for dereferencing it
5341 <em class="rfc2119" title="Keyword in RFC 2119 context"
5342 >SHOULD</em
5343 >
5344 trigger escaping. When escaping does occur, it
5345 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5346 be performed as follows:
5347 </p>
5348 <ol class="enumar">
5349 <li>
5350 <p>
5351 Each character to be escaped is represented in UTF-8
5352 <a href="#Unicode">[Unicode]</a> as one or more bytes.
5353 </p>
5354 </li>
5355 <li>
5356 <p>
5357 The resulting bytes are escaped with the URI escaping
5358 mechanism (that is, converted to <code>%</code><var>HH</var>,
5359 where HH is the hexadecimal notation of the byte value).
5360 </p>
5361 </li>
5362 <li>
5363 <p>
5364 The original character is replaced by the resulting character
5365 sequence.
5366 </p>
5367 </li>
5368 </ol>
5369 <p>
5370 [<a name="dt-pubid" id="dt-pubid" title="Public identifier"
5371 >Definition</a
5372 >: In addition to a system identifier, an external identifier
5373 <span>may</span> include a <b>public identifier</b>.] An XML
5374 processor attempting to retrieve the entity's content
5375 <span>may</span> use any combination of the public and system
5376 identifiers as well as additional information outside the scope of
5377 this specification to try to generate an alternative URI
5378 reference. If the processor is unable to do so, it
5379 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5380 use the URI reference specified in the system literal. Before a
5381 match is attempted, all strings of white space in the public
5382 identifier
5383 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5384 be normalized to single space characters (#x20), and leading and
5385 trailing white space
5386 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5387 be removed.
5388 </p>
5389 <p>Examples of external entity declarations:</p>
5390 <div class="exampleInner">
5391 <pre>
5392 &lt;!ENTITY open-hatch
5393 SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml"&gt;
5394 &lt;!ENTITY open-hatch
5395 PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"
5396 "http://www.textuality.com/boilerplate/OpenHatch.xml"&gt;
5397 &lt;!ENTITY hatch-pic
5398 SYSTEM "../grafix/OpenHatch.gif"
5399 NDATA gif &gt;</pre
5400 >
5401 </div>
5402 </div>
5403 </div>
5404 <div class="div2">
5405 <h3>
5406 <a name="TextEntities" id="TextEntities" />4.3 Parsed Entities
5407 </h3>
5408 <div class="div3">
5409 <h4>
5410 <a name="sec-TextDecl" id="sec-TextDecl" />4.3.1 The Text
5411 Declaration
5412 </h4>
5413 <p>
5414 External parsed entities
5415 <em class="rfc2119" title="Keyword in RFC 2119 context"
5416 >SHOULD</em
5417 >
5418 each begin with a <b>text declaration</b>.
5419 </p>
5420 <h5><a name="IDAGDLS" id="IDAGDLS" />Text Declaration</h5>
5421 <table class="scrap" summary="Scrap">
5422 <tbody>
5423 <tr valign="baseline">
5424 <td>
5425 <a
5426 name="NT-TextDecl"
5427 id="NT-TextDecl"
5428 />[77]&nbsp;&nbsp;&nbsp;
5429 </td>
5430 <td><code>TextDecl</code></td>
5431 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5432 <td>
5433 <code
5434 >'&lt;?xml' <a href="#NT-VersionInfo">VersionInfo</a>?
5435 <a href="#NT-EncodingDecl">EncodingDecl</a>
5436 <a href="#NT-S">S</a>? '?&gt;'</code
5437 >
5438 </td>
5439 </tr>
5440 </tbody>
5441 </table>
5442 <p>
5443 The text declaration
5444 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5445 be provided literally, not by reference to a parsed entity. The
5446 text declaration
5447 <em class="rfc2119" title="Keyword in RFC 2119 context"
5448 >MUST NOT</em
5449 >
5450 appear at any position other than the beginning of an external
5451 parsed entity. The text declaration in an external parsed entity
5452 is not considered part of its
5453 <a title="Replacement Text" href="#dt-repltext"
5454 >replacement text</a
5455 >.
5456 </p>
5457 </div>
5458 <div class="div3">
5459 <h4>
5460 <a name="wf-entities" id="wf-entities" />4.3.2 Well-Formed Parsed
5461 Entities
5462 </h4>
5463 <p>
5464 The document entity is well-formed if it matches the production
5465 labeled <a href="#NT-document">document</a>. An external general
5466 parsed entity is well-formed if it matches the production labeled
5467 <a href="#NT-extParsedEnt">extParsedEnt</a>. All external
5468 parameter entities are well-formed by definition.
5469 </p>
5470 <div class="note">
5471 <p class="prefix"><b>Note:</b></p>
5472 <p>
5473 Only parsed entities that are referenced directly or indirectly
5474 within the document are required to be well-formed.
5475 </p>
5476 </div>
5477 <h5>
5478 <a name="IDAKFLS" id="IDAKFLS" />Well-Formed External Parsed
5479 Entity
5480 </h5>
5481 <table class="scrap" summary="Scrap">
5482 <tbody>
5483 <tr valign="baseline">
5484 <td>
5485 <a
5486 name="NT-extParsedEnt"
5487 id="NT-extParsedEnt"
5488 />[78]&nbsp;&nbsp;&nbsp;
5489 </td>
5490 <td><code>extParsedEnt</code></td>
5491 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5492 <td>
5493 <code>
5494 <span> (</span>
5495 <a href="#NT-TextDecl">TextDecl</a>?
5496 <a href="#NT-content">content</a> <span> )</span> -
5497 <span> (</span> <a href="#NT-Char">Char</a>*
5498 <a href="#NT-RestrictedChar">RestrictedChar</a>
5499 <a href="#NT-Char">Char</a>*<span> )</span>
5500 </code>
5501 </td>
5502 </tr>
5503 </tbody>
5504 </table>
5505 <p>
5506 An internal general parsed entity is well-formed if its
5507 replacement text matches the production labeled
5508 <a href="#NT-content">content</a>. All internal parameter entities
5509 are well-formed by definition.
5510 </p>
5511 <p>
5512 A consequence of well-formedness in general entities is that the
5513 logical and physical structures in an XML document are properly
5514 nested; no <a title="Start-Tag" href="#dt-stag">start-tag</a>,
5515 <a title="End Tag" href="#dt-etag">end-tag</a>,
5516 <a title="Empty" href="#dt-empty">empty-element tag</a>,
5517 <a title="Element" href="#dt-element">element</a>,
5518 <a title="Comment" href="#dt-comment">comment</a>,
5519 <a title="Processing instruction" href="#dt-pi"
5520 >processing instruction</a
5521 >,
5522 <a title="Character Reference" href="#dt-charref"
5523 >character reference</a
5524 >, or
5525 <a title="Entity Reference" href="#dt-entref">entity reference</a>
5526 can begin in one entity and end in another.
5527 </p>
5528 </div>
5529 <div class="div3">
5530 <h4>
5531 <a name="charencoding" id="charencoding" />4.3.3 Character
5532 Encoding in Entities
5533 </h4>
5534 <p>
5535 Each external parsed entity in an XML document
5536 <span>may</span> use a different encoding for its characters. All
5537 XML processors
5538 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5539 be able to read entities in both the UTF-8 and UTF-16 encodings.
5540 The terms "UTF-8" and "UTF-16" in this specification do not apply
5541 to character encodings with any other labels, even if the
5542 encodings or labels are very similar to UTF-8 or UTF-16.
5543 </p>
5544 <p>
5545 Entities encoded in UTF-16
5546 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5547 and entities encoded in UTF-8
5548 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
5549 begin with the Byte Order Mark described in ISO/IEC 10646
5550 <a href="#ISO10646">[ISO/IEC 10646]</a> or Unicode
5551 <a href="#Unicode">[Unicode]</a> (the ZERO WIDTH NO-BREAK SPACE
5552 character, #xFEFF). This is an encoding signature, not part of
5553 either the markup or the character data of the XML document. XML
5554 processors
5555 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5556 be able to use this character to differentiate between UTF-8 and
5557 UTF-16 encoded documents.
5558 </p>
5559 <p>
5560 Although an XML processor is required to read only entities in the
5561 UTF-8 and UTF-16 encodings, it is recognized that other encodings
5562 are used around the world, and it may be desired for XML
5563 processors to read entities that use them. In the absence of
5564 external character encoding information (such as MIME headers),
5565 parsed entities which are stored in an encoding other than UTF-8
5566 or UTF-16
5567 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5568 begin with a text declaration (see
5569 <a href="#sec-TextDecl"><b>4.3.1 The Text Declaration</b></a
5570 >) containing an encoding declaration:
5571 </p>
5572 <h5><a name="IDABKLS" id="IDABKLS" />Encoding Declaration</h5>
5573 <table class="scrap" summary="Scrap">
5574 <tbody>
5575 <tr valign="baseline">
5576 <td>
5577 <a
5578 name="NT-EncodingDecl"
5579 id="NT-EncodingDecl"
5580 />[80]&nbsp;&nbsp;&nbsp;
5581 </td>
5582 <td><code>EncodingDecl</code></td>
5583 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5584 <td>
5585 <code>
5586 <a href="#NT-S">S</a> 'encoding'
5587 <a href="#NT-Eq">Eq</a> ('"'
5588 <a href="#NT-EncName">EncName</a> '"' | "'"
5589 <a href="#NT-EncName">EncName</a> "'" )
5590 </code>
5591 </td>
5592 </tr>
5593 </tbody>
5594 <tbody>
5595 <tr valign="baseline">
5596 <td>
5597 <a
5598 name="NT-EncName"
5599 id="NT-EncName"
5600 />[81]&nbsp;&nbsp;&nbsp;
5601 </td>
5602 <td><code>EncName</code></td>
5603 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
5604 <td><code>[A-Za-z] ([A-Za-z0-9._] | '-')*</code></td>
5605 <td>
5606 <i>/* Encoding name contains only Latin characters */</i>
5607 </td>
5608 </tr>
5609 </tbody>
5610 </table>
5611 <p>
5612 In the
5613 <a title="Document Entity" href="#dt-docent">document entity</a>,
5614 the encoding declaration is part of the
5615 <a title="XML Declaration" href="#dt-xmldecl">XML declaration</a>.
5616 The <a href="#NT-EncName">EncName</a> is the name of the encoding
5617 used.
5618 </p>
5619 <p>
5620 In an encoding declaration, the values "<code>UTF-8</code>",
5621 "<code>UTF-16</code>", "<code>ISO-10646-UCS-2</code>", and
5622 "<code>ISO-10646-UCS-4</code>"
5623 <em class="rfc2119" title="Keyword in RFC 2119 context"
5624 >SHOULD</em
5625 >
5626 be used for the various encodings and transformations of Unicode /
5627 ISO/IEC 10646, the values "<code>ISO-8859-1</code>",
5628 "<code>ISO-8859-2</code>", ... "<code>ISO-8859-</code
5629 ><var>n</var>" (where <var>n</var> is the part number)
5630 <em class="rfc2119" title="Keyword in RFC 2119 context"
5631 >SHOULD</em
5632 >
5633 be used for the parts of ISO 8859, and the values
5634 "<code>ISO-2022-JP</code>", "<code>Shift_JIS</code>", and
5635 "<code>EUC-JP</code>"
5636 <em class="rfc2119" title="Keyword in RFC 2119 context"
5637 >SHOULD</em
5638 >
5639 be used for the various encoded forms of JIS X-0208-1997. It is
5640 <em class="rfc2119" title="Keyword in RFC 2119 context"
5641 >RECOMMENDED</em
5642 >
5643 that character encodings registered (as <em>charset</em>s) with
5644 the Internet Assigned Numbers Authority
5645 <a href="#IANA">[IANA-CHARSETS]</a>, other than those just listed,
5646 be referred to using their registered names; other encodings
5647 <em class="rfc2119" title="Keyword in RFC 2119 context"
5648 >SHOULD</em
5649 >
5650 use names starting with an "x-" prefix. XML processors
5651 <em class="rfc2119" title="Keyword in RFC 2119 context"
5652 >SHOULD</em
5653 >
5654 match character encoding names in a case-insensitive way and
5655 <em class="rfc2119" title="Keyword in RFC 2119 context"
5656 >SHOULD</em
5657 >
5658 either interpret an IANA-registered name as the encoding
5659 registered at IANA for that name or treat it as unknown
5660 (processors are, of course, not required to support all
5661 IANA-registered encodings).
5662 </p>
5663 <p>
5664 In the absence of information provided by an external transport
5665 protocol (e.g. HTTP or MIME), it is a
5666 <a title="Fatal Error" href="#dt-fatal">fatal error</a> for an
5667 entity including an encoding declaration to be presented to the
5668 XML processor in an encoding other than that named in the
5669 declaration, or for an entity which begins with neither a Byte
5670 Order Mark nor an encoding declaration to use an encoding other
5671 than UTF-8. Note that since ASCII is a subset of UTF-8, ordinary
5672 ASCII entities do not strictly need an encoding declaration.
5673 </p>
5674 <p>
5675 It is a
5676 <a title="Fatal Error" href="#dt-fatal">fatal error</a> for a
5677 <a href="#NT-TextDecl">TextDecl</a> to occur other than at the
5678 beginning of an external entity.
5679 </p>
5680 <p>
5681 It is a
5682 <a title="Fatal Error" href="#dt-fatal">fatal error</a> when an
5683 XML processor encounters an entity with an encoding that it is
5684 unable to process. It is a
5685 <a title="Fatal Error" href="#dt-fatal">fatal error</a> if an XML
5686 entity is determined (via default, encoding declaration, or
5687 higher-level protocol) to be in a certain encoding but contains
5688 byte sequences that are not legal in that encoding. Specifically,
5689 it is a fatal error if an entity encoded in UTF-8 contains any
5690 irregular code unit sequences, as defined in Unicode
5691 <a href="#Unicode">[Unicode]</a>. Unless an encoding is determined
5692 by a higher-level protocol, it is also a
5693 <a title="Fatal Error" href="#dt-fatal">fatal error</a> if an XML
5694 entity contains no encoding declaration and its content is not
5695 legal UTF-8 or UTF-16.
5696 </p>
5697 <p>
5698 Examples of text declarations containing encoding declarations:
5699 </p>
5700 <div class="exampleInner">
5701 <pre>
5702 &lt;?xml encoding='UTF-8'?&gt;
5703 &lt;?xml encoding='EUC-JP'?&gt;</pre
5704 >
5705 </div>
5706 </div>
5707 <div class="div3">
5708 <h4>
5709 <a name="sec-version-info" id="sec-version-info" />4.3.4 Version
5710 Information in Entities
5711 </h4>
5712 <p>
5713 Each entity, including the
5714 <a title="Document Entity" href="#dt-docent">document entity</a>,
5715 can be separately declared as XML 1.0 or XML 1.1. The version
5716 declaration appearing in the document entity determines the
5717 version of the document as a whole. An XML 1.1 document may invoke
5718 XML 1.0 external entities, so that otherwise duplicated versions
5719 of external entities, particularly DTD external subsets, need not
5720 be maintained. However, in such a case the rules of XML 1.1 are
5721 applied to the entire document.
5722 </p>
5723 <p>
5724 If an entity (including the document entity) is not labeled with a
5725 version number, it is treated as if labeled as version 1.0.
5726 </p>
5727 </div>
5728 </div>
5729 <div class="div2">
5730 <h3>
5731 <a name="entproc" id="entproc" />4.4 XML Processor Treatment of
5732 Entities and References
5733 </h3>
5734 <p>
5735 The table below summarizes the contexts in which character
5736 references, entity references, and invocations of unparsed entities
5737 might appear and the
5738 <em class="rfc2119" title="Keyword in RFC 2119 context"
5739 >REQUIRED</em
5740 >
5741 behavior of an
5742 <a title="XML Processor" href="#dt-xml-proc">XML processor</a> in
5743 each case. The labels in the leftmost column describe the
5744 recognition context:
5745 </p>
5746 <dl>
5747 <dt class="label">Reference in Content</dt>
5748 <dd>
5749 <p>
5750 as a reference anywhere after the
5751 <a title="Start-Tag" href="#dt-stag">start-tag</a> and before
5752 the <a title="End Tag" href="#dt-etag">end-tag</a> of an
5753 element; corresponds to the nonterminal
5754 <a href="#NT-content">content</a>.
5755 </p>
5756 </dd>
5757 <dt class="label">Reference in Attribute Value</dt>
5758 <dd>
5759 <p>
5760 as a reference within either the value of an attribute in a
5761 <a title="Start-Tag" href="#dt-stag">start-tag</a>, or a default
5762 value in an
5763 <a title="Attribute-List Declaration" href="#dt-attdecl"
5764 >attribute declaration</a
5765 >; corresponds to the nonterminal
5766 <a href="#NT-AttValue">AttValue</a>.
5767 </p>
5768 </dd>
5769 <dt class="label">Occurs as Attribute Value</dt>
5770 <dd>
5771 <p>
5772 as a <a href="#NT-Name">Name</a>, not a reference, appearing
5773 either as the value of an attribute which has been declared as
5774 type <b>ENTITY</b>, or as one of the space-separated tokens in
5775 the value of an attribute which has been declared as type
5776 <b>ENTITIES</b>.
5777 </p>
5778 </dd>
5779 <dt class="label">Reference in Entity Value</dt>
5780 <dd>
5781 <p>
5782 as a reference within a parameter or internal entity's
5783 <a title="Literal Entity Value" href="#dt-litentval"
5784 >literal entity value</a
5785 >
5786 in the entity's declaration; corresponds to the nonterminal
5787 <a href="#NT-EntityValue">EntityValue</a>.
5788 </p>
5789 </dd>
5790 <dt class="label">Reference in DTD</dt>
5791 <dd>
5792 <p>
5793 as a reference within either the internal or external subsets of
5794 the
5795 <a title="Document Type Declaration" href="#dt-doctype">DTD</a>,
5796 but outside of an <a href="#NT-EntityValue">EntityValue</a>,
5797 <a href="#NT-AttValue">AttValue</a>, <a href="#NT-PI">PI</a>,
5798 <a href="#NT-Comment">Comment</a>,
5799 <a href="#NT-SystemLiteral">SystemLiteral</a>,
5800 <a href="#NT-PubidLiteral">PubidLiteral</a>, or the contents of
5801 an ignored conditional section (see
5802 <a href="#sec-condition-sect"><b>3.4 Conditional Sections</b></a
5803 >).
5804 </p>
5805 <p>.</p>
5806 </dd>
5807 </dl>
5808 <p></p>
5809 <table
5810 border="1"
5811 frame="border"
5812 cellpadding="7"
5813 summary="Entity type/reference matrix"
5814 >
5815 <tbody align="center">
5816 <tr>
5817 <td rowspan="2"></td>
5818 <td colspan="4" align="center" valign="bottom">Entity Type</td>
5819 <td rowspan="2" align="center">Character</td>
5820 </tr>
5821 <tr align="center" valign="bottom">
5822 <td>Parameter</td>
5823 <td>Internal General</td>
5824 <td>External Parsed General</td>
5825 <td>Unparsed</td>
5826 </tr>
5827 <tr align="center" valign="middle">
5828 <td align="right">Reference in Content</td>
5829 <td>
5830 <a href="#not-recognized"><cite>Not recognized</cite></a>
5831 </td>
5832 <td>
5833 <a href="#included"><cite>Included</cite></a>
5834 </td>
5835 <td>
5836 <a href="#include-if-valid"
5837 ><cite>Included if validating</cite></a
5838 >
5839 </td>
5840 <td>
5841 <a href="#forbidden"><cite>Forbidden</cite></a>
5842 </td>
5843 <td>
5844 <a href="#included"><cite>Included</cite></a>
5845 </td>
5846 </tr>
5847 <tr align="center" valign="middle">
5848 <td align="right">Reference in Attribute Value</td>
5849 <td>
5850 <a href="#not-recognized"><cite>Not recognized</cite></a>
5851 </td>
5852 <td>
5853 <a href="#inliteral"><cite>Included in literal</cite></a>
5854 </td>
5855 <td>
5856 <a href="#forbidden"><cite>Forbidden</cite></a>
5857 </td>
5858 <td>
5859 <a href="#forbidden"><cite>Forbidden</cite></a>
5860 </td>
5861 <td>
5862 <a href="#included"><cite>Included</cite></a>
5863 </td>
5864 </tr>
5865 <tr align="center" valign="middle">
5866 <td align="right">Occurs as Attribute Value</td>
5867 <td>
5868 <a href="#not-recognized"><cite>Not recognized</cite></a>
5869 </td>
5870 <td>
5871 <a href="#forbidden"><cite>Forbidden</cite></a>
5872 </td>
5873 <td>
5874 <a href="#forbidden"><cite>Forbidden</cite></a>
5875 </td>
5876 <td>
5877 <a href="#notify"><cite>Notify</cite></a>
5878 </td>
5879 <td>
5880 <a href="#not-recognized"><cite>Not recognized</cite></a>
5881 </td>
5882 </tr>
5883 <tr align="center" valign="middle">
5884 <td align="right">Reference in EntityValue</td>
5885 <td>
5886 <a href="#inliteral"><cite>Included in literal</cite></a>
5887 </td>
5888 <td>
5889 <a href="#bypass"><cite>Bypassed</cite></a>
5890 </td>
5891 <td>
5892 <a href="#bypass"><cite>Bypassed</cite></a>
5893 </td>
5894 <td>
5895 <a href="#error"><cite>Error</cite></a>
5896 </td>
5897 <td>
5898 <a href="#included"><cite>Included</cite></a>
5899 </td>
5900 </tr>
5901 <tr align="center" valign="middle">
5902 <td align="right">Reference in DTD</td>
5903 <td>
5904 <a href="#as-PE"><cite>Included as PE</cite></a>
5905 </td>
5906 <td>
5907 <a href="#forbidden"><cite>Forbidden</cite></a>
5908 </td>
5909 <td>
5910 <a href="#forbidden"><cite>Forbidden</cite></a>
5911 </td>
5912 <td>
5913 <a href="#forbidden"><cite>Forbidden</cite></a>
5914 </td>
5915 <td>
5916 <a href="#forbidden"><cite>Forbidden</cite></a>
5917 </td>
5918 </tr>
5919 </tbody>
5920 </table>
5921 <div class="div3">
5922 <h4>
5923 <a name="not-recognized" id="not-recognized" />4.4.1 Not
5924 Recognized
5925 </h4>
5926 <p>
5927 Outside the DTD, the <code>%</code> character has no special
5928 significance; thus, what would be parameter entity references in
5929 the DTD are not recognized as markup in
5930 <a href="#NT-content">content</a>. Similarly, the names of
5931 unparsed entities are not recognized except when they appear in
5932 the value of an appropriately declared attribute.
5933 </p>
5934 </div>
5935 <div class="div3">
5936 <h4><a name="included" id="included" />4.4.2 Included</h4>
5937 <p>
5938 [<a name="dt-include" id="dt-include" title="Include"
5939 >Definition</a
5940 >: An entity is <b>included</b> when its
5941 <a title="Replacement Text" href="#dt-repltext"
5942 >replacement text</a
5943 >
5944 is retrieved and processed, in place of the reference itself, as
5945 though it were part of the document at the location the reference
5946 was recognized.] The replacement text <span>may</span> contain
5947 both
5948 <a title="Character Data" href="#dt-chardata">character data</a>
5949 and (except for parameter entities)
5950 <a title="Markup" href="#dt-markup">markup</a>, which
5951 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5952 be recognized in the usual way. (The string
5953 "<code>AT&amp;amp;T;</code>" expands to "<code>AT&amp;T;</code>"
5954 and the remaining ampersand is not recognized as an
5955 entity-reference delimiter.) A character reference is
5956 <b>included</b> when the indicated character is processed in place
5957 of the reference itself.
5958 </p>
5959 </div>
5960 <div class="div3">
5961 <h4>
5962 <a name="include-if-valid" id="include-if-valid" />4.4.3 Included
5963 If Validating
5964 </h4>
5965 <p>
5966 When an XML processor recognizes a reference to a parsed entity,
5967 in order to <a title="Validity" href="#dt-valid">validate</a> the
5968 document, the processor
5969 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5970 <a title="Include" href="#dt-include">include</a> its replacement
5971 text. If the entity is external, and the processor is not
5972 attempting to validate the XML document, the processor
5973 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>,
5974 but need not, include the entity's replacement text. If a
5975 non-validating processor does not include the replacement text, it
5976 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
5977 inform the application that it recognized, but did not read, the
5978 entity.
5979 </p>
5980 <p>
5981 This rule is based on the recognition that the automatic inclusion
5982 provided by the SGML and XML entity mechanism, primarily designed
5983 to support modularity in authoring, is not necessarily appropriate
5984 for other applications, in particular document browsing. Browsers,
5985 for example, when encountering an external parsed entity
5986 reference, might choose to provide a visual indication of the
5987 entity's presence and retrieve it for display only on demand.
5988 </p>
5989 </div>
5990 <div class="div3">
5991 <h4><a name="forbidden" id="forbidden" />4.4.4 Forbidden</h4>
5992 <p>
5993 The following are forbidden, and constitute
5994 <a title="Fatal Error" href="#dt-fatal">fatal errors</a>:
5995 </p>
5996 <ul>
5997 <li>
5998 <p>
5999 the appearance of a reference to an
6000 <a title="Unparsed Entity" href="#dt-unparsed"
6001 >unparsed entity</a
6002 >, except in the <a href="#NT-EntityValue">EntityValue</a> in
6003 an entity declaration.
6004 </p>
6005 </li>
6006 <li>
6007 <p>
6008 the appearance of any character or general-entity reference in
6009 the DTD except within an
6010 <a href="#NT-EntityValue">EntityValue</a> or
6011 <a href="#NT-AttValue">AttValue</a>.
6012 </p>
6013 </li>
6014 <li>
6015 <p>a reference to an external entity in an attribute value.</p>
6016 </li>
6017 </ul>
6018 </div>
6019 <div class="div3">
6020 <h4>
6021 <a name="inliteral" id="inliteral" />4.4.5 Included in Literal
6022 </h4>
6023 <p>
6024 When an
6025 <a title="Entity Reference" href="#dt-entref">entity reference</a>
6026 appears in an attribute value, or a parameter entity reference
6027 appears in a literal entity value, its
6028 <a title="Replacement Text" href="#dt-repltext"
6029 >replacement text</a
6030 >
6031 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6032 be processed in place of the reference itself as though it were
6033 part of the document at the location the reference was recognized,
6034 except that a single or double quote character in the replacement
6035 text
6036 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6037 always be treated as a normal data character and
6038 <em class="rfc2119" title="Keyword in RFC 2119 context"
6039 >MUST NOT</em
6040 >
6041 terminate the literal. For example, this is well-formed:
6042 </p>
6043 <div class="exampleInner">
6044 <pre>
6045 &lt;!ENTITY % YN '"Yes"' &gt;
6046 &lt;!ENTITY WhatHeSaid "He said %YN;" &gt;</pre
6047 >
6048 </div>
6049 <p>while this is not:</p>
6050 <div class="exampleInner">
6051 <pre>
6052 &lt;!ENTITY EndAttr "27'" &gt;
6053 &lt;element attribute='a-&amp;EndAttr;&gt;</pre
6054 >
6055 </div>
6056 </div>
6057 <div class="div3">
6058 <h4><a name="notify" id="notify" />4.4.6 Notify</h4>
6059 <p>
6060 When the name of an
6061 <a title="Unparsed Entity" href="#dt-unparsed">unparsed entity</a>
6062 appears as a token in the value of an attribute of declared type
6063 <b>ENTITY</b> or <b>ENTITIES</b>, a validating processor
6064 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6065 inform the application of the
6066 <a title="System Identifier" href="#dt-sysid">system</a> and
6067 <a title="Public identifier" href="#dt-pubid">public</a> (if any)
6068 identifiers for both the entity and its associated
6069 <a title="Notation" href="#dt-notation">notation</a>.
6070 </p>
6071 </div>
6072 <div class="div3">
6073 <h4><a name="bypass" id="bypass" />4.4.7 Bypassed</h4>
6074 <p>
6075 When a general entity reference appears in the
6076 <a href="#NT-EntityValue">EntityValue</a> in an entity
6077 declaration, it
6078 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6079 be bypassed and left as is.
6080 </p>
6081 </div>
6082 <div class="div3">
6083 <h4><a name="as-PE" id="as-PE" />4.4.8 Included as PE</h4>
6084 <p>
6085 Just as with external parsed entities, parameter entities need
6086 only be
6087 <a href="#include-if-valid"><cite>included if validating</cite></a
6088 >. When a parameter-entity reference is recognized in the DTD and
6089 included, its
6090 <a title="Replacement Text" href="#dt-repltext"
6091 >replacement text</a
6092 >
6093 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6094 be enlarged by the attachment of one leading and one following
6095 space (#x20) character; the intent is to constrain the replacement
6096 text of parameter entities to contain an integral number of
6097 grammatical tokens in the DTD. This behavior
6098 <em class="rfc2119" title="Keyword in RFC 2119 context"
6099 >MUST NOT</em
6100 >
6101 apply to parameter entity references within entity values; these
6102 are described in
6103 <a href="#inliteral"><b>4.4.5 Included in Literal</b></a
6104 >.
6105 </p>
6106 </div>
6107 <div class="div3">
6108 <h4><a name="error" id="error" />4.4.9 Error</h4>
6109 <p>
6110 It is an <a title="Error" href="#dt-error">error</a> for a
6111 reference to an unparsed entity to appear in the
6112 <a href="#NT-EntityValue">EntityValue</a> in an entity
6113 declaration.
6114 </p>
6115 </div>
6116 </div>
6117 <div class="div2">
6118 <h3>
6119 <a name="intern-replacement" id="intern-replacement" />4.5
6120 Construction of Entity Replacement Text
6121 </h3>
6122 <p>
6123 In discussing the treatment of entities, it is useful to distinguish
6124 two forms of the entity's value. [<a
6125 name="dt-litentval"
6126 id="dt-litentval"
6127 title="Literal Entity Value"
6128 >Definition</a
6129 >: For an internal entity, the <b>literal entity value</b> is the
6130 quoted string actually present in the entity declaration,
6131 corresponding to the non-terminal
6132 <a href="#NT-EntityValue">EntityValue</a>.] [<a
6133 name="dt-extlitentval"
6134 id="dt-extlitentval"
6135 title="Literal Entity Value"
6136 >Definition</a
6137 >: For an external entity, the <b>literal entity value</b> is the
6138 exact text contained in the entity.] [<a
6139 name="dt-repltext"
6140 id="dt-repltext"
6141 title="Replacement Text"
6142 >Definition</a
6143 >: For an internal entity, the <b>replacement text</b> is the
6144 content of the entity, after replacement of character references and
6145 parameter-entity references.] [<a
6146 name="dt-extrepltext"
6147 id="dt-extrepltext"
6148 title="Replacement Text"
6149 >Definition</a
6150 >: For an external entity, the <b>replacement text</b> is the
6151 content of the entity, after stripping the text declaration (leaving
6152 any surrounding white space) if there is one but without any
6153 replacement of character references or parameter-entity references.]
6154 </p>
6155 <p>
6156 The literal entity value as given in an internal entity declaration
6157 (<a href="#NT-EntityValue">EntityValue</a>) <span>may</span> contain
6158 character, parameter-entity, and general-entity references. Such
6159 references
6160 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
6161 contained entirely within the literal entity value. The actual
6162 replacement text that is
6163 <a title="Include" href="#dt-include">included</a> (or
6164 <a title="" href="#inliteral">included in literal</a>) as described
6165 above
6166 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6167 contain the <em>replacement text</em> of any parameter entities
6168 referred to, and
6169 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6170 contain the character referred to, in place of any character
6171 references in the literal entity value; however, general-entity
6172 references
6173 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
6174 left as-is, unexpanded. For example, given the following
6175 declarations:
6176 </p>
6177 <div class="exampleInner">
6178 <pre>
6179 &lt;!ENTITY % pub "&amp;#xc9;ditions Gallimard" &gt;
6180 &lt;!ENTITY rights "All rights reserved" &gt;
6181 &lt;!ENTITY book "La Peste: Albert Camus,
6182 &amp;#xA9; 1947 %pub;. &amp;rights;" &gt;</pre
6183 >
6184 </div>
6185 <p>
6186 then the replacement text for the entity "<code>book</code>" is:
6187 </p>
6188 <div class="exampleInner">
6189 <pre>
6190 La Peste: Albert Camus,
6191 © 1947 Éditions Gallimard. &amp;rights;</pre
6192 >
6193 </div>
6194 <p>
6195 The general-entity reference "<code>&amp;rights;</code>" would be
6196 expanded should the reference "<code>&amp;book;</code>" appear in
6197 the document's content or an attribute value.
6198 </p>
6199 <p>
6200 These simple rules may have complex interactions; for a detailed
6201 discussion of a difficult example, see
6202 <a href="#sec-entexpand"
6203 ><b>C Expansion of Entity and Character References</b></a
6204 >.
6205 </p>
6206 </div>
6207 <div class="div2">
6208 <h3>
6209 <a name="sec-predefined-ent" id="sec-predefined-ent" />4.6
6210 Predefined Entities
6211 </h3>
6212 <p>
6213 [<a name="dt-escape" id="dt-escape" title="escape">Definition</a>:
6214 Entity and character references <span>may</span> both be used to
6215 <b>escape</b> the left angle bracket, ampersand, and other
6216 delimiters. A set of general entities (<code>amp</code>,
6217 <code>lt</code>, <code>gt</code>, <code>apos</code>,
6218 <code>quot</code>) is specified for this purpose. Numeric character
6219 references <span>may</span> also be used; they are expanded
6220 immediately when recognized and
6221 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
6222 treated as character data, so the numeric character references
6223 "<code>&amp;#60;</code>" and "<code>&amp;#38;</code>"
6224 <span>may</span> be used to escape <code>&lt;</code> and
6225 <code>&amp;</code> when they occur in character data.]
6226 </p>
6227 <p>
6228 All XML processors
6229 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6230 recognize these entities whether they are declared or not.
6231 <a title="For interoperability" href="#dt-interop"
6232 >For interoperability</a
6233 >, valid XML documents
6234 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
6235 declare these entities, like any others, before using them. If the
6236 entities <code>lt</code> or <code>amp</code> are declared, they
6237 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
6238 declared as internal entities whose replacement text is a character
6239 reference to the respective character (less-than sign or ampersand)
6240 being escaped; the double escaping is
6241 <em class="rfc2119" title="Keyword in RFC 2119 context"
6242 >REQUIRED</em
6243 >
6244 for these entities so that references to them produce a well-formed
6245 result. If the entities <code>gt</code>, <code>apos</code>, or
6246 <code>quot</code> are declared, they
6247 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
6248 declared as internal entities whose replacement text is the single
6249 character being escaped (or a character reference to that character;
6250 the double escaping here is
6251 <em class="rfc2119" title="Keyword in RFC 2119 context"
6252 >OPTIONAL</em
6253 >
6254 but harmless). For example:
6255 </p>
6256 <div class="exampleInner">
6257 <pre>
6258 &lt;!ENTITY lt "&amp;#38;#60;"&gt;
6259 &lt;!ENTITY gt "&amp;#62;"&gt;
6260 &lt;!ENTITY amp "&amp;#38;#38;"&gt;
6261 &lt;!ENTITY apos "&amp;#39;"&gt;
6262 &lt;!ENTITY quot "&amp;#34;"&gt;</pre
6263 >
6264 </div>
6265 </div>
6266 <div class="div2">
6267 <h3>
6268 <a name="Notations" id="Notations" />4.7 Notation Declarations
6269 </h3>
6270 <p>
6271 [<a name="dt-notation" id="dt-notation" title="Notation"
6272 >Definition</a
6273 >: <b>Notations</b> identify by name the format of
6274 <a title="Unparsed Entity" href="#dt-unparsed">unparsed entities</a
6275 >, the format of elements which bear a notation attribute, or the
6276 application to which a
6277 <a title="Processing instruction" href="#dt-pi"
6278 >processing instruction</a
6279 >
6280 is addressed.]
6281 </p>
6282 <p>
6283 [<a name="dt-notdecl" id="dt-notdecl" title="Notation Declaration"
6284 >Definition</a
6285 >:
6286 <b>Notation declarations</b>
6287 provide a name for the notation, for use in entity and
6288 attribute-list declarations and in attribute specifications, and an
6289 external identifier for the notation which may allow an XML
6290 processor or its client application to locate a helper application
6291 capable of processing data in the given notation.]
6292 </p>
6293 <h5><a name="IDANRMS" id="IDANRMS" />Notation Declarations</h5>
6294 <table class="scrap" summary="Scrap">
6295 <tbody>
6296 <tr valign="baseline">
6297 <td>
6298 <a
6299 name="NT-NotationDecl"
6300 id="NT-NotationDecl"
6301 />[82]&nbsp;&nbsp;&nbsp;
6302 </td>
6303 <td><code>NotationDecl</code></td>
6304 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
6305 <td>
6306 <code
6307 >'&lt;!NOTATION' <a href="#NT-S">S</a>
6308 <a href="#NT-Name">Name</a>
6309 <a href="#NT-S">S</a> (<a href="#NT-ExternalID"
6310 >ExternalID</a
6311 >
6312 | <a href="#NT-PublicID">PublicID</a>)
6313 <a href="#NT-S">S</a>? '&gt;'</code
6314 >
6315 </td>
6316 <td>
6317 <a href="#UniqueNotationName">[VC: Unique Notation Name]</a>
6318 </td>
6319 </tr>
6320 </tbody>
6321 <tbody>
6322 <tr valign="baseline">
6323 <td>
6324 <a
6325 name="NT-PublicID"
6326 id="NT-PublicID"
6327 />[83]&nbsp;&nbsp;&nbsp;
6328 </td>
6329 <td><code>PublicID</code></td>
6330 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
6331 <td>
6332 <code
6333 >'PUBLIC' <a href="#NT-S">S</a>
6334 <a href="#NT-PubidLiteral">PubidLiteral</a>
6335 </code>
6336 </td>
6337 </tr>
6338 </tbody>
6339 </table>
6340 <div class="constraint">
6341 <p class="prefix">
6342 <a name="UniqueNotationName" id="UniqueNotationName" /><b
6343 >Validity constraint: Unique Notation Name</b
6344 >
6345 </p>
6346 <p>
6347 A given <a href="#NT-Name">Name</a>
6348 <em class="rfc2119" title="Keyword in RFC 2119 context"
6349 >MUST NOT</em
6350 >
6351 be declared in more than one notation declaration.
6352 </p>
6353 </div>
6354 <p>
6355 XML processors
6356 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6357 provide applications with the name and external identifier(s) of any
6358 notation declared and referred to in an attribute value, attribute
6359 definition, or entity declaration. They
6360 <em class="rfc2119" title="Keyword in RFC 2119 context">MAY</em>
6361 additionally resolve the external identifier into the
6362 <a title="System Identifier" href="#dt-sysid">system identifier</a>,
6363 file name, or other information needed to allow the application to
6364 call a processor for data in the notation described. (It is not an
6365 error, however, for XML documents to declare and refer to notations
6366 for which notation-specific applications are not available on the
6367 system where the XML processor or application is running.)
6368 </p>
6369 </div>
6370 <div class="div2">
6371 <h3>
6372 <a name="sec-doc-entity" id="sec-doc-entity" />4.8 Document Entity
6373 </h3>
6374 <p>
6375 [<a name="dt-docent" id="dt-docent" title="Document Entity"
6376 >Definition</a
6377 >: The <b>document entity</b> serves as the root of the entity tree
6378 and a starting-point for an
6379 <a title="XML Processor" href="#dt-xml-proc">XML processor</a>.]
6380 This specification does not specify how the document entity is to be
6381 located by an XML processor; unlike other entities, the document
6382 entity has no name and might well appear on a processor input stream
6383 without any identification at all.
6384 </p>
6385 </div>
6386 </div>
6387 <div class="div1">
6388 <h2><a name="sec-conformance" id="sec-conformance" />5 Conformance</h2>
6389 <div class="div2">
6390 <h3>
6391 <a name="proc-types" id="proc-types" />5.1 Validating and
6392 Non-Validating Processors
6393 </h3>
6394 <p>
6395 Conforming
6396 <a title="XML Processor" href="#dt-xml-proc">XML processors</a> fall
6397 into two classes: validating and non-validating.
6398 </p>
6399 <p>
6400 Validating and non-validating processors alike
6401 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6402 report violations of this specification's well-formedness
6403 constraints in the content of the
6404 <a title="Document Entity" href="#dt-docent">document entity</a> and
6405 any other
6406 <a title="Text Entity" href="#dt-parsedent">parsed entities</a> that
6407 they read.
6408 </p>
6409 <p>
6410 [<a
6411 name="dt-validating"
6412 id="dt-validating"
6413 title="Validating Processor"
6414 >Definition</a
6415 >:
6416 <b>Validating processors</b>
6417 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>,
6418 at user option, report violations of the constraints expressed by
6419 the declarations in the
6420 <a title="Document Type Declaration" href="#dt-doctype">DTD</a>, and
6421 failures to fulfill the validity constraints given in this
6422 specification.] To accomplish this, validating XML processors
6423 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6424 read and process the entire DTD and all external parsed entities
6425 referenced in the document.
6426 </p>
6427 <p>
6428 Non-validating processors are
6429 <em class="rfc2119" title="Keyword in RFC 2119 context"
6430 >REQUIRED</em
6431 >
6432 to check only the
6433 <a title="Document Entity" href="#dt-docent">document entity</a>,
6434 including the entire internal DTD subset, for well-formedness. [<a
6435 name="dt-use-mdecl"
6436 id="dt-use-mdecl"
6437 title="Process Declarations"
6438 >Definition</a
6439 >: While they are not required to check the document for validity,
6440 they are
6441 <em class="rfc2119" title="Keyword in RFC 2119 context"
6442 >REQUIRED</em
6443 >
6444 to <b>process</b> all the declarations they read in the internal DTD
6445 subset and in any parameter entity that they read, up to the first
6446 reference to a parameter entity that they do <em>not</em> read; that
6447 is to say, they
6448 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6449 use the information in those declarations to
6450 <a href="#AVNormalize"><cite>normalize</cite></a> attribute values,
6451 <a href="#included"><cite>include</cite></a> the replacement text of
6452 internal entities, and supply
6453 <a href="#sec-attr-defaults"
6454 ><cite>default attribute values</cite></a
6455 >.] Except when <code>standalone="yes"</code>, they
6456 <em class="rfc2119" title="Keyword in RFC 2119 context"
6457 >MUST NOT</em
6458 >
6459 <a title="Process Declarations" href="#dt-use-mdecl">process</a>
6460 <a title="entity declaration" href="#dt-entdecl"
6461 >entity declarations</a
6462 >
6463 or
6464 <a title="Attribute-List Declaration" href="#dt-attdecl"
6465 >attribute-list declarations</a
6466 >
6467 encountered after a reference to a parameter entity that is not
6468 read, since the entity may have contained overriding declarations;
6469 when <code>standalone="yes"</code>, processors
6470 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em>
6471 process these declarations.
6472 </p>
6473 <p>
6474 Note that when processing invalid documents with a non-validating
6475 processor the application may not be presented with consistent
6476 information. For example, several requirements for uniqueness within
6477 the document may not be met, including more than one element with
6478 the same id, duplicate declarations of elements or notations with
6479 the same name, etc. In these cases the behavior of the parser with
6480 respect to reporting such information to the application is
6481 undefined.
6482 </p>
6483 <p>
6484 XML 1.1 processors
6485 <em class="rfc2119" title="Keyword in RFC 2119 context">MUST</em> be
6486 able to process both XML 1.0 and XML 1.1 documents. Programs which
6487 generate XML
6488 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
6489 generate XML 1.0, unless one of the specific features of XML 1.1 is
6490 required.
6491 </p>
6492 </div>
6493 <div class="div2">
6494 <h3>
6495 <a name="safe-behavior" id="safe-behavior" />5.2 Using XML
6496 Processors
6497 </h3>
6498 <p>
6499 The behavior of a validating XML processor is highly predictable; it
6500 must read every piece of a document and report all well-formedness
6501 and validity violations. Less is required of a non-validating
6502 processor; it need not read any part of the document other than the
6503 document entity. This has two effects that may be important to users
6504 of XML processors:
6505 </p>
6506 <ul>
6507 <li>
6508 <p>
6509 Certain well-formedness errors, specifically those that require
6510 reading external entities, may fail to be detected by a
6511 non-validating processor. Examples include the constraints
6512 entitled
6513 <a href="#wf-entdeclared"><cite>Entity Declared</cite></a
6514 >, <a href="#textent"><cite>Parsed Entity</cite></a
6515 >, and <a href="#norecursion"><cite>No Recursion</cite></a
6516 >, as well as some of the cases described as
6517 <a href="#forbidden"><cite>forbidden</cite></a> in
6518 <a href="#entproc"
6519 ><b
6520 >4.4 XML Processor Treatment of Entities and References</b
6521 ></a
6522 >.
6523 </p>
6524 </li>
6525 <li>
6526 <p>
6527 The information passed from the processor to the application may
6528 vary, depending on whether the processor reads parameter and
6529 external entities. For example, a non-validating processor may
6530 fail to
6531 <a href="#AVNormalize"><cite>normalize</cite></a> attribute
6532 values, <a href="#included"><cite>include</cite></a> the
6533 replacement text of internal entities, or supply
6534 <a href="#sec-attr-defaults"
6535 ><cite>default attribute values</cite></a
6536 >, where doing so depends on having read declarations in
6537 external or parameter entities.
6538 </p>
6539 </li>
6540 </ul>
6541 <p>
6542 For maximum reliability in interoperating between different XML
6543 processors, applications which use non-validating processors
6544 <em class="rfc2119" title="Keyword in RFC 2119 context"
6545 >SHOULD NOT</em
6546 >
6547 rely on any behaviors not required of such processors. Applications
6548 which require DTD facilities not related to validation (such as the
6549 declaration of default attributes and internal entities that are or
6550 may be specified in external entities<span> )</span>
6551 <em class="rfc2119" title="Keyword in RFC 2119 context">SHOULD</em>
6552 use validating XML processors.
6553 </p>
6554 </div>
6555 </div>
6556 <div class="div1">
6557 <h2><a name="sec-notation" id="sec-notation" />6 Notation</h2>
6558 <p>
6559 The formal grammar of XML is given in this specification using a
6560 simple Extended Backus-Naur Form (EBNF) notation. Each rule in the
6561 grammar defines one symbol, in the form
6562 </p>
6563 <div class="exampleInner"><pre>symbol ::= expression</pre></div>
6564 <p>
6565 Symbols are written with an initial capital letter if they are the
6566 start symbol of a regular language, otherwise with an initial
6567 lowercase letter. Literal strings are quoted.
6568 </p>
6569 <p>
6570 Within the expression on the right-hand side of a rule, the following
6571 expressions are used to match strings of one or more characters:
6572 </p>
6573 <dl>
6574 <dt class="label">
6575 <code>#xN</code>
6576 </dt>
6577 <dd>
6578 <p>
6579 where <code>N</code> is a hexadecimal integer, the expression
6580 matches the character whose number (code point) in ISO/IEC 10646
6581 is <code>N</code>. The number of leading zeros in the
6582 <code>#xN</code> form is insignificant.
6583 </p>
6584 </dd>
6585 <dt class="label"><code>[a-zA-Z]</code>, <code>[#xN-#xN]</code></dt>
6586 <dd>
6587 <p>
6588 matches any <a href="#NT-Char">Char</a> with a value in the
6589 range(s) indicated (inclusive).
6590 </p>
6591 </dd>
6592 <dt class="label"><code>[abc]</code>, <code>[#xN#xN#xN]</code></dt>
6593 <dd>
6594 <p>
6595 matches any <a href="#NT-Char">Char</a> with a value among the
6596 characters enumerated. Enumerations and ranges can be mixed in one
6597 set of brackets.
6598 </p>
6599 </dd>
6600 <dt class="label"><code>[^a-z]</code>, <code>[^#xN-#xN]</code></dt>
6601 <dd>
6602 <p>
6603 matches any <a href="#NT-Char">Char</a> with a value
6604 <em>outside</em> the range indicated.
6605 </p>
6606 </dd>
6607 <dt class="label"><code>[^abc]</code>, <code>[^#xN#xN#xN]</code></dt>
6608 <dd>
6609 <p>
6610 matches any <a href="#NT-Char">Char</a> with a value not among the
6611 characters given. Enumerations and ranges of forbidden values can
6612 be mixed in one set of brackets.
6613 </p>
6614 </dd>
6615 <dt class="label">
6616 <code>"string"</code>
6617 </dt>
6618 <dd>
6619 <p>
6620 matches a literal string
6621 <a title="match" href="#dt-match">matching</a> that given inside
6622 the double quotes.
6623 </p>
6624 </dd>
6625 <dt class="label">
6626 <code>'string'</code>
6627 </dt>
6628 <dd>
6629 <p>
6630 matches a literal string
6631 <a title="match" href="#dt-match">matching</a> that given inside
6632 the single quotes.
6633 </p>
6634 </dd>
6635 </dl>
6636 <p>
6637 These symbols may be combined to match more complex patterns as
6638 follows, where <code>A</code> and <code>B</code> represent simple
6639 expressions:
6640 </p>
6641 <dl>
6642 <dt class="label">(<code>expression</code>)</dt>
6643 <dd>
6644 <p>
6645 <code>expression</code> is treated as a unit and may be combined
6646 as described in this list.
6647 </p>
6648 </dd>
6649 <dt class="label">
6650 <code>A?</code>
6651 </dt>
6652 <dd>
6653 <p>matches <code>A</code> or nothing; optional <code>A</code>.</p>
6654 </dd>
6655 <dt class="label">
6656 <code>A B</code>
6657 </dt>
6658 <dd>
6659 <p>
6660 matches <code>A</code> followed by <code>B</code>. This operator
6661 has higher precedence than alternation; thus
6662 <code>A B | C D</code> is identical to <code>(A B) | (C D)</code>.
6663 </p>
6664 </dd>
6665 <dt class="label">
6666 <code>A | B</code>
6667 </dt>
6668 <dd>
6669 <p>matches <code>A</code> or <code>B</code>.</p>
6670 </dd>
6671 <dt class="label">
6672 <code>A - B</code>
6673 </dt>
6674 <dd>
6675 <p>
6676 matches any string that matches <code>A</code> but does not match
6677 <code>B</code>.
6678 </p>
6679 </dd>
6680 <dt class="label">
6681 <code>A+</code>
6682 </dt>
6683 <dd>
6684 <p>
6685 matches one or more occurrences of <code>A</code>. Concatenation
6686 has higher precedence than alternation; thus
6687 <code>A+ | B+</code> is identical to <code>(A+) | (B+)</code>.
6688 </p>
6689 </dd>
6690 <dt class="label">
6691 <code>A*</code>
6692 </dt>
6693 <dd>
6694 <p>
6695 matches zero or more occurrences of <code>A</code>. Concatenation
6696 has higher precedence than alternation; thus
6697 <code>A* | B*</code> is identical to <code>(A*) | (B*)</code>.
6698 </p>
6699 </dd>
6700 </dl>
6701 <p>Other notations used in the productions are:</p>
6702 <dl>
6703 <dt class="label">
6704 <code>/* ... */</code>
6705 </dt>
6706 <dd><p>comment.</p></dd>
6707 <dt class="label">
6708 <code>[ wfc: ... ]</code>
6709 </dt>
6710 <dd>
6711 <p>
6712 well-formedness constraint; this identifies by name a constraint
6713 on
6714 <a title="Well-Formed" href="#dt-wellformed">well-formed</a>
6715 documents associated with a production.
6716 </p>
6717 </dd>
6718 <dt class="label">
6719 <code>[ vc: ... ]</code>
6720 </dt>
6721 <dd>
6722 <p>
6723 validity constraint; this identifies by name a constraint on
6724 <a title="Validity" href="#dt-valid">valid</a> documents
6725 associated with a production.
6726 </p>
6727 </dd>
6728 </dl>
6729 <p></p>
6730 </div>
6731 </div>
6732 <div class="back">
6733 <div class="div1">
6734 <h2><a name="sec-bibliography" id="sec-bibliography" />A References</h2>
6735 <div class="div2">
6736 <h3>
6737 <a name="sec-existing-stds" id="sec-existing-stds" />A.1 Normative
6738 References
6739 </h3>
6740 <dl>
6741 <dt class="label"><a name="IANA" id="IANA" />IANA-CHARSETS</dt>
6742 <dd>
6743 (Internet Assigned Numbers Authority)
6744 <a href="http://www.iana.org/assignments/character-sets"
6745 ><cite>Official Names for Character Sets</cite></a
6746 >, ed. Keld Simonsen et al. (See
6747 http://www.iana.org/assignments/character-sets.)
6748 </dd>
6749 <dt class="label">
6750 <a name="rfc2119" id="rfc2119" />IETF RFC 2119
6751 </dt>
6752 <dd>
6753 IETF (Internet Engineering Task Force).
6754 <a href="http://www.ietf.org/rfc/rfc2119.txt"
6755 ><cite
6756 >RFC 2119: Key words for use in RFCs to Indicate Requirement
6757 Levels</cite
6758 ></a
6759 >. Scott Bradner, 1997. (See http://www.ietf.org/rfc/rfc2119.txt.)
6760 </dd>
6761 <dt class="label">
6762 <a name="RFC1766" id="RFC1766" />IETF RFC 3066
6763 </dt>
6764 <dd>
6765 IETF (Internet Engineering Task Force).
6766 <a href="http://www.ietf.org/rfc/rfc3066.txt"
6767 ><cite
6768 >RFC 3066: Tags for the Identification of Languages</cite
6769 ></a
6770 >, ed. H. Alvestrand. 2001. (See
6771 http://www.ietf.org/rfc/rfc3066.txt.)
6772 </dd>
6773 <dt class="label"><a name="rfc3986" />IETF RFC 3986</dt>
6774 <dd>
6775 IETF (Internet Engineering Task Force).
6776 <a href="http://www.ietf.org/rfc/rfc3986.txt"
6777 ><cite
6778 >RFC 3986: Uniform Resource Identifier (URI): Generic
6779 Syntax</cite
6780 ></a
6781 >. T. Berners-Lee, R. Fielding, L. Masinter. 2005. (See
6782 http://www.ietf.org/rfc/rfc3986.txt.)
6783 </dd>
6784 <dt class="label">
6785 <a name="ISO10646" id="ISO10646" />ISO/IEC 10646
6786 </dt>
6787 <dd>
6788 ISO (International Organization for Standardization).
6789 <cite
6790 >ISO/IEC 10646-1:2000. Information technology — Universal
6791 Multiple-Octet Coded Character Set (UCS) — Part 1: Architecture
6792 and Basic Multilingual Plane</cite
6793 >
6794 and
6795 <cite
6796 >ISO/IEC 10646-2:2001. Information technology — Universal
6797 Multiple-Octet Coded Character Set (UCS) — Part 2: Supplementary
6798 Planes</cite
6799 >, as, from time to time, amended, replaced by a new edition or
6800 expanded by the addition of new parts. [Geneva]: International
6801 Organization for Standardization. (See
6802 <a href="http://www.iso.ch">http://www.iso.ch</a> for the latest
6803 version.)
6804 </dd>
6805 <dt class="label"><a name="Unicode" id="Unicode" />Unicode</dt>
6806 <dd>
6807 The Unicode Consortium.
6808 <em>The Unicode Standard, Version 4.0.</em> Reading, Mass.:
6809 Addison-Wesley, 2003, as updated from time to time by the
6810 publication of new versions. (See
6811 <a href="http://www.unicode.org/unicode/standard/versions">
6812 http://www.unicode.org/unicode/standard/versions</a
6813 >
6814 for the latest version and additional information on versions of
6815 the standard and of the Unicode Character Database).
6816 </dd>
6817 <dt class="label"><a name="XML1.0" id="XML1.0" />XML-1.0</dt>
6818 <dd>
6819 W3C.
6820 <a href="http://www.w3.org/TR/xml"
6821 ><cite
6822 >Extensible Markup Language (XML) 1.0 (Fourth Edition)</cite
6823 ></a
6824 >. Tim Bray, Jean Paoli, C.M. Sperberg-McQueen, Eve Maler,
6825 François Yergeau (editors) (See http://www.w3.org/TR/xml.)
6826 </dd>
6827 </dl>
6828 </div>
6829 <div class="div2">
6830 <h3><a name="null" id="null" />A.2 Other References</h3>
6831 <dl>
6832 <dt class="label"><a name="Aho" id="Aho" />Aho/Ullman</dt>
6833 <dd>
6834 Aho, Alfred V., Ravi Sethi, and Jeffrey D. Ullman.
6835 <cite>Compilers: Principles, Techniques, and Tools</cite>.
6836 Reading: Addison-Wesley, 1986, rpt. corr. 1988.
6837 </dd>
6838 <dt class="label"><a name="ABK" id="ABK" />Brüggemann-Klein</dt>
6839 <dd>
6840 Brüggemann-Klein, Anne.
6841 <a
6842 href="ftp://ftp.informatik.uni-freiburg.de/documents/papers/brueggem/habil.ps"
6843 ><cite>Formal Models in Document Processing</cite></a
6844 >. Habilitationsschrift. Faculty of Mathematics at the University
6845 of Freiburg, 1993. (See
6846 ftp://ftp.informatik.uni-freiburg.de/documents/papers/brueggem/habil.ps.)
6847 </dd>
6848 <dt class="label">
6849 <a name="ABKDW" id="ABKDW" />Brüggemann-Klein and Wood
6850 </dt>
6851 <dd>
6852 Brüggemann-Klein, Anne, and Derick Wood.
6853 <cite>Deterministic Regular Languages</cite>. Universität
6854 Freiburg, Institut für Informatik, Bericht 38, Oktober 1991.
6855 Extended abstract in A. Finkel, M. Jantzen, Hrsg., STACS 1992, S.
6856 173-184. Springer-Verlag, Berlin 1992. Lecture Notes in Computer
6857 Science 577. Full version titled
6858 <cite>One-Unambiguous Regular Languages</cite> in Information and
6859 Computation 140 (2): 229-253, February 1998.
6860 </dd>
6861 <dt class="label"><a name="Charmod" id="Charmod" />Charmod</dt>
6862 <dd>
6863 W3C Working Draft.
6864 <a href="http://www.w3.org/TR/2003/WD-charmod-20030822/"
6865 ><cite>Character Model for the World Wide Web 1.0</cite></a
6866 >. Martin J. Dürst, François Yergeau, Richard Ishida, Misha Wolf,
6867 Tex Texin. (See http://www.w3.org/TR/2003/WD-charmod-20030822/.)
6868 </dd>
6869 <dt class="label"><a name="Clark" id="Clark" />Clark</dt>
6870 <dd>
6871 James Clark.
6872 <a href="http://www.w3.org/TR/NOTE-sgml-xml-971215"
6873 ><cite>Comparison of SGML and XML</cite></a
6874 >. (See http://www.w3.org/TR/NOTE-sgml-xml-971215.)
6875 </dd>
6876 <dt class="label">
6877 <a name="IANA-LANGCODES" id="IANA-LANGCODES" />IANA-LANGCODES
6878 </dt>
6879 <dd>
6880 (Internet Assigned Numbers Authority)
6881 <a href="http://www.iana.org/assignments/language-tags"
6882 ><cite>Registry of Language Tags</cite></a
6883 >, ed. Keld Simonsen et al. (See
6884 http://www.iana.org/assignments/language-tags.)
6885 </dd>
6886 <dt class="label">
6887 <a name="RFC2141" id="RFC2141" />IETF RFC 2141
6888 </dt>
6889 <dd>
6890 IETF (Internet Engineering Task Force).
6891 <a href="http://www.ietf.org/rfc/rfc2141.txt"
6892 ><cite>RFC 2141: URN Syntax</cite></a
6893 >, ed. R. Moats. 1997. (See http://www.ietf.org/rfc/rfc2141.txt.)
6894 </dd>
6895 <dt class="label">
6896 <a name="rfc2376" id="rfc2376" />IETF RFC 3023
6897 </dt>
6898 <dd>
6899 IETF (Internet Engineering Task Force).
6900 <a href="http://www.ietf.org/rfc/rfc3023.txt"
6901 ><cite>RFC 3023: XML Media Types</cite></a
6902 >. eds. M. Murata, S. St.Laurent, D. Kohn. 2001. (See
6903 http://www.ietf.org/rfc/rfc3023.txt.)
6904 </dd>
6905 <dt class="label">
6906 <a name="rfc2781" id="rfc2781" />IETF RFC 2781
6907 </dt>
6908 <dd>
6909 IETF (Internet Engineering Task Force).
6910 <a href="http://www.ietf.org/rfc/rfc2781.txt"
6911 ><cite>RFC 2781: UTF-16, an encoding of ISO 10646</cite></a
6912 >, ed. P. Hoffman, F. Yergeau. 2000. (See
6913 http://www.ietf.org/rfc/rfc2781.txt.)
6914 </dd>
6915 <dt class="label"><a name="ISO639" id="ISO639" />ISO 639</dt>
6916 <dd>
6917 (International Organization for Standardization).
6918 <cite
6919 >ISO 639:1988 (E). Code for the representation of names of
6920 languages.</cite
6921 >
6922 [Geneva]: International Organization for Standardization, 1988.
6923 </dd>
6924 <dt class="label"><a name="ISO3166" id="ISO3166" />ISO 3166</dt>
6925 <dd>
6926 (International Organization for Standardization).
6927 <cite
6928 >ISO 3166-1:1997 (E). Codes for the representation of names of
6929 countries and their subdivisions — Part 1: Country codes</cite
6930 >
6931 [Geneva]: International Organization for Standardization, 1997.
6932 </dd>
6933 <dt class="label"><a name="ISO8879" id="ISO8879" />ISO 8879</dt>
6934 <dd>
6935 ISO (International Organization for Standardization).
6936 <cite
6937 >ISO 8879:1986(E). Information processing — Text and Office
6938 Systems — Standard Generalized Markup Language (SGML).</cite
6939 >
6940 First edition — 1986-10-15. [Geneva]: International Organization
6941 for Standardization, 1986.
6942 </dd>
6943 <dt class="label">
6944 <a name="ISO10744" id="ISO10744" />ISO/IEC 10744
6945 </dt>
6946 <dd>
6947 ISO (International Organization for Standardization).
6948 <cite
6949 >ISO/IEC 10744-1992 (E). Information technology —
6950 Hypermedia/Time-based Structuring Language (HyTime).
6951 </cite>
6952 [Geneva]: International Organization for Standardization, 1992.
6953 <em>Extended Facilities Annexe.</em> [Geneva]: International
6954 Organization for Standardization, 1996.
6955 </dd>
6956 <dt class="label"><a name="websgml" id="websgml" />WEBSGML</dt>
6957 <dd>
6958 ISO (International Organization for Standardization).
6959 <a href="http://www.sgmlsource.com/8879/n0029.htm"
6960 ><cite
6961 >ISO 8879:1986 TC2. Information technology — Document
6962 Description and Processing Languages</cite
6963 ></a
6964 >. [Geneva]: International Organization for Standardization, 1998.
6965 (See http://www.sgmlsource.com/8879/n0029.htm.)
6966 </dd>
6967 <dt class="label">
6968 <a name="xml-names" id="xml-names" />XML Names
6969 </dt>
6970 <dd>
6971 Tim Bray, Dave Hollander, and Andrew Layman, editors.
6972 <a href="http://www.w3.org/TR/REC-xml-names/"
6973 ><cite>Namespaces in XML</cite></a
6974 >. Textuality, Hewlett-Packard, and Microsoft. World Wide Web
6975 Consortium, 1999. (See http://www.w3.org/TR/REC-xml-names/.)
6976 </dd>
6977 </dl>
6978 </div>
6979 </div>
6980 <div class="div1">
6981 <h2>
6982 <a name="sec-CharNorm" id="sec-CharNorm" />B Definitions for Character
6983 Normalization
6984 </h2>
6985 <p>
6986 This appendix contains the necessary definitions for character
6987 normalization. For additional background information and examples, see
6988 <a href="#Charmod">[Charmod]</a>.
6989 </p>
6990 <p>
6991 [<a
6992 name="dt-Uni-encform"
6993 id="dt-Uni-encform"
6994 title="Unicode encoding form"
6995 >Definition</a
6996 >: Text is said to be in a <b>Unicode encoding form</b> if it is
6997 encoded in UTF-8, UTF-16 or UTF-32.]
6998 </p>
6999 <p>
7000 [<a name="dt-legacyenc" id="dt-legacyenc" title="legacy encoding"
7001 >Definition</a
7002 >:
7003 <b>Legacy encoding</b>
7004 is taken to mean any character encoding not based on Unicode.]
7005 </p>
7006 <p>
7007 [<a
7008 name="dt-normtransc"
7009 id="dt-normtransc"
7010 title="normalizing transcoder"
7011 >Definition</a
7012 >: A <b>normalizing transcoder</b> is a transcoder that converts from
7013 a
7014 <a title="legacy encoding" href="#dt-legacyenc">legacy encoding</a> to
7015 a
7016 <a title="Unicode encoding form" href="#dt-Uni-encform"
7017 >Unicode encoding form</a
7018 >
7019 and ensures that the result is in Unicode Normalization Form C (see
7020 UAX #15 <a href="#Unicode">[Unicode]</a>).]
7021 </p>
7022 <p>
7023 [<a name="dt-charesc" id="dt-charesc" title="character escape"
7024 >Definition</a
7025 >: A <b>character escape</b>
7026 is a syntactic device defined in a markup or programming language that
7027 allows one or more of:]
7028 </p>
7029 <ol class="enumar">
7030 <li>
7031 <p>
7032 expressing syntax-significant characters while disregarding their
7033 significance in the syntax of the language, or
7034 </p>
7035 </li>
7036 <li>
7037 <p>
7038 expressing characters not representable in the character encoding
7039 chosen for an instance of the language, or
7040 </p>
7041 </li>
7042 <li>
7043 <p>
7044 expressing characters in general, without use of the corresponding
7045 character codes.
7046 </p>
7047 </li>
7048 </ol>
7049 <p>
7050 [<a name="dt-certified" id="dt-certified" title="certified"
7051 >Definition</a
7052 >: <b>Certified</b> text is text which satisfies at least one of the
7053 following conditions:]
7054 </p>
7055 <ol class="enumar">
7056 <li>
7057 <p>
7058 it has been confirmed through inspection that the text is in
7059 normalized form
7060 </p>
7061 </li>
7062 <li>
7063 <p>
7064 the source text-processing component is identified and is known to
7065 produce only normalized text.
7066 </p>
7067 </li>
7068 </ol>
7069 <p>
7070 [<a name="dt-uninorm" id="dt-uninorm" title="Unicode-normalized"
7071 >Definition</a
7072 >: Text is, for the purposes of this specification,
7073 <b>Unicode-normalized</b> if it is in a
7074 <a title="Unicode encoding form" href="#dt-Uni-encform"
7075 >Unicode encoding form</a
7076 >
7077 and is in Unicode Normalization Form C, according to a version of
7078 Unicode Standard Annex #15: Unicode Normalization Forms
7079 <a href="#Unicode">[Unicode]</a> at least as recent as the oldest
7080 version of the Unicode Standard that contains all the characters
7081 actually present in the text, but no earlier than version 3.2.]
7082 </p>
7083 <p>
7084 [<a name="dt-inclnorm" id="dt-inclnorm" title="include-normalized"
7085 >Definition</a
7086 >: Text is <b>include-normalized</b> if:]
7087 </p>
7088 <ol class="enumar">
7089 <li>
7090 <p>
7091 the text is
7092 <a title="Unicode-normalized" href="#dt-uninorm"
7093 >Unicode-normalized</a
7094 >
7095 and does not contain any
7096 <a title="character escape" href="#dt-charesc"
7097 >character escapes</a
7098 >
7099 or <a title="Include" href="#dt-include">includes</a> whose
7100 expansion would cause the text to become no longer
7101 <a title="Unicode-normalized" href="#dt-uninorm"
7102 >Unicode-normalized</a
7103 >; or
7104 </p>
7105 </li>
7106 <li>
7107 <p>
7108 the text is in a
7109 <a title="legacy encoding" href="#dt-legacyenc"
7110 >legacy encoding</a
7111 >
7112 and, if it were transcoded to a
7113 <a title="Unicode encoding form" href="#dt-Uni-encform"
7114 >Unicode encoding form</a
7115 >
7116 by a
7117 <a title="normalizing transcoder" href="#dt-normtransc"
7118 >normalizing transcoder</a
7119 >, the resulting text would satisfy clause 1 above.
7120 </p>
7121 </li>
7122 </ol>
7123 <p>
7124 [<a name="dt-compchar" id="dt-compchar" title="composing character"
7125 >Definition</a
7126 >: A <b>composing character</b>
7127 is a character that is one or both of the following:]
7128 </p>
7129 <ol class="enumar">
7130 <li>
7131 <p>
7132 the second character in the canonical decomposition mapping of
7133 some primary composite (as defined in D3 of UAX #15
7134 <a href="#Unicode">[Unicode]</a>), or
7135 </p>
7136 </li>
7137 <li>
7138 <p>
7139 of non-zero canonical combining class (as defined in Unicode
7140 <a href="#Unicode">[Unicode]</a>).
7141 </p>
7142 </li>
7143 </ol>
7144 <p>
7145 [<a name="dt-fullnorm" id="dt-fullnorm" title="fully normalized"
7146 >Definition</a
7147 >: Text is <b>fully-normalized</b> if:]
7148 </p>
7149 <ol class="enumar">
7150 <li>
7151 <p>
7152 the text is in a
7153 <a title="Unicode encoding form" href="#dt-Uni-encform"
7154 >Unicode encoding form</a
7155 >, is
7156 <a title="include-normalized" href="#dt-inclnorm"
7157 >include-normalized</a
7158 >
7159 and none of the
7160 <a title="" href="#dt-relconst">relevant constructs</a> comprising
7161 the text begin with a
7162 <a title="composing character" href="#dt-compchar"
7163 >composing character</a
7164 >
7165 or a character escape representing a
7166 <a title="composing character" href="#dt-compchar"
7167 >composing character</a
7168 >; or
7169 </p>
7170 </li>
7171 <li>
7172 <p>
7173 the text is in a
7174 <a title="legacy encoding" href="#dt-legacyenc"
7175 >legacy encoding</a
7176 >
7177 and, if it were transcoded to a
7178 <a title="Unicode encoding form" href="#dt-Uni-encform"
7179 >Unicode encoding form</a
7180 >
7181 by a
7182 <a title="normalizing transcoder" href="#dt-normtransc"
7183 >normalizing transcoder</a
7184 >, the resulting text would satisfy clause 1 above.
7185 </p>
7186 </li>
7187 </ol>
7188 </div>
7189 <div class="div1">
7190 <h2>
7191 <a name="sec-entexpand" id="sec-entexpand" />C Expansion of Entity and
7192 Character References (Non-Normative)
7193 </h2>
7194 <p>
7195 This appendix contains some examples illustrating the sequence of
7196 entity- and character-reference recognition and expansion, as
7197 specified in
7198 <a href="#entproc"
7199 ><b>4.4 XML Processor Treatment of Entities and References</b></a
7200 >.
7201 </p>
7202 <p>If the DTD contains the declaration</p>
7203 <div class="exampleInner">
7204 <pre>
7205 &lt;!ENTITY example "&lt;p&gt;An ampersand (&amp;#38;#38;) may be escaped
7206 numerically (&amp;#38;#38;#38;) or with a general entity
7207 (&amp;amp;amp;).&lt;/p&gt;" &gt;</pre
7208 >
7209 </div>
7210 <p>
7211 then the XML processor will recognize the character references when it
7212 parses the entity declaration, and resolve them before storing the
7213 following string as the value of the entity "<code>example</code>":
7214 </p>
7215 <div class="exampleInner">
7216 <pre>
7217 &lt;p&gt;An ampersand (&amp;#38;) may be escaped
7218 numerically (&amp;#38;#38;) or with a general entity
7219 (&amp;amp;amp;).&lt;/p&gt;</pre
7220 >
7221 </div>
7222 <p>
7223 A reference in the document to "<code>&amp;example;</code>" will cause
7224 the text to be reparsed, at which time the start- and end-tags of the
7225 <code>p</code> element will be recognized and the three references
7226 will be recognized and expanded, resulting in a <code>p</code> element
7227 with the following content (all data, no delimiters or markup):
7228 </p>
7229 <div class="exampleInner">
7230 <pre>
7231 An ampersand (&amp;) may be escaped
7232 numerically (&amp;#38;) or with a general entity
7233 (&amp;amp;).</pre
7234 >
7235 </div>
7236 <p>
7237 A more complex example will illustrate the rules and their effects
7238 fully. In the following example, the line numbers are solely for
7239 reference.
7240 </p>
7241 <div class="exampleInner">
7242 <pre>
7243 1 &lt;?xml version='1.<span>1</span>'?&gt;
7244 2 &lt;!DOCTYPE test [
7245 3 &lt;!ELEMENT test (#PCDATA) &gt;
7246 4 &lt;!ENTITY % xx '&amp;#37;zz;'&gt;
7247 5 &lt;!ENTITY % zz '&amp;#60;!ENTITY tricky "error-prone" &gt;' &gt;
7248 6 %xx;
7249 7 ]&gt;
7250 8 &lt;test&gt;This sample shows a &amp;tricky; method.&lt;/test&gt;</pre
7251 >
7252 </div>
7253 <p>This produces the following:</p>
7254 <ul>
7255 <li>
7256 <p>
7257 in line 4, the reference to character 37 is expanded immediately,
7258 and the parameter entity "<code>xx</code>" is stored in the symbol
7259 table with the value "<code>%zz;</code>". Since the replacement
7260 text is not rescanned, the reference to parameter entity
7261 "<code>zz</code>" is not recognized. (And it would be an error if
7262 it were, since "<code>zz</code>" is not yet declared.)
7263 </p>
7264 </li>
7265 <li>
7266 <p>
7267 in line 5, the character reference "<code>&amp;#60;</code>" is
7268 expanded immediately and the parameter entity "<code>zz</code>" is
7269 stored with the replacement text "<code
7270 >&lt;!ENTITY tricky "error-prone"&gt;</code
7271 >", which is a well-formed entity declaration.
7272 </p>
7273 </li>
7274 <li>
7275 <p>
7276 in line 6, the reference to "<code>xx</code>" is recognized, and
7277 the replacement text of "<code>xx</code>" (namely
7278 "<code>%zz;</code>") is parsed. The reference to "<code>zz</code>"
7279 is recognized in its turn, and its replacement text ("<code
7280 >&lt;!ENTITY tricky "error-prone"&gt;</code
7281 >") is parsed. The general entity "<code>tricky</code>" has now
7282 been declared, with the replacement text
7283 "<code>error-prone</code>".
7284 </p>
7285 </li>
7286 <li>
7287 <p>
7288 in line 8, the reference to the general entity
7289 "<code>tricky</code>" is recognized, and it is expanded, so the
7290 full content of the <code>test</code> element is the
7291 self-describing (and ungrammatical) string
7292 <em>This sample shows a error-prone method.</em>
7293 </p>
7294 </li>
7295 </ul>
7296 </div>
7297 <div class="div1">
7298 <h2>
7299 <a name="determinism" id="determinism" />D Deterministic Content
7300 Models (Non-Normative)
7301 </h2>
7302 <p>
7303 As noted in
7304 <a href="#sec-element-content"><b>3.2.1 Element Content</b></a
7305 >, it is required that content models in element type declarations be
7306 deterministic. This requirement is
7307 <a title="For Compatibility" href="#dt-compat">for compatibility</a>
7308 with SGML (which calls deterministic content models "unambiguous");
7309 XML processors built using SGML systems may flag non-deterministic
7310 content models as errors.
7311 </p>
7312 <p>
7313 For example, the content model <code>((b, c) | (b, d))</code> is
7314 non-deterministic, because given an initial <code>b</code> the XML
7315 processor cannot know which <code>b</code> in the model is being
7316 matched without looking ahead to see which element follows the
7317 <code>b</code>. In this case, the two references to <code>b</code> can
7318 be collapsed into a single reference, making the model read
7319 <code>(b, (c | d))</code>. An initial <code>b</code> now clearly
7320 matches only a single name in the content model. The processor doesn't
7321 need to look ahead to see what follows; either <code>c</code> or
7322 <code>d</code> would be accepted.
7323 </p>
7324 <p>
7325 More formally: a finite state automaton may be constructed from the
7326 content model using the standard algorithms, e.g. algorithm 3.5 in
7327 section 3.9 of Aho, Sethi, and Ullman <a href="#Aho">[Aho/Ullman]</a>.
7328 In many such algorithms, a follow set is constructed for each position
7329 in the regular expression (i.e., each leaf node in the syntax tree for
7330 the regular expression); if any position has a follow set in which
7331 more than one following position is labeled with the same element type
7332 name, then the content model is in error and may be reported as an
7333 error.
7334 </p>
7335 <p>
7336 Algorithms exist which allow many but not all non-deterministic
7337 content models to be reduced automatically to equivalent deterministic
7338 models; see Brüggemann-Klein 1991
7339 <a href="#ABK">[Brüggemann-Klein]</a>.
7340 </p>
7341 </div>
7342 <div class="div1">
7343 <h2>
7344 <a name="sec-guessing" id="sec-guessing" />E Autodetection of
7345 Character Encodings (Non-Normative)
7346 </h2>
7347 <p>
7348 The XML encoding declaration functions as an internal label on each
7349 entity, indicating which character encoding is in use. Before an XML
7350 processor can read the internal label, however, it apparently has to
7351 know what character encoding is in use — which is what the internal
7352 label is trying to indicate. In the general case, this is a hopeless
7353 situation. It is not entirely hopeless in XML, however, because XML
7354 limits the general case in two ways: each implementation is assumed to
7355 support only a finite set of character encodings, and the XML encoding
7356 declaration is restricted in position and content in order to make it
7357 feasible to autodetect the character encoding in use in each entity in
7358 normal cases. Also, in many cases other sources of information are
7359 available in addition to the XML data stream itself. Two cases may be
7360 distinguished, depending on whether the XML entity is presented to the
7361 processor without, or with, any accompanying (external) information.
7362 We consider the first case first.
7363 </p>
7364 <div class="div2">
7365 <h3>
7366 <a
7367 name="sec-guessing-no-ext-info"
7368 id="sec-guessing-no-ext-info"
7369 />E.1 Detection Without External Encoding Information
7370 </h3>
7371 <p>
7372 Because each XML entity not accompanied by external encoding
7373 information and not in UTF-8 or UTF-16 encoding must begin with an
7374 XML encoding declaration, in which the first characters must be
7375 '<code>&lt;?xml</code>', any conforming processor can detect, after
7376 two to four octets of input, which of the following cases apply. In
7377 reading this list, it may help to know that in UCS-4, '&lt;' is
7378 "<code>#x0000003C</code>" and '?' is "<code>#x0000003F</code>", and
7379 the Byte Order Mark required of UTF-16 data streams is
7380 "<code>#xFEFF</code>". The notation <var>##</var> is used to denote
7381 any byte value except that two consecutive <var>##</var>s cannot be
7382 both 00.
7383 </p>
7384 <p>With a Byte Order Mark:</p>
7385 <table border="1" frame="border" summary="Encoding detection summary">
7386 <tbody>
7387 <tr>
7388 <td>
7389 <code>00 00 FE FF</code>
7390 </td>
7391 <td>UCS-4, big-endian machine (1234 order)</td>
7392 </tr>
7393 <tr>
7394 <td>
7395 <code>FF FE 00 00</code>
7396 </td>
7397 <td>UCS-4, little-endian machine (4321 order)</td>
7398 </tr>
7399 <tr>
7400 <td>
7401 <code>00 00 FF FE</code>
7402 </td>
7403 <td>UCS-4, unusual octet order (2143)</td>
7404 </tr>
7405 <tr>
7406 <td>
7407 <code>FE FF 00 00</code>
7408 </td>
7409 <td>UCS-4, unusual octet order (3412)</td>
7410 </tr>
7411 <tr>
7412 <td>
7413 <code>FE FF ## ##</code>
7414 </td>
7415 <td>UTF-16, big-endian</td>
7416 </tr>
7417 <tr>
7418 <td>
7419 <code>FF FE ## ##</code>
7420 </td>
7421 <td>UTF-16, little-endian</td>
7422 </tr>
7423 <tr>
7424 <td>
7425 <code>EF BB BF</code>
7426 </td>
7427 <td>UTF-8</td>
7428 </tr>
7429 </tbody>
7430 </table>
7431 <p>Without a Byte Order Mark:</p>
7432 <table border="1" frame="border" summary="Encoding detection summary">
7433 <tbody>
7434 <tr>
7435 <td>
7436 <code>00&nbsp;00&nbsp;00&nbsp;3C</code>
7437 </td>
7438 <td rowspan="4">
7439 UCS-4 or other encoding with a 32-bit code unit and ASCII
7440 characters encoded as ASCII values, in respectively big-endian
7441 (1234), little-endian (4321) and two unusual byte orders (2143
7442 and 3412). The encoding declaration must be read to determine
7443 which of UCS-4 or other supported 32-bit encodings applies.
7444 </td>
7445 </tr>
7446 <tr>
7447 <td>
7448 <code>3C 00 00 00</code>
7449 </td>
7450 </tr>
7451 <tr>
7452 <td>
7453 <code>00 00 3C 00</code>
7454 </td>
7455 </tr>
7456 <tr>
7457 <td>
7458 <code>00 3C 00 00</code>
7459 </td>
7460 </tr>
7461 <tr>
7462 <td>
7463 <code>00 3C 00 3F</code>
7464 </td>
7465 <td>
7466 UTF-16BE or big-endian ISO-10646-UCS-2 or other encoding with
7467 a 16-bit code unit in big-endian order and ASCII characters
7468 encoded as ASCII values (the encoding declaration must be read
7469 to determine which)
7470 </td>
7471 </tr>
7472 <tr>
7473 <td>
7474 <code>3C 00 3F 00</code>
7475 </td>
7476 <td>
7477 UTF-16LE or little-endian ISO-10646-UCS-2 or other encoding
7478 with a 16-bit code unit in little-endian order and ASCII
7479 characters encoded as ASCII values (the encoding declaration
7480 must be read to determine which)
7481 </td>
7482 </tr>
7483 <tr>
7484 <td>
7485 <code>3C 3F 78 6D</code>
7486 </td>
7487 <td>
7488 UTF-8, ISO 646, ASCII, some part of ISO 8859, Shift-JIS, EUC,
7489 or any other 7-bit, 8-bit, or mixed-width encoding which
7490 ensures that the characters of ASCII have their normal
7491 positions, width, and values; the actual encoding declaration
7492 must be read to detect which of these applies, but since all
7493 of these encodings use the same bit patterns for the relevant
7494 ASCII characters, the encoding declaration itself may be read
7495 reliably
7496 </td>
7497 </tr>
7498 <tr>
7499 <td>
7500 <code>4C 6F A7 94</code>
7501 </td>
7502 <td>
7503 EBCDIC (in some flavor; the full encoding declaration must be
7504 read to tell which code page is in use)
7505 </td>
7506 </tr>
7507 <tr>
7508 <td>Other</td>
7509 <td>
7510 UTF-8 without an encoding declaration, or else the data stream
7511 is mislabeled (lacking a required encoding declaration),
7512 corrupt, fragmentary, or enclosed in a wrapper of some kind
7513 </td>
7514 </tr>
7515 </tbody>
7516 </table>
7517 <div class="note">
7518 <p class="prefix"><b>Note:</b></p>
7519 <p>
7520 In cases above which do not require reading the encoding
7521 declaration to determine the encoding, section 4.3.3 still
7522 requires that the encoding declaration, if present, be read and
7523 that the encoding name be checked to match the actual encoding of
7524 the entity. Also, it is possible that new character encodings will
7525 be invented that will make it necessary to use the encoding
7526 declaration to determine the encoding, in cases where this is not
7527 required at present.
7528 </p>
7529 </div>
7530 <p>
7531 This level of autodetection is enough to read the XML encoding
7532 declaration and parse the character-encoding identifier, which is
7533 still necessary to distinguish the individual members of each family
7534 of encodings (e.g. to tell UTF-8 from 8859, and the parts of 8859
7535 from each other, or to distinguish the specific EBCDIC code page in
7536 use, and so on).
7537 </p>
7538 <p>
7539 Because the contents of the encoding declaration are restricted to
7540 characters from the ASCII repertoire (however encoded), a processor
7541 can reliably read the entire encoding declaration as soon as it has
7542 detected which family of encodings is in use. Since in practice, all
7543 widely used character encodings fall into one of the categories
7544 above, the XML encoding declaration allows reasonably reliable
7545 in-band labeling of character encodings, even when external sources
7546 of information at the operating-system or transport-protocol level
7547 are unreliable. Character encodings such as UTF-7 that make
7548 overloaded usage of ASCII-valued bytes may fail to be reliably
7549 detected.
7550 </p>
7551 <p>
7552 Once the processor has detected the character encoding in use, it
7553 can act appropriately, whether by invoking a separate input routine
7554 for each case, or by calling the proper conversion function on each
7555 character of input.
7556 </p>
7557 <p>
7558 Like any self-labeling system, the XML encoding declaration will not
7559 work if any software changes the entity's character set or encoding
7560 without updating the encoding declaration. Implementors of
7561 character-encoding routines should be careful to ensure the accuracy
7562 of the internal and external information used to label the entity.
7563 </p>
7564 </div>
7565 <div class="div2">
7566 <h3>
7567 <a
7568 name="sec-guessing-with-ext-info"
7569 id="sec-guessing-with-ext-info"
7570 />E.2 Priorities in the Presence of External Encoding Information
7571 </h3>
7572 <p>
7573 The second possible case occurs when the XML entity is accompanied
7574 by encoding information, as in some file systems and some network
7575 protocols. When multiple sources of information are available, their
7576 relative priority and the preferred method of handling conflict
7577 should be specified as part of the higher-level protocol used to
7578 deliver XML. In particular, please refer to
7579 <a href="#rfc2376">[IETF RFC 3023]</a> or its successor, which
7580 defines the <code>text/xml</code> and
7581 <code>application/xml</code> MIME types and provides some useful
7582 guidance. In the interests of interoperability, however, the
7583 following rule is recommended.
7584 </p>
7585 <ul>
7586 <li>
7587 <p>
7588 If an XML entity is in a file, the Byte-Order Mark and encoding
7589 declaration are used (if present) to determine the character
7590 encoding.
7591 </p>
7592 </li>
7593 </ul>
7594 </div>
7595 </div>
7596 <div class="div1">
7597 <h2>
7598 <a name="sec-xml-wg" id="sec-xml-wg" />F W3C XML Working Group
7599 (Non-Normative)
7600 </h2>
7601 <p>
7602 This specification was prepared and approved for publication by the
7603 W3C XML Working Group (WG). WG approval of this specification does not
7604 necessarily imply that all WG participants voted for its approval. The
7605 current and former members in the XML WG are:
7606 </p>
7607 <ul>
7608 <li>Jon Bosak, Sun (<i>Chair</i>)</li>
7609 <li>James Clark (<i>Technical Lead</i>)</li>
7610 <li>Tim Bray, Textuality and Netscape (<i>XML Co-editor</i>)</li>
7611 <li>Jean Paoli, Microsoft (<i>XML Co-editor</i>)</li>
7612 <li>C. M. Sperberg-McQueen, U. of Ill. (<i>XML Co-editor</i>)</li>
7613 <li>Dan Connolly, W3C (<i>W3C Liaison</i>)</li>
7614 <li>Paula Angerstein, Texcel</li>
7615 <li>Steve DeRose, INSO</li>
7616 <li>Dave Hollander, HP</li>
7617 <li>Eliot Kimber, ISOGEN</li>
7618 <li>Eve Maler, ArborText</li>
7619 <li>Tom Magliery, NCSA</li>
7620 <li>Murray Maloney, SoftQuad, Grif SA, Muzmo and Veo Systems</li>
7621 <li>MURATA Makoto (FAMILY Given), Fuji Xerox Information Systems</li>
7622 <li>Joel Nava, Adobe</li>
7623 <li>Conleth O'Connell, Vignette</li>
7624 <li>Peter Sharpe, SoftQuad</li>
7625 <li>John Tigue, DataChannel</li>
7626 </ul>
7627 </div>
7628 <div class="div1">
7629 <h2>
7630 <a name="sec-core-wg" id="sec-core-wg" />G W3C XML Core Working Group
7631 (Non-Normative)
7632 </h2>
7633 <p>
7634 The <span>second</span> edition of this specification was prepared by
7635 the W3C XML Core Working Group (WG). The participants in the WG at the
7636 time of publication of this edition were:
7637 </p>
7638 <ul>
7639 <li>Leonid Arbouzov, Sun Microsystems</li>
7640 <li>John Cowan</li>
7641 <li>Andrew Fang, PTC-Arbortext</li>
7642 <li>Paul Grosso, PTC-Arbortext (<i>Co-Chair</i>)</li>
7643 <li>Konrad Lanz, A-SIT</li>
7644 <li>Philippe Le Hégaret, W3C (<i>Staff Contact</i>)</li>
7645 <li>Glenn Marcy, IBM</li>
7646 <li>Sandra Martinez, NIST</li>
7647 <li>Ravindrakumar R, CDAC</li>
7648 <li>Lew Shannon</li>
7649 <li>Henry Thompson, W3C (<i>Staff Contact</i>)</li>
7650 <li>Richard Tobin, University of Edinburgh</li>
7651 <li>Daniel Veillard</li>
7652 <li>Norman Walsh, Sun Microsystems (<i>Co-Chair</i>)</li>
7653 <li>François Yergeau</li>
7654 </ul>
7655 </div>
7656 <div class="div1">
7657 <h2>
7658 <a name="prod-notes" id="prod-notes" />H Production Notes
7659 (Non-Normative)
7660 </h2>
7661 <p>
7662 This edition was encoded in a slightly modified version of the
7663 <a href="http://www.w3.org/2002/xmlspec/dtd/2.10/xmlspec.dtd"
7664 >XMLspec DTD, 2.10</a
7665 >. The XHTML versions were produced with a combination of the
7666 <a href="http://www.w3.org/2002/xmlspec/xhtml/1.13/xmlspec.xsl"
7667 >xmlspec.xsl</a
7668 >,
7669 <a href="http://www.w3.org/2002/xmlspec/xhtml/1.13/diffspec.xsl"
7670 >diffspec.xsl</a
7671 >, and <a href="REC-xml.xsl">REC-xml.xsl</a> XSLT stylesheets.
7672 </p>
7673 </div>
7674 <div class="div1">
7675 <h2>
7676 <a name="sec-suggested-names" id="sec-suggested-names" />I Suggestions
7677 for XML Names (Non-Normative)
7678 </h2>
7679 <p>
7680 The following suggestions define what is believed to be best practice
7681 in the construction of XML names used as element names, attribute
7682 names, processing instruction targets, entity names, notation names,
7683 and the values of attributes of type ID, and are intended as guidance
7684 for document authors and schema designers. All references to Unicode
7685 are understood with respect to a particular version of the Unicode
7686 Standard greater than or equal to 3.0; which version should be used is
7687 left to the discretion of the document author or schema designer.
7688 </p>
7689 <p>
7690 The first two suggestions are directly derived from the rules given
7691 for identifiers in the Unicode Standard, version 3.0, and exclude all
7692 control characters, enclosing nonspacing marks, non-decimal numbers,
7693 private-use characters, punctuation characters (with the noted
7694 exceptions), symbol characters, unassigned codepoints, and white space
7695 characters. The other suggestions are mostly derived from
7696 <a href="#XML1.0">[XML-1.0]</a> Appendix B.
7697 </p>
7698 <ol class="enumar">
7699 <li>
7700 <p>
7701 The first character of any name should have a Unicode General
7702 Category of Ll, Lu, Lo, Lm, Lt, or Nl, or else be '_' #x5F.
7703 </p>
7704 </li>
7705 <li>
7706 <p>
7707 Characters other than the first should have a Unicode General
7708 Category of Ll, Lu, Lo, Lm, Lt, Mc, Mn, Nl, Nd, Pc, or Cf, or else
7709 be one of the following: '-' #x2D, '.' #x2E, ':' #x3A or '·' #xB7
7710 (middle dot). Since Cf characters are not directly visible, they
7711 should be employed with caution and only when necessary, to avoid
7712 creating names which are distinct to XML processors but look the
7713 same to human beings.
7714 </p>
7715 </li>
7716 <li>
7717 <p>
7718 Ideographic characters which have a canonical decomposition
7719 (including those in the ranges [#xF900-#xFAFF] and
7720 [#x2F800-#x2FFFD], with 12 exceptions) should not be used in
7721 names.
7722 </p>
7723 </li>
7724 <li>
7725 <p>
7726 Characters which have a compatibility decomposition (those with a
7727 "compatibility formatting tag" in field 5 of the Unicode Character
7728 Database -- marked by field 5 beginning with a "&lt;") should not
7729 be used in names. This suggestion does not apply to #x0E33 THAI
7730 CHARACTER SARA AM or #x0EB3 LAO CHARACTER AM, which despite their
7731 compatibility decompositions are in regular use in those scripts.
7732 </p>
7733 </li>
7734 <li>
7735 <p>
7736 Combining characters meant for use with symbols only (including
7737 those in the ranges [#x20D0-#x20EF] and [#x1D165-#x1D1AD]) should
7738 not be used in names.
7739 </p>
7740 </li>
7741 <li>
7742 <p>
7743 The interlinear annotation characters ([#xFFF9-#xFFFB<span>
7744 ]</span
7745 >) should not be used in names.
7746 </p>
7747 </li>
7748 <li>
7749 <p>Variation selector characters should not be used in names.</p>
7750 </li>
7751 <li>
7752 <p>
7753 Names which are nonsensical, unpronounceable, hard to read, or
7754 easily confusable with other names should not be employed.
7755 </p>
7756 </li>
7757 </ol>
7758 </div>
7759 </div>
7760 <script
7761 type="application/javascript"
7762 src="https://www.w3.org/scripts/TR/fixup.js"
7763 ></script>
7764 </body>
7765 </html>