• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
2<!DOCTYPE spec SYSTEM "dtds/spec.dtd" [
3
4<!-- LAST TOUCHED BY: Tim Bray, 8 February 1997 -->
5
6<!-- The words 'FINAL EDIT' in comments mark places where changes
7need to be made after approval of the document by the ERB, before
8publication.  -->
9
10<!ENTITY XML.version "1.0">
11<!ENTITY doc.date "10 February 1998">
12<!ENTITY iso6.doc.date "19980210">
13<!ENTITY w3c.doc.date "02-Feb-1998">
14<!ENTITY draft.day '10'>
15<!ENTITY draft.month 'February'>
16<!ENTITY draft.year '1998'>
17
18<!ENTITY WebSGML
19 'WebSGML Adaptations Annex to ISO 8879'>
20
21<!ENTITY lt     "<">
22<!ENTITY gt     ">">
23<!ENTITY xmlpio "'&lt;?xml'">
24<!ENTITY pic    "'?>'">
25<!ENTITY br     "\n">
26<!ENTITY cellback '#c0d9c0'>
27<!ENTITY mdash  "--"> <!-- &#x2014, but nsgmls doesn't grok hex -->
28<!ENTITY com    "--">
29<!ENTITY como   "--">
30<!ENTITY comc   "--">
31<!ENTITY hcro   "&amp;#x">
32<!-- <!ENTITY nbsp "�"> -->
33<!ENTITY nbsp   "&#160;">
34<!ENTITY magicents "<code>amp</code>,
35<code>lt</code>,
36<code>gt</code>,
37<code>apos</code>,
38<code>quot</code>">
39
40<!-- audience and distribution status:  for use at publication time -->
41<!ENTITY doc.audience "public review and discussion">
42<!ENTITY doc.distribution "may be distributed freely, as long as
43all text and legal notices remain intact">
44
45]>
46
47<!-- for Panorama *-->
48<?VERBATIM "eg" ?>
49
50<spec>
51<header>
52<title>Extensible Markup Language (XML) 1.0</title>
53<version></version>
54<w3c-designation>REC-xml-&iso6.doc.date;</w3c-designation>
55<w3c-doctype>W3C Recommendation</w3c-doctype>
56<pubdate><day>&draft.day;</day><month>&draft.month;</month><year>&draft.year;</year></pubdate>
57
58<publoc>
59<loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;">
60http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;</loc>
61<loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.xml">
62http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.xml</loc>
63<loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.html">
64http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.html</loc>
65<loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.pdf">
66http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.pdf</loc>
67<loc  href="http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.ps">
68http://www.w3.org/TR/1998/REC-xml-&iso6.doc.date;.ps</loc>
69</publoc>
70<latestloc>
71<loc  href="http://www.w3.org/TR/REC-xml">
72http://www.w3.org/TR/REC-xml</loc>
73</latestloc>
74<prevlocs>
75<loc  href="http://www.w3.org/TR/PR-xml-971208">
76http://www.w3.org/TR/PR-xml-971208</loc>
77<!--
78<loc  href='http://www.w3.org/TR/WD-xml-961114'>
79http://www.w3.org/TR/WD-xml-961114</loc>
80<loc  href='http://www.w3.org/TR/WD-xml-lang-970331'>
81http://www.w3.org/TR/WD-xml-lang-970331</loc>
82<loc  href='http://www.w3.org/TR/WD-xml-lang-970630'>
83http://www.w3.org/TR/WD-xml-lang-970630</loc>
84<loc  href='http://www.w3.org/TR/WD-xml-970807'>
85http://www.w3.org/TR/WD-xml-970807</loc>
86<loc  href='http://www.w3.org/TR/WD-xml-971117'>
87http://www.w3.org/TR/WD-xml-971117</loc>-->
88</prevlocs>
89<authlist>
90<author><name>Tim Bray</name>
91<affiliation>Textuality and Netscape</affiliation>
92<email
93href="mailto:tbray@textuality.com">tbray@textuality.com</email></author>
94<author><name>Jean Paoli</name>
95<affiliation>Microsoft</affiliation>
96<email href="mailto:jeanpa@microsoft.com">jeanpa@microsoft.com</email></author>
97<author><name>C. M. Sperberg-McQueen</name>
98<affiliation>University of Illinois at Chicago</affiliation>
99<email href="mailto:cmsmcq@uic.edu">cmsmcq@uic.edu</email></author>
100</authlist>
101<abstract>
102<p>The Extensible Markup Language (XML) is a subset of
103SGML that is completely described in this document. Its goal is to
104enable generic SGML to be served, received, and processed on the Web
105in the way that is now possible with HTML. XML has been designed for
106ease of implementation and for interoperability with both SGML and
107HTML.</p>
108</abstract>
109<status>
110<p>This document has been reviewed by W3C Members and
111other interested parties and has been endorsed by the
112Director as a W3C Recommendation. It is a stable
113document and may be used as reference material or cited
114as a normative reference from another document. W3C's
115role in making the Recommendation is to draw attention
116to the specification and to promote its widespread
117deployment. This enhances the functionality and
118interoperability of the Web.</p>
119<p>
120This document specifies a syntax created by subsetting an existing,
121widely used international text processing standard (Standard
122Generalized Markup Language, ISO 8879:1986(E) as amended and
123corrected) for use on the World Wide Web.  It is a product of the W3C
124XML Activity, details of which can be found at <loc
125href='http://www.w3.org/XML'>http://www.w3.org/XML</loc>.  A list of
126current W3C Recommendations and other technical documents can be found
127at <loc href='http://www.w3.org/TR'>http://www.w3.org/TR</loc>.
128</p>
129<p>This specification uses the term URI, which is defined by <bibref
130ref="Berners-Lee"/>, a work in progress expected to update <bibref
131ref="RFC1738"/> and <bibref ref="RFC1808"/>.
132</p>
133<p>The list of known errors in this specification is
134available at
135<loc href='http://www.w3.org/XML/xml-19980210-errata'>http://www.w3.org/XML/xml-19980210-errata</loc>.</p>
136<p>Please report errors in this document to
137<loc href='mailto:xml-editor@w3.org'>xml-editor@w3.org</loc>.
138</p>
139</status>
140
141
142<pubstmt>
143<p>Chicago, Vancouver, Mountain View, et al.:
144World-Wide Web Consortium, XML Working Group, 1996, 1997.</p>
145</pubstmt>
146<sourcedesc>
147<p>Created in electronic form.</p>
148</sourcedesc>
149<langusage>
150<language id='EN'>English</language>
151<language id='ebnf'>Extended Backus-Naur Form (formal grammar)</language>
152</langusage>
153<revisiondesc>
154<slist>
155<sitem>1997-12-03 : CMSMcQ : yet further changes</sitem>
156<sitem>1997-12-02 : TB : further changes (see TB to XML WG,
1572 December 1997)</sitem>
158<sitem>1997-12-02 : CMSMcQ : deal with as many corrections and
159comments from the proofreaders as possible:
160entify hard-coded document date in pubdate element,
161change expansion of entity WebSGML,
162update status description as per Dan Connolly (am not sure
163about refernece to Berners-Lee et al.),
164add 'The' to abstract as per WG decision,
165move Relationship to Existing Standards to back matter and
166combine with References,
167re-order back matter so normative appendices come first,
168re-tag back matter so informative appendices are tagged informdiv1,
169remove XXX XXX from list of 'normative' specs in prose,
170move some references from Other References to Normative References,
171add RFC 1738, 1808, and 2141 to Other References (they are not
172normative since we do not require the processor to enforce any
173rules based on them),
174add reference to 'Fielding draft' (Berners-Lee et al.),
175move notation section to end of body,
176drop URIchar non-terminal and use SkipLit instead,
177lose stray reference to defunct nonterminal 'markupdecls',
178move reference to Aho et al. into appendix (Tim's right),
179add prose note saying that hash marks and fragment identifiers are
180NOT part of the URI formally speaking, and are NOT legal in
181system identifiers (processor 'may' signal an error).
182Work through:
183Tim Bray reacting to James Clark,
184Tim Bray on his own,
185Eve Maler,
186
187NOT DONE YET:
188change binary / text to unparsed / parsed.
189handle James's suggestion about &lt; in attriubte values
190uppercase hex characters,
191namechar list,
192</sitem>
193<sitem>1997-12-01 : JB : add some column-width parameters</sitem>
194<sitem>1997-12-01 : CMSMcQ : begin round of changes to incorporate
195recent WG decisions and other corrections:
196binding sources of character encoding info (27 Aug / 3 Sept),
197correct wording of Faust quotation (restore dropped line),
198drop SDD from EncodingDecl,
199change text at version number 1.0,
200drop misleading (wrong!) sentence about ignorables and extenders,
201modify definition of PCData to make bar on msc grammatical,
202change grammar's handling of internal subset (drop non-terminal markupdecls),
203change definition of includeSect to allow conditional sections,
204add integral-declaration constraint on internal subset,
205drop misleading / dangerous sentence about relationship of
206entities with system storage objects,
207change table body tag to htbody as per EM change to DTD,
208add rule about space normalization in public identifiers,
209add description of how to generate our name-space rules from
210Unicode character database (needs further work!).
211</sitem>
212<sitem>1997-10-08 : TB : Removed %-constructs again, new rules
213for PE appearance.</sitem>
214<sitem>1997-10-01 : TB : Case-sensitive markup; cleaned up
215element-type defs, lotsa little edits for style</sitem>
216<sitem>1997-09-25 : TB : Change to elm's new DTD, with
217substantial detail cleanup as a side-effect</sitem>
218<sitem>1997-07-24 : CMSMcQ : correct error (lost *) in definition
219of ignoreSectContents (thanks to Makoto Murata)</sitem>
220<sitem>Allow all empty elements to have end-tags, consistent with
221SGML TC (as per JJC).</sitem>
222<sitem>1997-07-23 : CMSMcQ : pre-emptive strike on pending corrections:
223introduce the term 'empty-element tag', note that all empty elements
224may use it, and elements declared EMPTY must use it.
225Add WFC requiring encoding decl to come first in an entity.
226Redefine notations to point to PIs as well as binary entities.
227Change autodetection table by removing bytes 3 and 4 from
228examples with Byte Order Mark.
229Add content model as a term and clarify that it applies to both
230mixed and element content.
231</sitem>
232<sitem>1997-06-30 : CMSMcQ : change date, some cosmetic changes,
233changes to productions for choice, seq, Mixed, NotationType,
234Enumeration.  Follow James Clark's suggestion and prohibit
235conditional sections in internal subset.  TO DO:  simplify
236production for ignored sections as a result, since we don't
237need to worry about parsers which don't expand PErefs finding
238a conditional section.</sitem>
239<sitem>1997-06-29 : TB : various edits</sitem>
240<sitem>1997-06-29 : CMSMcQ : further changes:
241Suppress old FINAL EDIT comments and some dead material.
242Revise occurrences of % in grammar to exploit Henry Thompson's pun,
243especially markupdecl and attdef.
244Remove RMD requirement relating to element content (?).
245</sitem>
246<sitem>1997-06-28 : CMSMcQ : Various changes for 1 July draft:
247Add text for draconian error handling (introduce
248the term Fatal Error).
249RE deleta est (changing wording from
250original announcement to restrict the requirement to validating
251parsers).
252Tag definition of validating processor and link to it.
253Add colon as name character.
254Change def of %operator.
255Change standard definitions of lt, gt, amp.
256Strip leading zeros from #x00nn forms.</sitem>
257<sitem>1997-04-02 : CMSMcQ : final corrections of editorial errors
258found in last night's proofreading.  Reverse course once more on
259well-formed:   Webster's Second hyphenates it, and that's enough
260for me.</sitem>
261<sitem>1997-04-01 : CMSMcQ : corrections from JJC, EM, HT, and self</sitem>
262<sitem>1997-03-31 : Tim Bray : many changes</sitem>
263<sitem>1997-03-29 : CMSMcQ : some Henry Thompson (on entity handling),
264some Charles Goldfarb, some ERB decisions (PE handling in miscellaneous
265declarations.  Changed Ident element to accept def attribute.
266Allow normalization of Unicode characters.  move def of systemliteral
267into section on literals.</sitem>
268<sitem>1997-03-28 : CMSMcQ : make as many corrections as possible, from
269Terry Allen, Norbert Mikula, James Clark, Jon Bosak, Henry Thompson,
270Paul Grosso, and self.  Among other things:  give in on "well formed"
271(Terry is right), tentatively rename QuotedCData as AttValue
272and Literal as EntityValue to be more informative, since attribute
273values are the <emph>only</emph> place QuotedCData was used, and
274vice versa for entity text and Literal. (I'd call it Entity Text,
275but 8879 uses that name for both internal and external entities.)</sitem>
276<sitem>1997-03-26 : CMSMcQ : resynch the two forks of this draft, reapply
277my changes dated 03-20 and 03-21.  Normalize old 'may not' to 'must not'
278except in the one case where it meant 'may or may not'.</sitem>
279<sitem>1997-03-21 : TB : massive changes on plane flight from Chicago
280to Vancouver</sitem>
281<sitem>1997-03-21 : CMSMcQ : correct as many reported errors as possible.
282</sitem>
283<sitem>1997-03-20 : CMSMcQ : correct typos listed in CMSMcQ hand copy of spec.</sitem>
284<sitem>1997-03-20 : CMSMcQ : cosmetic changes preparatory to revision for
285WWW conference April 1997:  restore some of the internal entity
286references (e.g. to docdate, etc.), change character xA0 to &amp;nbsp;
287and define nbsp as &amp;#160;, and refill a lot of paragraphs for
288legibility.</sitem>
289<sitem>1996-11-12 : CMSMcQ : revise using Tim's edits:
290Add list type of NUMBERED and change most lists either to
291BULLETS or to NUMBERED.
292Suppress QuotedNames, Names (not used).
293Correct trivial-grammar doc type decl.
294Rename 'marked section' as 'CDATA section' passim.
295Also edits from James Clark:
296Define the set of characters from which [^abc] subtracts.
297Charref should use just [0-9] not Digit.
298Location info needs cleaner treatment:  remove?  (ERB
299question).
300One example of a PI has wrong pic.
301Clarify discussion of encoding names.
302Encoding failure should lead to unspecified results; don't
303prescribe error recovery.
304Don't require exposure of entity boundaries.
305Ignore white space in element content.
306Reserve entity names of the form u-NNNN.
307Clarify relative URLs.
308And some of my own:
309Correct productions for content model:  model cannot
310consist of a name, so "elements ::= cp" is no good.
311</sitem>
312<sitem>1996-11-11 : CMSMcQ : revise for style.
313Add new rhs to entity declaration, for parameter entities.</sitem>
314<sitem>1996-11-10 : CMSMcQ : revise for style.
315Fix / complete section on names, characters.
316Add sections on parameter entities, conditional sections.
317Still to do:  Add compatibility note on deterministic content models.
318Finish stylistic revision.</sitem>
319<sitem>1996-10-31 : TB : Add Entity Handling section</sitem>
320<sitem>1996-10-30 : TB : Clean up term &amp; termdef.  Slip in
321ERB decision re EMPTY.</sitem>
322<sitem>1996-10-28 : TB : Change DTD.  Implement some of Michael's
323suggestions.  Change comments back to //.  Introduce language for
324XML namespace reservation.  Add section on white-space handling.
325Lots more cleanup.</sitem>
326<sitem>1996-10-24 : CMSMcQ : quick tweaks, implement some ERB
327decisions.  Characters are not integers.  Comments are /* */ not //.
328Add bibliographic refs to 10646, HyTime, Unicode.
329Rename old Cdata as MsData since it's <emph>only</emph> seen
330in marked sections.  Call them attribute-value pairs not
331name-value pairs, except once.  Internal subset is optional, needs
332'?'.  Implied attributes should be signaled to the app, not
333have values supplied by processor.</sitem>
334<sitem>1996-10-16 : TB : track down &amp; excise all DSD references;
335introduce some EBNF for entity declarations.</sitem>
336<sitem>1996-10-?? : TB : consistency check, fix up scraps so
337they all parse, get formatter working, correct a few productions.</sitem>
338<sitem>1996-10-10/11 : CMSMcQ : various maintenance, stylistic, and
339organizational changes:
340Replace a few literals with xmlpio and
341pic entities, to make them consistent and ensure we can change pic
342reliably when the ERB votes.
343Drop paragraph on recognizers from notation section.
344Add match, exact match to terminology.
345Move old 2.2 XML Processors and Apps into intro.
346Mention comments, PIs, and marked sections in discussion of
347delimiter escaping.
348Streamline discussion of doctype decl syntax.
349Drop old section of 'PI syntax' for doctype decl, and add
350section on partial-DTD summary PIs to end of Logical Structures
351section.
352Revise DSD syntax section to use Tim's subset-in-a-PI
353mechanism.</sitem>
354<sitem>1996-10-10 : TB : eliminate name recognizers (and more?)</sitem>
355<sitem>1996-10-09 : CMSMcQ : revise for style, consistency through 2.3
356(Characters)</sitem>
357<sitem>1996-10-09 : CMSMcQ : re-unite everything for convenience,
358at least temporarily, and revise quickly</sitem>
359<sitem>1996-10-08 : TB : first major homogenization pass</sitem>
360<sitem>1996-10-08 : TB : turn "current" attribute on div type into
361CDATA</sitem>
362<sitem>1996-10-02 : TB : remould into skeleton + entities</sitem>
363<sitem>1996-09-30 : CMSMcQ : add a few more sections prior to exchange
364                            with Tim.</sitem>
365<sitem>1996-09-20 : CMSMcQ : finish transcribing notes.</sitem>
366<sitem>1996-09-19 : CMSMcQ : begin transcribing notes for draft.</sitem>
367<sitem>1996-09-13 : CMSMcQ : made outline from notes of 09-06,
368do some housekeeping</sitem>
369</slist>
370</revisiondesc>
371</header>
372<body>
373<div1 id='sec-intro'>
374<head>Introduction</head>
375<p>Extensible Markup Language, abbreviated XML, describes a class of
376data objects called <termref def="dt-xml-doc">XML documents</termref> and
377partially describes the behavior of
378computer programs which process them. XML is an application profile or
379restricted form of SGML, the Standard Generalized Markup
380Language <bibref ref='ISO8879'/>.
381By construction, XML documents
382are conforming SGML documents.
383</p>
384<p>XML documents are made up of storage units called <termref
385def="dt-entity">entities</termref>, which contain either parsed
386or unparsed data.
387Parsed data is made up of <termref def="dt-character">characters</termref>,
388some
389of which form <termref def="dt-chardata">character data</termref>,
390and some of which form <termref def="dt-markup">markup</termref>.
391Markup encodes a description of the document's storage layout and
392logical structure. XML provides a mechanism to impose constraints on
393the storage layout and logical structure.</p>
394<p><termdef id="dt-xml-proc" term="XML Processor">A software module
395called an <term>XML processor</term> is used to read XML documents
396and provide access to their content and structure.</termdef> <termdef
397id="dt-app" term="Application">It is assumed that an XML processor is
398doing its work on behalf of another module, called the
399<term>application</term>.</termdef> This specification describes the
400required behavior of an XML processor in terms of how it must read XML
401data and the information it must provide to the application.</p>
402
403<div2 id='sec-origin-goals'>
404<head>Origin and Goals</head>
405<p>XML was developed by an XML Working Group (originally known as the
406SGML Editorial Review Board) formed under the auspices of the World
407Wide Web Consortium (W3C) in 1996.
408It was chaired by Jon Bosak of Sun
409Microsystems with the active participation of an XML Special
410Interest Group (previously known as the SGML Working Group) also
411organized by the W3C. The membership of the XML Working Group is given
412in an appendix. Dan Connolly served as the WG's contact with the W3C.
413</p>
414<p>The design goals for XML are:<olist>
415<item><p>XML shall be straightforwardly usable over the
416Internet.</p></item>
417<item><p>XML shall support a wide variety of applications.</p></item>
418<item><p>XML shall be compatible with SGML.</p></item>
419<item><p>It shall be easy to write programs which process XML
420documents.</p></item>
421<item><p>The number of optional features in XML is to be kept to the
422absolute minimum, ideally zero.</p></item>
423<item><p>XML documents should be human-legible and reasonably
424clear.</p></item>
425<item><p>The XML design should be prepared quickly.</p></item>
426<item><p>The design of XML shall be formal and concise.</p></item>
427<item><p>XML documents shall be easy to create.</p></item>
428<item><p>Terseness in XML markup is of minimal importance.</p></item></olist>
429</p>
430<p>This specification,
431together with associated standards
432(Unicode and ISO/IEC 10646 for characters,
433Internet RFC 1766 for language identification tags,
434ISO 639 for language name codes, and
435ISO 3166 for country name codes),
436provides all the information necessary to understand
437XML Version &XML.version;
438and construct computer programs to process it.</p>
439<p>This version of the XML specification
440<!-- is for &doc.audience;.-->
441&doc.distribution;.</p>
442
443</div2>
444
445
446
447
448<div2 id='sec-terminology'>
449<head>Terminology</head>
450
451<p>The terminology used to describe XML documents is defined in the body of
452this specification.
453The terms defined in the following list are used in building those
454definitions and in describing the actions of an XML processor:
455<glist>
456<gitem>
457<label>may</label>
458<def><p><termdef id="dt-may" term="May">Conforming documents and XML
459processors are permitted to but need not behave as
460described.</termdef></p></def>
461</gitem>
462<gitem>
463<label>must</label>
464<def><p>Conforming documents and XML processors
465are required to behave as described; otherwise they are in error.
466<!-- do NOT change this! this is what defines a violation of
467a 'must' clause as 'an error'. -MSM -->
468</p></def>
469</gitem>
470<gitem>
471<label>error</label>
472<def><p><termdef id='dt-error' term='Error'
473>A violation of the rules of this
474specification; results are
475undefined.  Conforming software may detect and report an error and may
476recover from it.</termdef></p></def>
477</gitem>
478<gitem>
479<label>fatal error</label>
480<def><p><termdef id="dt-fatal" term="Fatal Error">An error
481which a conforming <termref def="dt-xml-proc">XML processor</termref>
482must detect and report to the application.
483After encountering a fatal error, the
484processor may continue
485processing the data to search for further errors and may report such
486errors to the application.  In order to support correction of errors,
487the processor may make unprocessed data from the document (with
488intermingled character data and markup) available to the application.
489Once a fatal error is detected, however, the processor must not
490continue normal processing (i.e., it must not
491continue to pass character data and information about the document's
492logical structure to the application in the normal way).
493</termdef></p></def>
494</gitem>
495<gitem>
496<label>at user option</label>
497<def><p>Conforming software may or must (depending on the modal verb in the
498sentence) behave as described; if it does, it must
499provide users a means to enable or disable the behavior
500described.</p></def>
501</gitem>
502<gitem>
503<label>validity constraint</label>
504<def><p>A rule which applies to all
505<termref def="dt-valid">valid</termref> XML documents.
506Violations of validity constraints are errors; they must, at user option,
507be reported by
508<termref def="dt-validating">validating XML processors</termref>.</p></def>
509</gitem>
510<gitem>
511<label>well-formedness constraint</label>
512<def><p>A rule which applies to all <termref
513def="dt-wellformed">well-formed</termref> XML documents.
514Violations of well-formedness constraints are
515<termref def="dt-fatal">fatal errors</termref>.</p></def>
516</gitem>
517
518<gitem>
519<label>match</label>
520<def><p><termdef id="dt-match" term="match">(Of strings or names:)
521Two strings or names being compared must be identical.
522Characters with multiple possible representations in ISO/IEC 10646 (e.g.
523characters with
524both precomposed and base+diacritic forms) match only if they have the
525same representation in both strings.
526At user option, processors may normalize such characters to
527some canonical form.
528No case folding is performed.
529(Of strings and rules in the grammar:)
530A string matches a grammatical production if it belongs to the
531language generated by that production.
532(Of content and content models:)
533An element matches its declaration when it conforms
534in the fashion described in the constraint
535<specref ref='elementvalid'/>.
536</termdef>
537</p></def>
538</gitem>
539<gitem>
540<label>for compatibility</label>
541<def><p><termdef id="dt-compat" term="For Compatibility">A feature of
542XML included solely to ensure that XML remains compatible with SGML.
543</termdef></p></def>
544</gitem>
545<gitem>
546<label>for interoperability</label>
547<def><p><termdef id="dt-interop" term="For interoperability">A
548non-binding recommendation included to increase the chances that XML
549documents can be processed by the existing installed base of SGML
550processors which predate the
551&WebSGML;.</termdef></p></def>
552</gitem>
553</glist>
554</p>
555</div2>
556
557
558</div1>
559<!-- &Docs; -->
560
561<div1 id='sec-documents'>
562<head>Documents</head>
563
564<p><termdef id="dt-xml-doc" term="XML Document">
565A data object is an
566<term>XML document</term> if it is
567<termref def="dt-wellformed">well-formed</termref>, as
568defined in this specification.
569A well-formed XML document may in addition be
570<termref def="dt-valid">valid</termref> if it meets certain further
571constraints.</termdef></p>
572
573<p>Each XML document has both a logical and a physical structure.
574Physically, the document is composed of units called <termref
575def="dt-entity">entities</termref>.  An entity may <termref
576def="dt-entref">refer</termref> to other entities to cause their
577inclusion in the document. A document begins in a "root"  or <termref
578def="dt-docent">document entity</termref>.
579Logically, the document is composed of declarations, elements,
580comments,
581character references, and
582processing
583instructions, all of which are indicated in the document by explicit
584markup.
585The logical and physical structures must nest properly, as described
586in <specref ref='wf-entities'/>.
587</p>
588
589<div2 id='sec-well-formed'>
590<head>Well-Formed XML Documents</head>
591
592<p><termdef id="dt-wellformed" term="Well-Formed">
593A textual object is
594a well-formed XML document if:</termdef>
595<olist>
596<item><p>Taken as a whole, it
597matches the production labeled <nt def='NT-document'>document</nt>.</p></item>
598<item><p>It
599meets all the well-formedness constraints given in this specification.</p>
600</item>
601<item><p>Each of the <termref def='dt-parsedent'>parsed entities</termref>
602which is referenced directly or indirectly within the document is
603<titleref href='wf-entities'>well-formed</titleref>.</p></item>
604</olist></p>
605<p>
606<scrap lang='ebnf' id='document'>
607<head>Document</head>
608<prod id='NT-document'><lhs>document</lhs>
609<rhs><nt def='NT-prolog'>prolog</nt>
610<nt def='NT-element'>element</nt>
611<nt def='NT-Misc'>Misc</nt>*</rhs></prod>
612</scrap>
613</p>
614<p>Matching the <nt def="NT-document">document</nt> production
615implies that:
616<olist>
617<item><p>It contains one or more
618<termref def="dt-element">elements</termref>.</p>
619</item>
620<!--* N.B. some readers (notably JC) find the following
621paragraph awkward and redundant.  I agree it's logically redundant:
622it *says* it is summarizing the logical implications of
623matching the grammar, and that means by definition it's
624logically redundant.  I don't think it's rhetorically
625redundant or unnecessary, though, so I'm keeping it.  It
626could however use some recasting when the editors are feeling
627stronger. -MSM *-->
628<item><p><termdef id="dt-root" term="Root Element">There is  exactly
629one element, called the <term>root</term>, or document element,  no
630part of which appears in the <termref
631def="dt-content">content</termref> of any other element.</termdef>
632For all other elements, if the start-tag is in the content of another
633element, the end-tag is in the content of the same element.  More
634simply stated, the elements, delimited by start- and end-tags, nest
635properly within each other.
636</p></item>
637</olist>
638</p>
639<p><termdef id="dt-parentchild" term="Parent/Child">As a consequence
640of this,
641for each non-root element
642<code>C</code> in the document, there is one other element <code>P</code>
643in the document such that
644<code>C</code> is in the content of <code>P</code>, but is not in
645the content of any other element that is in the content of
646<code>P</code>.
647<code>P</code> is referred to as the
648<term>parent</term> of <code>C</code>, and <code>C</code> as a
649<term>child</term> of <code>P</code>.</termdef></p></div2>
650
651<div2 id="charsets">
652<head>Characters</head>
653
654<p><termdef id="dt-text" term="Text">A parsed entity contains
655<term>text</term>, a sequence of
656<termref def="dt-character">characters</termref>,
657which may represent markup or character data.</termdef>
658<termdef id="dt-character" term="Character">A <term>character</term>
659is an atomic unit of text as specified by
660ISO/IEC 10646 <bibref ref="ISO10646"/>.
661Legal characters are tab, carriage return, line feed, and the legal
662graphic characters of Unicode and ISO/IEC 10646.
663The use of "compatibility characters", as defined in section 6.8
664of <bibref ref='Unicode'/>, is discouraged.
665</termdef>
666<scrap lang="ebnf" id="char32">
667<head>Character Range</head>
668<prodgroup pcw2="4" pcw4="17.5" pcw5="11">
669<prod id="NT-Char"><lhs>Char</lhs>
670<rhs>#x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]
671| [#x10000-#x10FFFF]</rhs>
672<com>any Unicode character, excluding the
673surrogate blocks, FFFE, and FFFF.</com> </prod>
674</prodgroup>
675</scrap>
676</p>
677
678<p>The mechanism for encoding character code points into bit patterns may
679vary from entity to entity. All XML processors must accept the UTF-8
680and UTF-16 encodings of 10646; the mechanisms for signaling which of
681the two is in use, or for bringing other encodings into play, are
682discussed later, in <specref ref='charencoding'/>.
683</p>
684<!--
685<p>Regardless of the specific encoding used, any character in the ISO/IEC
68610646 character set may be referred to by the decimal or hexadecimal
687equivalent of its
688UCS-4 code value.
689</p>-->
690</div2>
691
692<div2 id='sec-common-syn'>
693<head>Common Syntactic Constructs</head>
694
695<p>This section defines some symbols used widely in the grammar.</p>
696<p><nt def="NT-S">S</nt> (white space) consists of one or more space (#x20)
697characters, carriage returns, line feeds, or tabs.
698
699<scrap lang="ebnf" id='white'>
700<head>White Space</head>
701<prodgroup pcw2="4" pcw4="17.5" pcw5="11">
702<prod id='NT-S'><lhs>S</lhs>
703<rhs>(#x20 | #x9 | #xD | #xA)+</rhs>
704</prod>
705</prodgroup>
706</scrap></p>
707<p>Characters are classified for convenience as letters, digits, or other
708characters.  Letters consist of an alphabetic or syllabic
709base character possibly
710followed by one or more combining characters, or of an ideographic
711character.
712Full definitions of the specific characters in each class
713are given in <specref ref='CharClasses'/>.</p>
714<p><termdef id="dt-name" term="Name">A <term>Name</term> is a token
715beginning with a letter or one of a few punctuation characters, and continuing
716with letters, digits, hyphens, underscores, colons, or full stops, together
717known as name characters.</termdef>
718Names beginning with the string "<code>xml</code>", or any string
719which would match <code>(('X'|'x') ('M'|'m') ('L'|'l'))</code>, are
720reserved for standardization in this or future versions of this
721specification.
722</p>
723<note>
724<p>The colon character within XML names is reserved for experimentation with
725name spaces.
726Its meaning is expected to be
727standardized at some future point, at which point those documents
728using the colon for experimental purposes may need to be updated.
729(There is no guarantee that any name-space mechanism
730adopted for XML will in fact use the colon as a name-space delimiter.)
731In practice, this means that authors should not use the colon in XML
732names except as part of name-space experiments, but that XML processors
733should accept the colon as a name character.</p>
734</note>
735<p>An
736<nt def='NT-Nmtoken'>Nmtoken</nt> (name token) is any mixture of
737name characters.
738<scrap lang='ebnf'>
739<head>Names and Tokens</head>
740<prod id='NT-NameChar'><lhs>NameChar</lhs>
741<rhs><nt def="NT-Letter">Letter</nt>
742| <nt def='NT-Digit'>Digit</nt>
743| '.' | '-' | '_' | ':'
744| <nt def='NT-CombiningChar'>CombiningChar</nt>
745| <nt def='NT-Extender'>Extender</nt></rhs>
746</prod>
747<prod id='NT-Name'><lhs>Name</lhs>
748<rhs>(<nt def='NT-Letter'>Letter</nt> | '_' | ':')
749(<nt def='NT-NameChar'>NameChar</nt>)*</rhs></prod>
750<prod id='NT-Names'><lhs>Names</lhs>
751<rhs><nt def='NT-Name'>Name</nt>
752(<nt def='NT-S'>S</nt> <nt def='NT-Name'>Name</nt>)*</rhs></prod>
753<prod id='NT-Nmtoken'><lhs>Nmtoken</lhs>
754<rhs>(<nt def='NT-NameChar'>NameChar</nt>)+</rhs></prod>
755<prod id='NT-Nmtokens'><lhs>Nmtokens</lhs>
756<rhs><nt def='NT-Nmtoken'>Nmtoken</nt> (<nt def='NT-S'>S</nt> <nt def='NT-Nmtoken'>Nmtoken</nt>)*</rhs></prod>
757</scrap>
758</p>
759<p>Literal data is any quoted string not containing
760the quotation mark used as a delimiter for that string.
761Literals are used
762for specifying the content of internal entities
763(<nt def='NT-EntityValue'>EntityValue</nt>),
764the values of attributes (<nt def='NT-AttValue'>AttValue</nt>),
765and external identifiers
766(<nt def="NT-SystemLiteral">SystemLiteral</nt>).
767Note that a <nt def='NT-SystemLiteral'>SystemLiteral</nt>
768can be parsed without scanning for markup.
769<scrap lang='ebnf'>
770<head>Literals</head>
771<prod id='NT-EntityValue'><lhs>EntityValue</lhs>
772<rhs>'"'
773([^%&amp;"]
774| <nt def='NT-PEReference'>PEReference</nt>
775| <nt def='NT-Reference'>Reference</nt>)*
776'"'
777</rhs>
778<rhs>|&nbsp;
779"'"
780([^%&amp;']
781| <nt def='NT-PEReference'>PEReference</nt>
782| <nt def='NT-Reference'>Reference</nt>)*
783"'"</rhs>
784</prod>
785<prod id='NT-AttValue'><lhs>AttValue</lhs>
786<rhs>'"'
787([^&lt;&amp;"]
788| <nt def='NT-Reference'>Reference</nt>)*
789'"'
790</rhs>
791<rhs>|&nbsp;
792"'"
793([^&lt;&amp;']
794| <nt def='NT-Reference'>Reference</nt>)*
795"'"</rhs>
796</prod>
797<prod id="NT-SystemLiteral"><lhs>SystemLiteral</lhs>
798<rhs>('"' [^"]* '"') |&nbsp;("'" [^']* "'")
799</rhs>
800</prod>
801<prod id="NT-PubidLiteral"><lhs>PubidLiteral</lhs>
802<rhs>'"' <nt def='NT-PubidChar'>PubidChar</nt>*
803'"'
804| "'" (<nt def='NT-PubidChar'>PubidChar</nt> - "'")* "'"</rhs>
805</prod>
806<prod id="NT-PubidChar"><lhs>PubidChar</lhs>
807<rhs>#x20 | #xD | #xA
808|&nbsp;[a-zA-Z0-9]
809|&nbsp;[-'()+,./:=?;!*#@$_%]</rhs>
810</prod>
811</scrap>
812</p>
813
814</div2>
815
816<div2 id='syntax'>
817<head>Character Data and Markup</head>
818
819<p><termref def='dt-text'>Text</termref> consists of intermingled
820<termref def="dt-chardata">character
821data</termref> and markup.
822<termdef id="dt-markup" term="Markup"><term>Markup</term> takes the form of
823<termref def="dt-stag">start-tags</termref>,
824<termref def="dt-etag">end-tags</termref>,
825<termref def="dt-empty">empty-element tags</termref>,
826<termref def="dt-entref">entity references</termref>,
827<termref def="dt-charref">character references</termref>,
828<termref def="dt-comment">comments</termref>,
829<termref def="dt-cdsection">CDATA section</termref> delimiters,
830<termref def="dt-doctype">document type declarations</termref>, and
831<termref def="dt-pi">processing instructions</termref>.
832</termdef>
833</p>
834<p><termdef id="dt-chardata" term="Character Data">All text that is not markup
835constitutes the <term>character data</term> of
836the document.</termdef></p>
837<p>The ampersand character (&amp;) and the left angle bracket (&lt;)
838may appear in their literal form <emph>only</emph> when used as markup
839delimiters, or within a <termref def="dt-comment">comment</termref>, a
840<termref def="dt-pi">processing instruction</termref>,
841or a <termref def="dt-cdsection">CDATA section</termref>.
842
843They are also legal within the <termref def='dt-litentval'>literal entity
844value</termref> of an internal entity declaration; see
845<specref ref='wf-entities'/>.
846<!-- FINAL EDIT:  restore internal entity decl or leave it out. -->
847If they are needed elsewhere,
848they must be <termref def="dt-escape">escaped</termref>
849using either <termref def='dt-charref'>numeric character references</termref>
850or the strings
851"<code>&amp;amp;</code>" and "<code>&amp;lt;</code>" respectively.
852The right angle
853bracket (>) may be represented using the string
854"<code>&amp;gt;</code>", and must, <termref def='dt-compat'>for
855compatibility</termref>,
856be escaped using
857"<code>&amp;gt;</code>" or a character reference
858when it appears in the string
859"<code>]]&gt;</code>"
860in content,
861when that string is not marking the end of
862a <termref def="dt-cdsection">CDATA section</termref>.
863</p>
864<p>
865In the content of elements, character data
866is any string of characters which does
867not contain the start-delimiter of any markup.
868In a CDATA section, character data
869is any string of characters not including the CDATA-section-close
870delimiter, "<code>]]&gt;</code>".</p>
871<p>
872To allow attribute values to contain both single and double quotes, the
873apostrophe or single-quote character (') may be represented as
874"<code>&amp;apos;</code>", and the double-quote character (") as
875"<code>&amp;quot;</code>".
876<scrap lang="ebnf">
877<head>Character Data</head>
878<prod id='NT-CharData'>
879<lhs>CharData</lhs>
880<rhs>[^&lt;&amp;]* - ([^&lt;&amp;]* ']]&gt;' [^&lt;&amp;]*)</rhs>
881</prod>
882</scrap>
883</p>
884</div2>
885
886<div2 id='sec-comments'>
887<head>Comments</head>
888
889<p><termdef id="dt-comment" term="Comment"><term>Comments</term> may
890appear anywhere in a document outside other
891<termref def='dt-markup'>markup</termref>; in addition,
892they may appear within the document type declaration
893at places allowed by the grammar.
894They are not part of the document's <termref def="dt-chardata">character
895data</termref>; an XML
896processor may, but need not, make it possible for an application to
897retrieve the text of comments.
898<termref def="dt-compat">For compatibility</termref>, the string
899"<code>--</code>" (double-hyphen) must not occur within
900comments.
901<scrap lang="ebnf">
902<head>Comments</head>
903<prod id='NT-Comment'><lhs>Comment</lhs>
904<rhs>'&lt;!--'
905((<nt def='NT-Char'>Char</nt> - '-')
906| ('-' (<nt def='NT-Char'>Char</nt> - '-')))*
907'-->'</rhs>
908</prod>
909</scrap>
910</termdef></p>
911<p>An example of a comment:
912<eg>&lt;!&como; declarations for &lt;head> &amp; &lt;body> &comc;&gt;</eg>
913</p>
914</div2>
915
916<div2 id='sec-pi'>
917<head>Processing Instructions</head>
918
919<p><termdef id="dt-pi" term="Processing instruction"><term>Processing
920instructions</term> (PIs) allow documents to contain instructions
921for applications.
922
923<scrap lang="ebnf">
924<head>Processing Instructions</head>
925<prod id='NT-PI'><lhs>PI</lhs>
926<rhs>'&lt;?' <nt def='NT-PITarget'>PITarget</nt>
927(<nt def='NT-S'>S</nt>
928(<nt def='NT-Char'>Char</nt>* -
929(<nt def='NT-Char'>Char</nt>* &pic; <nt def='NT-Char'>Char</nt>*)))?
930&pic;</rhs></prod>
931<prod id='NT-PITarget'><lhs>PITarget</lhs>
932<rhs><nt def='NT-Name'>Name</nt> -
933(('X' | 'x') ('M' | 'm') ('L' | 'l'))</rhs>
934</prod>
935</scrap></termdef>
936PIs are not part of the document's <termref def="dt-chardata">character
937data</termref>, but must be passed through to the application. The
938PI begins with a target (<nt def='NT-PITarget'>PITarget</nt>) used
939to identify the application to which the instruction is directed.
940The target names "<code>XML</code>", "<code>xml</code>", and so on are
941reserved for standardization in this or future versions of this
942specification.
943The
944XML <termref def='dt-notation'>Notation</termref> mechanism
945may be used for
946formal declaration of PI targets.
947</p>
948</div2>
949
950<div2 id='sec-cdata-sect'>
951<head>CDATA Sections</head>
952
953<p><termdef id="dt-cdsection" term="CDATA Section"><term>CDATA sections</term>
954may occur
955anywhere character data may occur; they are
956used to escape blocks of text containing characters which would
957otherwise be recognized as markup.  CDATA sections begin with the
958string "<code>&lt;![CDATA[</code>" and end with the string
959"<code>]]&gt;</code>":
960<scrap lang="ebnf">
961<head>CDATA Sections</head>
962<prod id='NT-CDSect'><lhs>CDSect</lhs>
963<rhs><nt def='NT-CDStart'>CDStart</nt>
964<nt def='NT-CData'>CData</nt>
965<nt def='NT-CDEnd'>CDEnd</nt></rhs></prod>
966<prod id='NT-CDStart'><lhs>CDStart</lhs>
967<rhs>'&lt;![CDATA['</rhs>
968</prod>
969<prod id='NT-CData'><lhs>CData</lhs>
970<rhs>(<nt def='NT-Char'>Char</nt>* -
971(<nt def='NT-Char'>Char</nt>* ']]&gt;' <nt def='NT-Char'>Char</nt>*))
972</rhs>
973</prod>
974<prod id='NT-CDEnd'><lhs>CDEnd</lhs>
975<rhs>']]&gt;'</rhs>
976</prod>
977</scrap>
978
979Within a CDATA section, only the <nt def='NT-CDEnd'>CDEnd</nt> string is
980recognized as markup, so that left angle brackets and ampersands may occur in
981their literal form; they need not (and cannot) be escaped using
982"<code>&amp;lt;</code>" and "<code>&amp;amp;</code>".  CDATA sections
983cannot nest.</termdef>
984</p>
985
986<p>An example of a CDATA section, in which "<code>&lt;greeting></code>" and
987"<code>&lt;/greeting></code>"
988are recognized as <termref def='dt-chardata'>character data</termref>, not
989<termref def='dt-markup'>markup</termref>:
990<eg>&lt;![CDATA[&lt;greeting>Hello, world!&lt;/greeting>]]&gt;</eg>
991</p>
992</div2>
993
994<div2 id='sec-prolog-dtd'>
995<head>Prolog and Document Type Declaration</head>
996
997<p><termdef id='dt-xmldecl' term='XML Declaration'>XML documents
998may, and should,
999begin with an <term>XML declaration</term> which specifies
1000the version of
1001XML being used.</termdef>
1002For example, the following is a complete XML document, <termref
1003def="dt-wellformed">well-formed</termref> but not
1004<termref def="dt-valid">valid</termref>:
1005<eg><![CDATA[<?xml version="1.0"?>
1006<greeting>Hello, world!</greeting>
1007]]></eg>
1008and so is this:
1009<eg><![CDATA[<greeting>Hello, world!</greeting>
1010]]></eg>
1011</p>
1012
1013<p>The version number "<code>1.0</code>" should be used to indicate
1014conformance to this version of this specification; it is an error
1015for a document to use the value "<code>1.0</code>"
1016if it does not conform to this version of this specification.
1017It is the intent
1018of the XML working group to give later versions of this specification
1019numbers other than "<code>1.0</code>", but this intent does not
1020indicate a
1021commitment to produce any future versions of XML, nor if any are produced, to
1022use any particular numbering scheme.
1023Since future versions are not ruled out, this construct is provided
1024as a means to allow the possibility of automatic version recognition, should
1025it become necessary.
1026Processors may signal an error if they receive documents labeled with
1027versions they do not support.
1028</p>
1029<p>The function of the markup in an XML document is to describe its
1030storage and logical structure and to associate attribute-value pairs
1031with its logical structures.  XML provides a mechanism, the <termref
1032def="dt-doctype">document type declaration</termref>, to define
1033constraints on the logical structure and to support the use of
1034predefined storage units.
1035
1036<termdef id="dt-valid" term="Validity">An XML document is
1037<term>valid</term> if it has an associated document type
1038declaration and if the document
1039complies with the constraints expressed in it.</termdef></p>
1040<p>The document type declaration must appear before
1041the first <termref def="dt-element">element</termref> in the document.
1042<scrap lang="ebnf" id='xmldoc'>
1043<head>Prolog</head>
1044<prodgroup pcw2="6" pcw4="17.5" pcw5="9">
1045<prod id='NT-prolog'><lhs>prolog</lhs>
1046<rhs><nt def='NT-XMLDecl'>XMLDecl</nt>?
1047<nt def='NT-Misc'>Misc</nt>*
1048(<nt def='NT-doctypedecl'>doctypedecl</nt>
1049<nt def='NT-Misc'>Misc</nt>*)?</rhs></prod>
1050<prod id='NT-XMLDecl'><lhs>XMLDecl</lhs>
1051<rhs>&xmlpio;
1052<nt def='NT-VersionInfo'>VersionInfo</nt>
1053<nt def='NT-EncodingDecl'>EncodingDecl</nt>?
1054<nt def='NT-SDDecl'>SDDecl</nt>?
1055<nt def="NT-S">S</nt>?
1056&pic;</rhs>
1057</prod>
1058<prod id='NT-VersionInfo'><lhs>VersionInfo</lhs>
1059<rhs><nt def="NT-S">S</nt> 'version' <nt def='NT-Eq'>Eq</nt>
1060(' <nt def="NT-VersionNum">VersionNum</nt> '
1061| " <nt def="NT-VersionNum">VersionNum</nt> ")</rhs>
1062</prod>
1063<prod id='NT-Eq'><lhs>Eq</lhs>
1064<rhs><nt def='NT-S'>S</nt>? '=' <nt def='NT-S'>S</nt>?</rhs></prod>
1065<prod id="NT-VersionNum">
1066<lhs>VersionNum</lhs>
1067<rhs>([a-zA-Z0-9_.:] | '-')+</rhs>
1068</prod>
1069<prod id='NT-Misc'><lhs>Misc</lhs>
1070<rhs><nt def='NT-Comment'>Comment</nt> | <nt def='NT-PI'>PI</nt> |
1071<nt def='NT-S'>S</nt></rhs></prod>
1072</prodgroup>
1073</scrap></p>
1074
1075<p><termdef id="dt-doctype" term="Document Type Declaration">The XML
1076<term>document type declaration</term>
1077contains or points to
1078<termref def='dt-markupdecl'>markup declarations</termref>
1079that provide a grammar for a
1080class of documents.
1081This grammar is known as a document type definition,
1082or <term>DTD</term>.
1083The document type declaration can point to an external subset (a
1084special kind of
1085<termref def='dt-extent'>external entity</termref>) containing markup
1086declarations, or can
1087contain the markup declarations directly in an internal subset, or can do
1088both.
1089The DTD for a document consists of both subsets taken
1090together.</termdef>
1091</p>
1092<p><termdef id="dt-markupdecl" term="markup declaration">
1093A <term>markup declaration</term> is
1094an <termref def="dt-eldecl">element type declaration</termref>,
1095an <termref def="dt-attdecl">attribute-list declaration</termref>,
1096an <termref def="dt-entdecl">entity declaration</termref>, or
1097a <termref def="dt-notdecl">notation declaration</termref>.
1098</termdef>
1099These declarations may be contained in whole or in part
1100within <termref def='dt-PE'>parameter entities</termref>,
1101as described in the well-formedness and validity constraints below.
1102For fuller information, see
1103<specref ref="sec-physical-struct"/>.</p>
1104<scrap lang="ebnf" id='dtd'>
1105<head>Document Type Definition</head>
1106<prodgroup pcw2="6" pcw4="17.5" pcw5="9">
1107<prod id='NT-doctypedecl'><lhs>doctypedecl</lhs>
1108<rhs>'&lt;!DOCTYPE' <nt def='NT-S'>S</nt>
1109<nt def='NT-Name'>Name</nt> (<nt def='NT-S'>S</nt>
1110<nt def='NT-ExternalID'>ExternalID</nt>)?
1111<nt def='NT-S'>S</nt>? ('['
1112(<nt def='NT-markupdecl'>markupdecl</nt>
1113| <nt def='NT-PEReference'>PEReference</nt>
1114| <nt def='NT-S'>S</nt>)*
1115']'
1116<nt def='NT-S'>S</nt>?)? '>'</rhs>
1117<vc def="vc-roottype"/>
1118</prod>
1119<prod id='NT-markupdecl'><lhs>markupdecl</lhs>
1120<rhs><nt def='NT-elementdecl'>elementdecl</nt>
1121| <nt def='NT-AttlistDecl'>AttlistDecl</nt>
1122| <nt def='NT-EntityDecl'>EntityDecl</nt>
1123| <nt def='NT-NotationDecl'>NotationDecl</nt>
1124| <nt def='NT-PI'>PI</nt>
1125| <nt def='NT-Comment'>Comment</nt>
1126</rhs>
1127<vc def='vc-PEinMarkupDecl'/>
1128<wfc def="wfc-PEinInternalSubset"/>
1129</prod>
1130
1131</prodgroup>
1132</scrap>
1133
1134<p>The markup declarations may be made up in whole or in part of
1135the <termref def='dt-repltext'>replacement text</termref> of
1136<termref def='dt-PE'>parameter entities</termref>.
1137The productions later in this specification for
1138individual nonterminals (<nt def='NT-elementdecl'>elementdecl</nt>,
1139<nt def='NT-AttlistDecl'>AttlistDecl</nt>, and so on) describe
1140the declarations <emph>after</emph> all the parameter entities have been
1141<termref def='dt-include'>included</termref>.</p>
1142
1143<vcnote id="vc-roottype">
1144<head>Root Element Type</head>
1145<p>
1146The <nt def='NT-Name'>Name</nt> in the document type declaration must
1147match the element type of the <termref def='dt-root'>root element</termref>.
1148</p>
1149</vcnote>
1150
1151<vcnote id='vc-PEinMarkupDecl'>
1152<head>Proper Declaration/PE Nesting</head>
1153<p>Parameter-entity
1154<termref def='dt-repltext'>replacement text</termref> must be properly nested
1155with markup declarations.
1156That is to say, if either the first character
1157or the last character of a markup
1158declaration (<nt def='NT-markupdecl'>markupdecl</nt> above)
1159is contained in the replacement text for a
1160<termref def='dt-PERef'>parameter-entity reference</termref>,
1161both must be contained in the same replacement text.</p>
1162</vcnote>
1163<wfcnote id="wfc-PEinInternalSubset">
1164<head>PEs in Internal Subset</head>
1165<p>In the internal DTD subset,
1166<termref def='dt-PERef'>parameter-entity references</termref>
1167can occur only where markup declarations can occur, not
1168within markup declarations.  (This does not apply to
1169references that occur in
1170external parameter entities or to the external subset.)
1171</p>
1172</wfcnote>
1173<p>
1174Like the internal subset, the external subset and
1175any external parameter entities referred to in the DTD
1176must consist of a series of complete markup declarations of the types
1177allowed by the non-terminal symbol
1178<nt def="NT-markupdecl">markupdecl</nt>, interspersed with white space
1179or <termref def="dt-PERef">parameter-entity references</termref>.
1180However, portions of the contents
1181of the
1182external subset or of external parameter entities may conditionally be ignored
1183by using
1184the <termref def="dt-cond-section">conditional section</termref>
1185construct; this is not allowed in the internal subset.
1186
1187<scrap id="ext-Subset">
1188<head>External Subset</head>
1189<prodgroup pcw2="6" pcw4="17.5" pcw5="9">
1190<prod id='NT-extSubset'><lhs>extSubset</lhs>
1191<rhs><nt def='NT-TextDecl'>TextDecl</nt>?
1192<nt def='NT-extSubsetDecl'>extSubsetDecl</nt></rhs></prod>
1193<prod id='NT-extSubsetDecl'><lhs>extSubsetDecl</lhs>
1194<rhs>(
1195<nt def='NT-markupdecl'>markupdecl</nt>
1196| <nt def='NT-conditionalSect'>conditionalSect</nt>
1197| <nt def='NT-PEReference'>PEReference</nt>
1198| <nt def='NT-S'>S</nt>
1199)*</rhs>
1200</prod>
1201</prodgroup>
1202</scrap></p>
1203<p>The external subset and external parameter entities also differ
1204from the internal subset in that in them,
1205<termref def="dt-PERef">parameter-entity references</termref>
1206are permitted <emph>within</emph> markup declarations,
1207not only <emph>between</emph> markup declarations.</p>
1208<p>An example of an XML document with a document type declaration:
1209<eg><![CDATA[<?xml version="1.0"?>
1210<!DOCTYPE greeting SYSTEM "hello.dtd">
1211<greeting>Hello, world!</greeting>
1212]]></eg>
1213The <termref def="dt-sysid">system identifier</termref>
1214"<code>hello.dtd</code>" gives the URI of a DTD for the document.</p>
1215<p>The declarations can also be given locally, as in this
1216example:
1217<eg><![CDATA[<?xml version="1.0" encoding="UTF-8" ?>
1218<!DOCTYPE greeting [
1219  <!ELEMENT greeting (#PCDATA)>
1220]>
1221<greeting>Hello, world!</greeting>
1222]]></eg>
1223If both the external and internal subsets are used, the
1224internal subset is considered to occur before the external subset.
1225<!-- 'is considered to'? boo. whazzat mean? -->
1226This has the effect that entity and attribute-list declarations in the
1227internal subset take precedence over those in the external subset.
1228</p>
1229</div2>
1230
1231<div2 id='sec-rmd'>
1232<head>Standalone Document Declaration</head>
1233<p>Markup declarations can affect the content of the document,
1234as passed from an <termref def="dt-xml-proc">XML processor</termref>
1235to an application; examples are attribute defaults and entity
1236declarations.
1237The standalone document declaration,
1238which may appear as a component of the XML declaration, signals
1239whether or not there are such declarations which appear external to
1240the <termref def='dt-docent'>document entity</termref>.
1241<scrap lang="ebnf" id='fulldtd'>
1242<head>Standalone Document Declaration</head>
1243<prodgroup pcw2="4" pcw4="19.5" pcw5="9">
1244<prod id='NT-SDDecl'><lhs>SDDecl</lhs>
1245<rhs>
1246<nt def="NT-S">S</nt>
1247'standalone' <nt def='NT-Eq'>Eq</nt>
1248(("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no') '"'))
1249</rhs>
1250<vc def='vc-check-rmd'/></prod>
1251</prodgroup>
1252</scrap></p>
1253<p>
1254In a standalone document declaration, the value "<code>yes</code>" indicates
1255that there
1256are no markup declarations external to the <termref def='dt-docent'>document
1257entity</termref> (either in the DTD external subset, or in an
1258external parameter entity referenced from the internal subset)
1259which affect the information passed from the XML processor to
1260the application.
1261The value "<code>no</code>" indicates that there are or may be such
1262external markup declarations.
1263Note that the standalone document declaration only
1264denotes the presence of external <emph>declarations</emph>; the presence, in a
1265document, of
1266references to external <emph>entities</emph>, when those entities are
1267internally declared,
1268does not change its standalone status.</p>
1269<p>If there are no external markup declarations, the standalone document
1270declaration has no meaning.
1271If there are external markup declarations but there is no standalone
1272document declaration, the value "<code>no</code>" is assumed.</p>
1273<p>Any XML document for which <code>standalone="no"</code> holds can
1274be converted algorithmically to a standalone document,
1275which may be desirable for some network delivery applications.</p>
1276<vcnote id='vc-check-rmd'>
1277<head>Standalone Document Declaration</head>
1278<p>The standalone document declaration must have
1279the value "<code>no</code>" if any external markup declarations
1280contain declarations of:</p><ulist>
1281<item><p>attributes with <termref def="dt-default">default</termref> values, if
1282elements to which
1283these attributes apply appear in the document without
1284specifications of values for these attributes, or</p></item>
1285<item><p>entities (other than &magicents;),
1286if <termref def="dt-entref">references</termref> to those
1287entities appear in the document, or</p>
1288</item>
1289<item><p>attributes with values subject to
1290<titleref href='AVNormalize'>normalization</titleref>, where the
1291attribute appears in the document with a value which will
1292change as a result of normalization, or</p>
1293</item>
1294<item>
1295<p>element types with <termref def="dt-elemcontent">element content</termref>,
1296if white space occurs
1297directly within any instance of those types.
1298</p></item>
1299</ulist>
1300
1301</vcnote>
1302<p>An example XML declaration with a standalone document declaration:<eg
1303>&lt;?xml version="&XML.version;" standalone='yes'?></eg></p>
1304</div2>
1305<div2 id='sec-white-space'>
1306<head>White Space Handling</head>
1307
1308<p>In editing XML documents, it is often convenient to use "white space"
1309(spaces, tabs, and blank lines, denoted by the nonterminal
1310<nt def='NT-S'>S</nt> in this specification) to
1311set apart the markup for greater readability.  Such white space is typically
1312not intended for inclusion in the delivered version of the document.
1313On the other hand, "significant" white space that should be preserved in the
1314delivered version is common, for example in poetry and
1315source code.</p>
1316<p>An <termref def='dt-xml-proc'>XML processor</termref>
1317must always pass all characters in a document that are not
1318markup through to the application.   A <termref def='dt-validating'>
1319validating XML processor</termref> must also inform the application
1320which  of these characters constitute white space appearing
1321in <termref def="dt-elemcontent">element content</termref>.
1322</p>
1323<p>A special <termref def='dt-attr'>attribute</termref>
1324named <kw>xml:space</kw> may be attached to an element
1325to signal an intention that in that element,
1326white space should be preserved by applications.
1327In valid documents, this attribute, like any other, must be
1328<termref def="dt-attdecl">declared</termref> if it is used.
1329When declared, it must be given as an
1330<termref def='dt-enumerated'>enumerated type</termref> whose only
1331possible values are "<code>default</code>" and "<code>preserve</code>".
1332For example:<eg><![CDATA[    <!ATTLIST poem   xml:space (default|preserve) 'preserve'>]]></eg></p>
1333<p>The value "<code>default</code>" signals that applications'
1334default white-space processing modes are acceptable for this element; the
1335value "<code>preserve</code>" indicates the intent that applications preserve
1336all the white space.
1337This declared intent is considered to apply to all elements within the content
1338of the element where it is specified, unless overriden with another instance
1339of the <kw>xml:space</kw> attribute.
1340</p>
1341<p>The <termref def='dt-root'>root element</termref> of any document
1342is considered to have signaled no intentions as regards application space
1343handling, unless it provides a value for
1344this attribute or the attribute is declared with a default value.
1345</p>
1346
1347</div2>
1348<div2 id='sec-line-ends'>
1349<head>End-of-Line Handling</head>
1350<p>XML <termref def='dt-parsedent'>parsed entities</termref> are often stored in
1351computer files which, for editing convenience, are organized into lines.
1352These lines are typically separated by some combination of the characters
1353carriage-return (#xD) and line-feed (#xA).</p>
1354<p>To simplify the tasks of <termref def='dt-app'>applications</termref>,
1355wherever an external parsed entity or the literal entity value
1356of an internal parsed entity contains either the literal
1357two-character sequence "#xD#xA" or a standalone literal
1358#xD, an <termref def='dt-xml-proc'>XML processor</termref> must
1359pass to the application the single character #xA.
1360(This behavior can
1361conveniently be produced by normalizing all
1362line breaks to #xA on input, before parsing.)
1363</p>
1364</div2>
1365<div2 id='sec-lang-tag'>
1366<head>Language Identification</head>
1367<p>In document processing, it is often useful to
1368identify the natural or formal language
1369in which the content is
1370written.
1371A special <termref def="dt-attr">attribute</termref> named
1372<kw>xml:lang</kw> may be inserted in
1373documents to specify the
1374language used in the contents and attribute values
1375of any element in an XML document.
1376In valid documents, this attribute, like any other, must be
1377<termref def="dt-attdecl">declared</termref> if it is used.
1378The values of the attribute are language identifiers as defined
1379by <bibref ref="RFC1766"/>, "Tags for the Identification of Languages":
1380<scrap lang='ebnf'>
1381<head>Language Identification</head>
1382<prod id='NT-LanguageID'><lhs>LanguageID</lhs>
1383<rhs><nt def='NT-Langcode'>Langcode</nt>
1384('-' <nt def='NT-Subcode'>Subcode</nt>)*</rhs></prod>
1385<prod id='NT-Langcode'><lhs>Langcode</lhs>
1386<rhs><nt def='NT-ISO639Code'>ISO639Code</nt> |
1387<nt def='NT-IanaCode'>IanaCode</nt> |
1388<nt def='NT-UserCode'>UserCode</nt></rhs>
1389</prod>
1390<prod id='NT-ISO639Code'><lhs>ISO639Code</lhs>
1391<rhs>([a-z] | [A-Z]) ([a-z] | [A-Z])</rhs></prod>
1392<prod id='NT-IanaCode'><lhs>IanaCode</lhs>
1393<rhs>('i' | 'I') '-' ([a-z] | [A-Z])+</rhs></prod>
1394<prod id='NT-UserCode'><lhs>UserCode</lhs>
1395<rhs>('x' | 'X') '-' ([a-z] | [A-Z])+</rhs></prod>
1396<prod id='NT-Subcode'><lhs>Subcode</lhs>
1397<rhs>([a-z] | [A-Z])+</rhs></prod>
1398</scrap>
1399The <nt def='NT-Langcode'>Langcode</nt> may be any of the following:
1400<ulist>
1401<item><p>a two-letter language code as defined by
1402<bibref ref="ISO639"/>, "Codes
1403for the representation of names of languages"</p></item>
1404<item><p>a language identifier registered with the Internet
1405Assigned Numbers Authority <bibref ref='IANA'/>; these begin with the
1406prefix "<code>i-</code>" (or "<code>I-</code>")</p></item>
1407<item><p>a language identifier assigned by the user, or agreed on
1408between parties in private use; these must begin with the
1409prefix "<code>x-</code>" or "<code>X-</code>" in order to ensure that they do not conflict
1410with names later standardized or registered with IANA</p></item>
1411</ulist></p>
1412<p>There may be any number of <nt def='NT-Subcode'>Subcode</nt> segments; if
1413the first
1414subcode segment exists and the Subcode consists of two
1415letters, then it must be a country code from
1416<bibref ref="ISO3166"/>, "Codes
1417for the representation of names of countries."
1418If the first
1419subcode consists of more than two letters, it must be
1420a subcode for the language in question registered with IANA,
1421unless the <nt def='NT-Langcode'>Langcode</nt> begins with the prefix
1422"<code>x-</code>" or
1423"<code>X-</code>". </p>
1424<p>It is customary to give the language code in lower case, and
1425the country code (if any) in upper case.
1426Note that these values, unlike other names in XML documents,
1427are case insensitive.</p>
1428<p>For example:
1429<eg><![CDATA[<p xml:lang="en">The quick brown fox jumps over the lazy dog.</p>
1430<p xml:lang="en-GB">What colour is it?</p>
1431<p xml:lang="en-US">What color is it?</p>
1432<sp who="Faust" desc='leise' xml:lang="de">
1433  <l>Habe nun, ach! Philosophie,</l>
1434  <l>Juristerei, und Medizin</l>
1435  <l>und leider auch Theologie</l>
1436  <l>durchaus studiert mit hei�em Bem�h'n.</l>
1437  </sp>]]></eg></p>
1438<!--<p>The xml:lang value is considered to apply both to the contents of an
1439element and
1440(unless otherwise via attribute default values) to the
1441values of all of its attributes with free-text (CDATA) values.  -->
1442<p>The intent declared with <kw>xml:lang</kw> is considered to apply to
1443all attributes and content of the element where it is specified,
1444unless overridden with an instance of <kw>xml:lang</kw>
1445on another element within that content.</p>
1446<!--
1447If no
1448value is specified for xml:lang on an element, and no default value is
1449defined for it in the DTD, then the xml:lang attribute of any element
1450takes the same value it has in the parent element, if any.  The two
1451technical terms in the following example both have the same effective
1452value for xml:lang:
1453
1454  <p xml:lang="en">Here the keywords are
1455  <term xml:lang="en">shift</term> and
1456  <term>reduce</term>. ...</p>
1457
1458The application, not the XML processor, is responsible for this '
1459inheritance' of attribute values.
1460-->
1461<p>A simple declaration for <kw>xml:lang</kw> might take
1462the form
1463<eg>xml:lang  NMTOKEN  #IMPLIED</eg>
1464but specific default values may also be given, if appropriate.  In a
1465collection of French poems for English students, with glosses and
1466notes in English, the xml:lang attribute might be declared this way:
1467<eg><![CDATA[    <!ATTLIST poem   xml:lang NMTOKEN 'fr'>
1468    <!ATTLIST gloss  xml:lang NMTOKEN 'en'>
1469    <!ATTLIST note   xml:lang NMTOKEN 'en'>]]></eg>
1470</p>
1471
1472</div2>
1473</div1>
1474<!-- &Elements; -->
1475
1476<div1 id='sec-logical-struct'>
1477<head>Logical Structures</head>
1478
1479<p><termdef id="dt-element" term="Element">Each <termref
1480def="dt-xml-doc">XML document</termref> contains one or more
1481<term>elements</term>, the boundaries of which are
1482either delimited by <termref def="dt-stag">start-tags</termref>
1483and <termref def="dt-etag">end-tags</termref>, or, for <termref
1484def="dt-empty">empty</termref> elements, by an <termref
1485def="dt-eetag">empty-element tag</termref>. Each element has a type,
1486identified by name, sometimes called its "generic
1487identifier" (GI), and may have a set of
1488attribute specifications.</termdef>  Each attribute specification
1489has a <termref
1490def="dt-attrname">name</termref> and a <termref
1491def="dt-attrval">value</termref>.
1492</p>
1493<scrap lang='ebnf'><head>Element</head>
1494<prod id='NT-element'><lhs>element</lhs>
1495<rhs><nt def='NT-EmptyElemTag'>EmptyElemTag</nt></rhs>
1496<rhs>| <nt def='NT-STag'>STag</nt> <nt def='NT-content'>content</nt>
1497<nt def='NT-ETag'>ETag</nt></rhs>
1498<wfc def='GIMatch'/>
1499<vc def='elementvalid'/>
1500</prod>
1501</scrap>
1502<p>This specification does not constrain the semantics, use, or (beyond
1503syntax) names of the element types and attributes, except that names
1504beginning with a match to <code>(('X'|'x')('M'|'m')('L'|'l'))</code>
1505are reserved for standardization in this or future versions of this
1506specification.
1507</p>
1508<wfcnote id='GIMatch'>
1509<head>Element Type Match</head>
1510<p>
1511The <nt def='NT-Name'>Name</nt> in an element's end-tag must match
1512the element type in
1513the start-tag.
1514</p>
1515</wfcnote>
1516<vcnote id='elementvalid'>
1517<head>Element Valid</head>
1518<p>An element is
1519valid if
1520there is a declaration matching
1521<nt def='NT-elementdecl'>elementdecl</nt> where the
1522<nt def='NT-Name'>Name</nt> matches the element type, and
1523one of the following holds:</p>
1524<olist>
1525<item><p>The declaration matches <kw>EMPTY</kw> and the element has no
1526<termref def='dt-content'>content</termref>.</p></item>
1527<item><p>The declaration matches <nt def='NT-children'>children</nt> and
1528the sequence of
1529<termref def="dt-parentchild">child elements</termref>
1530belongs to the language generated by the regular expression in
1531the content model, with optional white space (characters
1532matching the nonterminal <nt def='NT-S'>S</nt>) between each pair
1533of child elements.</p></item>
1534<item><p>The declaration matches <nt def='NT-Mixed'>Mixed</nt> and
1535the content consists of <termref def='dt-chardata'>character
1536data</termref> and <termref def='dt-parentchild'>child elements</termref>
1537whose types match names in the content model.</p></item>
1538<item><p>The declaration matches <kw>ANY</kw>, and the types
1539of any <termref def='dt-parentchild'>child elements</termref> have
1540been declared.</p></item>
1541</olist>
1542</vcnote>
1543
1544<div2 id='sec-starttags'>
1545<head>Start-Tags, End-Tags, and Empty-Element Tags</head>
1546
1547<p><termdef id="dt-stag" term="Start-Tag">The beginning of every
1548non-empty XML element is marked by a <term>start-tag</term>.
1549<scrap lang='ebnf'>
1550<head>Start-tag</head>
1551<prodgroup pcw2="6" pcw4="15" pcw5="11.5">
1552<prod id='NT-STag'><lhs>STag</lhs>
1553<rhs>'&lt;' <nt def='NT-Name'>Name</nt>
1554(<nt def='NT-S'>S</nt> <nt def='NT-Attribute'>Attribute</nt>)*
1555<nt def='NT-S'>S</nt>? '>'</rhs>
1556<wfc def="uniqattspec"/>
1557</prod>
1558<prod id='NT-Attribute'><lhs>Attribute</lhs>
1559<rhs><nt def='NT-Name'>Name</nt> <nt def='NT-Eq'>Eq</nt>
1560<nt def='NT-AttValue'>AttValue</nt></rhs>
1561<vc def='ValueType'/>
1562<wfc def='NoExternalRefs'/>
1563<wfc def='CleanAttrVals'/></prod>
1564</prodgroup>
1565</scrap>
1566The <nt def='NT-Name'>Name</nt> in
1567the start- and end-tags gives the
1568element's <term>type</term>.</termdef>
1569<termdef id="dt-attr" term="Attribute">
1570The <nt def='NT-Name'>Name</nt>-<nt def='NT-AttValue'>AttValue</nt> pairs are
1571referred to as
1572the <term>attribute specifications</term> of the element</termdef>,
1573<termdef id="dt-attrname" term="Attribute Name">with the
1574<nt def='NT-Name'>Name</nt> in each pair
1575referred to as the <term>attribute name</term></termdef> and
1576<termdef id="dt-attrval" term="Attribute Value">the content of the
1577<nt def='NT-AttValue'>AttValue</nt> (the text between the
1578<code>'</code> or <code>"</code> delimiters)
1579as the <term>attribute value</term>.</termdef>
1580</p>
1581<wfcnote id='uniqattspec'>
1582<head>Unique Att Spec</head>
1583<p>
1584No attribute name may appear more than once in the same start-tag
1585or empty-element tag.
1586</p>
1587</wfcnote>
1588<vcnote id='ValueType'>
1589<head>Attribute Value Type</head>
1590<p>
1591The attribute must have been declared; the value must be of the type
1592declared for it.
1593(For attribute types, see <specref ref='attdecls'/>.)
1594</p>
1595</vcnote>
1596<wfcnote id='NoExternalRefs'>
1597<head>No External Entity References</head>
1598<p>
1599Attribute values cannot contain direct or indirect entity references
1600to external entities.
1601</p>
1602</wfcnote>
1603<wfcnote id='CleanAttrVals'>
1604<head>No <code>&lt;</code> in Attribute Values</head>
1605<p>The <termref def='dt-repltext'>replacement text</termref> of any entity
1606referred to directly or indirectly in an attribute
1607value (other than "<code>&amp;lt;</code>") must not contain
1608a <code>&lt;</code>.
1609</p></wfcnote>
1610<p>An example of a start-tag:
1611<eg>&lt;termdef id="dt-dog" term="dog"></eg></p>
1612<p><termdef id="dt-etag" term="End Tag">The end of every element
1613that begins with a start-tag must
1614be marked by an <term>end-tag</term>
1615containing a name that echoes the element's type as given in the
1616start-tag:
1617<scrap lang='ebnf'>
1618<head>End-tag</head>
1619<prodgroup pcw2="6" pcw4="15" pcw5="11.5">
1620<prod id='NT-ETag'><lhs>ETag</lhs>
1621<rhs>'&lt;/' <nt def='NT-Name'>Name</nt>
1622<nt def='NT-S'>S</nt>? '>'</rhs></prod>
1623</prodgroup>
1624</scrap>
1625</termdef></p>
1626<p>An example of an end-tag:<eg>&lt;/termdef></eg></p>
1627<p><termdef id="dt-content" term="Content">The
1628<termref def='dt-text'>text</termref> between the start-tag and
1629end-tag is called the element's
1630<term>content</term>:
1631<scrap lang='ebnf'>
1632<head>Content of Elements</head>
1633<prodgroup pcw2="6" pcw4="15" pcw5="11.5">
1634<prod id='NT-content'><lhs>content</lhs>
1635<rhs>(<nt def='NT-element'>element</nt> | <nt def='NT-CharData'>CharData</nt>
1636| <nt def='NT-Reference'>Reference</nt> | <nt def='NT-CDSect'>CDSect</nt>
1637| <nt def='NT-PI'>PI</nt> | <nt def='NT-Comment'>Comment</nt>)*</rhs>
1638</prod>
1639</prodgroup>
1640</scrap>
1641</termdef></p>
1642<p><termdef id="dt-empty" term="Empty">If an element is <term>empty</term>,
1643it must be represented either by a start-tag immediately followed
1644by an end-tag or by an empty-element tag.</termdef>
1645<termdef id="dt-eetag" term="empty-element tag">An
1646<term>empty-element tag</term> takes a special form:
1647<scrap lang='ebnf'>
1648<head>Tags for Empty Elements</head>
1649<prodgroup pcw2="6" pcw4="15" pcw5="11.5">
1650<prod id='NT-EmptyElemTag'><lhs>EmptyElemTag</lhs>
1651<rhs>'&lt;' <nt def='NT-Name'>Name</nt> (<nt def='NT-S'>S</nt>
1652<nt def='NT-Attribute'>Attribute</nt>)* <nt def='NT-S'>S</nt>?
1653'/&gt;'</rhs>
1654<wfc def="uniqattspec"/>
1655</prod>
1656</prodgroup>
1657</scrap>
1658</termdef></p>
1659<p>Empty-element tags may be used for any element which has no
1660content, whether or not it is declared using the keyword
1661<kw>EMPTY</kw>.
1662<termref def='dt-interop'>For interoperability</termref>, the empty-element
1663tag must be used, and can only be used, for elements which are
1664<termref def='dt-eldecl'>declared</termref> <kw>EMPTY</kw>.</p>
1665<p>Examples of empty elements:
1666<eg>&lt;IMG align="left"
1667 src="http://www.w3.org/Icons/WWW/w3c_home" />
1668&lt;br>&lt;/br>
1669&lt;br/></eg></p>
1670</div2>
1671
1672<div2 id='elemdecls'>
1673<head>Element Type Declarations</head>
1674
1675<p>The <termref def="dt-element">element</termref> structure of an
1676<termref def="dt-xml-doc">XML document</termref> may, for
1677<termref def="dt-valid">validation</termref> purposes,
1678be constrained
1679using element type and attribute-list declarations.
1680An element type declaration constrains the element's
1681<termref def="dt-content">content</termref>.
1682</p>
1683
1684<p>Element type declarations often constrain which element types can
1685appear as <termref def="dt-parentchild">children</termref> of the element.
1686At user option, an XML processor may issue a warning
1687when a declaration mentions an element type for which no declaration
1688is provided, but this is not an error.</p>
1689<p><termdef id="dt-eldecl" term="Element Type declaration">An <term>element
1690type declaration</term> takes the form:
1691<scrap lang='ebnf'>
1692<head>Element Type Declaration</head>
1693<prodgroup pcw2="5.5" pcw4="18" pcw5="9">
1694<prod id='NT-elementdecl'><lhs>elementdecl</lhs>
1695<rhs>'&lt;!ELEMENT' <nt def='NT-S'>S</nt>
1696<nt def='NT-Name'>Name</nt>
1697<nt def='NT-S'>S</nt>
1698<nt def='NT-contentspec'>contentspec</nt>
1699<nt def='NT-S'>S</nt>? '>'</rhs>
1700<vc def='EDUnique'/></prod>
1701<prod id='NT-contentspec'><lhs>contentspec</lhs>
1702<rhs>'EMPTY'
1703| 'ANY'
1704| <nt def='NT-Mixed'>Mixed</nt>
1705| <nt def='NT-children'>children</nt>
1706</rhs>
1707</prod>
1708</prodgroup>
1709</scrap>
1710where the <nt def='NT-Name'>Name</nt> gives the element type
1711being declared.</termdef>
1712</p>
1713
1714<vcnote id='EDUnique'>
1715<head>Unique Element Type Declaration</head>
1716<p>
1717No element type may be declared more than once.
1718</p>
1719</vcnote>
1720
1721<p>Examples of element type declarations:
1722<eg>&lt;!ELEMENT br EMPTY>
1723&lt;!ELEMENT p (#PCDATA|emph)* >
1724&lt;!ELEMENT %name.para; %content.para; >
1725&lt;!ELEMENT container ANY></eg></p>
1726
1727<div3 id='sec-element-content'>
1728<head>Element Content</head>
1729
1730<p><termdef id='dt-elemcontent' term='Element content'>An element <termref
1731def="dt-stag">type</termref> has
1732<term>element content</term> when elements of that
1733type must contain only <termref def='dt-parentchild'>child</termref>
1734elements (no character data), optionally separated by
1735white space (characters matching the nonterminal
1736<nt def='NT-S'>S</nt>).
1737</termdef>
1738In this case, the
1739constraint includes a content model, a simple grammar governing
1740the allowed types of the child
1741elements and the order in which they are allowed to appear.
1742The grammar is built on
1743content particles (<nt def='NT-cp'>cp</nt>s), which consist of names,
1744choice lists of content particles, or
1745sequence lists of content particles:
1746<scrap lang='ebnf'>
1747<head>Element-content Models</head>
1748<prodgroup pcw2="5.5" pcw4="16" pcw5="11">
1749<prod id='NT-children'><lhs>children</lhs>
1750<rhs>(<nt def='NT-choice'>choice</nt>
1751| <nt def='NT-seq'>seq</nt>)
1752('?' | '*' | '+')?</rhs></prod>
1753<prod id='NT-cp'><lhs>cp</lhs>
1754<rhs>(<nt def='NT-Name'>Name</nt>
1755| <nt def='NT-choice'>choice</nt>
1756| <nt def='NT-seq'>seq</nt>)
1757('?' | '*' | '+')?</rhs></prod>
1758<prod id='NT-choice'><lhs>choice</lhs>
1759<rhs>'(' <nt def='NT-S'>S</nt>? cp
1760( <nt def='NT-S'>S</nt>? '|' <nt def='NT-S'>S</nt>? <nt def='NT-cp'>cp</nt> )*
1761<nt def='NT-S'>S</nt>? ')'</rhs>
1762<vc def='vc-PEinGroup'/></prod>
1763<prod id='NT-seq'><lhs>seq</lhs>
1764<rhs>'(' <nt def='NT-S'>S</nt>? cp
1765( <nt def='NT-S'>S</nt>? ',' <nt def='NT-S'>S</nt>? <nt def='NT-cp'>cp</nt> )*
1766<nt def='NT-S'>S</nt>? ')'</rhs>
1767<vc def='vc-PEinGroup'/></prod>
1768
1769</prodgroup>
1770</scrap>
1771where each <nt def='NT-Name'>Name</nt> is the type of an element which may
1772appear as a <termref def="dt-parentchild">child</termref>.
1773Any content
1774particle in a choice list may appear in the <termref
1775def="dt-elemcontent">element content</termref> at the location where
1776the choice list appears in the grammar;
1777content particles occurring in a sequence list must each
1778appear in the <termref def="dt-elemcontent">element content</termref> in the
1779order given in the list.
1780The optional character following a name or list governs
1781whether the element or the content particles in the list may occur one
1782or more (<code>+</code>), zero or more (<code>*</code>), or zero or
1783one times (<code>?</code>).
1784The absence of such an operator means that the element or content particle
1785must appear exactly once.
1786This syntax
1787and meaning are identical to those used in the productions in this
1788specification.</p>
1789<p>
1790The content of an element matches a content model if and only if it is
1791possible to trace out a path through the content model, obeying the
1792sequence, choice, and repetition operators and matching each element in
1793the content against an element type in the content model.  <termref
1794def='dt-compat'>For compatibility</termref>, it is an error
1795if an element in the document can
1796match more than one occurrence of an element type in the content model.
1797For more information, see <specref ref="determinism"/>.
1798<!-- appendix <specref ref="determinism"/>. -->
1799<!-- appendix on deterministic content models. -->
1800</p>
1801<vcnote id='vc-PEinGroup'>
1802<head>Proper Group/PE Nesting</head>
1803<p>Parameter-entity
1804<termref def='dt-repltext'>replacement text</termref> must be properly nested
1805with parenthetized groups.
1806That is to say, if either of the opening or closing parentheses
1807in a <nt def='NT-choice'>choice</nt>, <nt def='NT-seq'>seq</nt>, or
1808<nt def='NT-Mixed'>Mixed</nt> construct
1809is contained in the replacement text for a
1810<termref def='dt-PERef'>parameter entity</termref>,
1811both must be contained in the same replacement text.</p>
1812<p><termref def='dt-interop'>For interoperability</termref>,
1813if a parameter-entity reference appears in a
1814<nt def='NT-choice'>choice</nt>, <nt def='NT-seq'>seq</nt>, or
1815<nt def='NT-Mixed'>Mixed</nt> construct, its replacement text
1816should not be empty, and
1817neither the first nor last non-blank
1818character of the replacement text should be a connector
1819(<code>|</code> or <code>,</code>).
1820</p>
1821</vcnote>
1822<p>Examples of element-content models:
1823<eg>&lt;!ELEMENT spec (front, body, back?)>
1824&lt;!ELEMENT div1 (head, (p | list | note)*, div2*)>
1825&lt;!ELEMENT dictionary-body (%div.mix; | %dict.mix;)*></eg></p>
1826</div3>
1827
1828<div3 id='sec-mixed-content'>
1829<head>Mixed Content</head>
1830
1831<p><termdef id='dt-mixed' term='Mixed Content'>An element
1832<termref def='dt-stag'>type</termref> has
1833<term>mixed content</term> when elements of that type may contain
1834character data, optionally interspersed with
1835<termref def="dt-parentchild">child</termref> elements.</termdef>
1836In this case, the types of the child elements
1837may be constrained, but not their order or their number of occurrences:
1838<scrap lang='ebnf'>
1839<head>Mixed-content Declaration</head>
1840<prodgroup pcw2="5.5" pcw4="16" pcw5="11">
1841<prod id='NT-Mixed'><lhs>Mixed</lhs>
1842<rhs>'(' <nt def='NT-S'>S</nt>?
1843'#PCDATA'
1844(<nt def='NT-S'>S</nt>?
1845'|'
1846<nt def='NT-S'>S</nt>?
1847<nt def='NT-Name'>Name</nt>)*
1848<nt def='NT-S'>S</nt>?
1849')*' </rhs>
1850<rhs>| '(' <nt def='NT-S'>S</nt>? '#PCDATA' <nt def='NT-S'>S</nt>? ')'
1851</rhs><vc def='vc-PEinGroup'/>
1852<vc def='vc-MixedChildrenUnique'/>
1853</prod>
1854
1855</prodgroup>
1856</scrap>
1857where the <nt def='NT-Name'>Name</nt>s give the types of elements
1858that may appear as children.
1859</p>
1860<vcnote id='vc-MixedChildrenUnique'>
1861<head>No Duplicate Types</head>
1862<p>The same name must not appear more than once in a single mixed-content
1863declaration.
1864</p></vcnote>
1865<p>Examples of mixed content declarations:
1866<eg>&lt;!ELEMENT p (#PCDATA|a|ul|b|i|em)*>
1867&lt;!ELEMENT p (#PCDATA | %font; | %phrase; | %special; | %form;)* >
1868&lt;!ELEMENT b (#PCDATA)></eg></p>
1869</div3>
1870</div2>
1871
1872<div2 id='attdecls'>
1873<head>Attribute-List Declarations</head>
1874
1875<p><termref def="dt-attr">Attributes</termref> are used to associate
1876name-value pairs with <termref def="dt-element">elements</termref>.
1877Attribute specifications may appear only within <termref
1878def="dt-stag">start-tags</termref>
1879and <termref def="dt-eetag">empty-element tags</termref>;
1880thus, the productions used to
1881recognize them appear in <specref ref='sec-starttags'/>.
1882Attribute-list
1883declarations may be used:
1884<ulist>
1885<item><p>To define the set of attributes pertaining to a given
1886element type.</p></item>
1887<item><p>To establish type constraints for these
1888attributes.</p></item>
1889<item><p>To provide <termref def="dt-default">default values</termref>
1890for attributes.</p></item>
1891</ulist>
1892</p>
1893<p><termdef id="dt-attdecl" term="Attribute-List Declaration">
1894<term>Attribute-list declarations</term> specify the name, data type, and default
1895value (if any) of each attribute associated with a given element type:
1896<scrap lang='ebnf'>
1897<head>Attribute-list Declaration</head>
1898<prod id='NT-AttlistDecl'><lhs>AttlistDecl</lhs>
1899<rhs>'&lt;!ATTLIST' <nt def='NT-S'>S</nt>
1900<nt def='NT-Name'>Name</nt>
1901<nt def='NT-AttDef'>AttDef</nt>*
1902<nt def='NT-S'>S</nt>? '&gt;'</rhs>
1903</prod>
1904<prod id='NT-AttDef'><lhs>AttDef</lhs>
1905<rhs><nt def='NT-S'>S</nt> <nt def='NT-Name'>Name</nt>
1906<nt def='NT-S'>S</nt> <nt def='NT-AttType'>AttType</nt>
1907<nt def='NT-S'>S</nt> <nt def='NT-DefaultDecl'>DefaultDecl</nt></rhs>
1908</prod>
1909</scrap>
1910The <nt def="NT-Name">Name</nt> in the
1911<nt def='NT-AttlistDecl'>AttlistDecl</nt> rule is the type of an element.  At
1912user option, an XML processor may issue a warning if attributes are
1913declared for an element type not itself declared, but this is not an
1914error.  The <nt def='NT-Name'>Name</nt> in the
1915<nt def='NT-AttDef'>AttDef</nt> rule is
1916the name of the attribute.</termdef></p>
1917<p>
1918When more than one <nt def='NT-AttlistDecl'>AttlistDecl</nt> is provided for a
1919given element type, the contents of all those provided are merged.  When
1920more than one definition is provided for the same attribute of a
1921given element type, the first declaration is binding and later
1922declarations are ignored.
1923<termref def='dt-interop'>For interoperability,</termref> writers of DTDs
1924may choose to provide at most one attribute-list declaration
1925for a given element type, at most one attribute definition
1926for a given attribute name, and at least one attribute definition
1927in each attribute-list declaration.
1928For interoperability, an XML processor may at user option
1929issue a warning when more than one attribute-list declaration is
1930provided for a given element type, or more than one attribute definition
1931is provided
1932for a given attribute, but this is not an error.
1933</p>
1934
1935<div3 id='sec-attribute-types'>
1936<head>Attribute Types</head>
1937
1938<p>XML attribute types are of three kinds:  a string type, a
1939set of tokenized types, and enumerated types.  The string type may take
1940any literal string as a value; the tokenized types have varying lexical
1941and semantic constraints, as noted:
1942<scrap lang='ebnf'>
1943<head>Attribute Types</head>
1944<prodgroup pcw4="14" pcw5="11.5">
1945<prod id='NT-AttType'><lhs>AttType</lhs>
1946<rhs><nt def='NT-StringType'>StringType</nt>
1947| <nt def='NT-TokenizedType'>TokenizedType</nt>
1948| <nt def='NT-EnumeratedType'>EnumeratedType</nt>
1949</rhs>
1950</prod>
1951<prod id='NT-StringType'><lhs>StringType</lhs>
1952<rhs>'CDATA'</rhs>
1953</prod>
1954<prod id='NT-TokenizedType'><lhs>TokenizedType</lhs>
1955<rhs>'ID'</rhs>
1956<vc def='id'/>
1957<vc def='one-id-per-el'/>
1958<vc def='id-default'/>
1959<rhs>| 'IDREF'</rhs>
1960<vc def='idref'/>
1961<rhs>| 'IDREFS'</rhs>
1962<vc def='idref'/>
1963<rhs>| 'ENTITY'</rhs>
1964<vc def='entname'/>
1965<rhs>| 'ENTITIES'</rhs>
1966<vc def='entname'/>
1967<rhs>| 'NMTOKEN'</rhs>
1968<vc def='nmtok'/>
1969<rhs>| 'NMTOKENS'</rhs>
1970<vc def='nmtok'/></prod>
1971</prodgroup>
1972</scrap>
1973</p>
1974<vcnote id='id' >
1975<head>ID</head>
1976<p>
1977Values of type <kw>ID</kw> must match the
1978<nt def='NT-Name'>Name</nt> production.
1979A name must not appear more than once in
1980an XML document as a value of this type; i.e., ID values must uniquely
1981identify the elements which bear them.
1982</p>
1983</vcnote>
1984<vcnote id='one-id-per-el'>
1985<head>One ID per Element Type</head>
1986<p>No element type may have more than one ID attribute specified.</p>
1987</vcnote>
1988<vcnote id='id-default'>
1989<head>ID Attribute Default</head>
1990<p>An ID attribute must have a declared default of <kw>#IMPLIED</kw> or
1991<kw>#REQUIRED</kw>.</p>
1992</vcnote>
1993<vcnote id='idref'>
1994<head>IDREF</head>
1995<p>
1996Values of type <kw>IDREF</kw> must match
1997the <nt def="NT-Name">Name</nt> production, and
1998values of type <kw>IDREFS</kw> must match
1999<nt def="NT-Names">Names</nt>;
2000each <nt def='NT-Name'>Name</nt> must match the value of an ID attribute on
2001some element in the XML document; i.e. <kw>IDREF</kw> values must
2002match the value of some ID attribute.
2003</p>
2004</vcnote>
2005<vcnote id='entname'>
2006<head>Entity Name</head>
2007<p>
2008Values of type <kw>ENTITY</kw>
2009must match the <nt def="NT-Name">Name</nt> production,
2010values of type <kw>ENTITIES</kw> must match
2011<nt def="NT-Names">Names</nt>;
2012each <nt def="NT-Name">Name</nt> must
2013match the
2014name of an <termref def="dt-unparsed">unparsed entity</termref> declared in the
2015<termref def="dt-doctype">DTD</termref>.
2016</p>
2017</vcnote>
2018<vcnote id='nmtok'>
2019<head>Name Token</head>
2020<p>
2021Values of type <kw>NMTOKEN</kw> must match the
2022<nt def="NT-Nmtoken">Nmtoken</nt> production;
2023values of type <kw>NMTOKENS</kw> must
2024match <termref def="NT-Nmtokens">Nmtokens</termref>.
2025</p>
2026</vcnote>
2027<!-- why?
2028<p>The XML processor must normalize attribute values before
2029passing them to the application, as described in
2030<specref ref="AVNormalize"/>.</p>-->
2031<p><termdef id='dt-enumerated' term='Enumerated Attribute
2032Values'><term>Enumerated attributes</term> can take one
2033of a list of values provided in the declaration</termdef>. There are two
2034kinds of enumerated types:
2035<scrap lang='ebnf'>
2036<head>Enumerated Attribute Types</head>
2037<prod id='NT-EnumeratedType'><lhs>EnumeratedType</lhs>
2038<rhs><nt def='NT-NotationType'>NotationType</nt>
2039| <nt def='NT-Enumeration'>Enumeration</nt>
2040</rhs></prod>
2041<prod id='NT-NotationType'><lhs>NotationType</lhs>
2042<rhs>'NOTATION'
2043<nt def='NT-S'>S</nt>
2044'('
2045<nt def='NT-S'>S</nt>?
2046<nt def='NT-Name'>Name</nt>
2047(<nt def='NT-S'>S</nt>? '|' <nt def='NT-S'>S</nt>?
2048<nt def='NT-Name'>Name</nt>)*
2049<nt def='NT-S'>S</nt>? ')'
2050</rhs>
2051<vc def='notatn' /></prod>
2052<prod id='NT-Enumeration'><lhs>Enumeration</lhs>
2053<rhs>'(' <nt def='NT-S'>S</nt>?
2054<nt def='NT-Nmtoken'>Nmtoken</nt>
2055(<nt def='NT-S'>S</nt>? '|'
2056<nt def='NT-S'>S</nt>?
2057<nt def='NT-Nmtoken'>Nmtoken</nt>)*
2058<nt def='NT-S'>S</nt>?
2059')'</rhs>
2060<vc def='enum'/></prod>
2061</scrap>
2062A <kw>NOTATION</kw> attribute identifies a
2063<termref def='dt-notation'>notation</termref>, declared in the
2064DTD with associated system and/or public identifiers, to
2065be used in interpreting the element to which the attribute
2066is attached.
2067</p>
2068
2069<vcnote id='notatn'>
2070<head>Notation Attributes</head>
2071<p>
2072Values of this type must match
2073one of the <titleref href='Notations'>notation</titleref> names included in
2074the declaration; all notation names in the declaration must
2075be declared.
2076</p>
2077</vcnote>
2078<vcnote id='enum'>
2079<head>Enumeration</head>
2080<p>
2081Values of this type
2082must match one of the <nt def='NT-Nmtoken'>Nmtoken</nt> tokens in the
2083declaration.
2084</p>
2085</vcnote>
2086<p><termref def='dt-interop'>For interoperability,</termref> the same
2087<nt def='NT-Nmtoken'>Nmtoken</nt> should not occur more than once in the
2088enumerated attribute types of a single element type.
2089</p>
2090</div3>
2091
2092<div3 id='sec-attr-defaults'>
2093<head>Attribute Defaults</head>
2094
2095<p>An <termref def="dt-attdecl">attribute declaration</termref> provides
2096information on whether
2097the attribute's presence is required, and if not, how an XML processor should
2098react if a declared attribute is absent in a document.
2099<scrap lang='ebnf'>
2100<head>Attribute Defaults</head>
2101<prodgroup pcw4="14" pcw5="11.5">
2102<prod id='NT-DefaultDecl'><lhs>DefaultDecl</lhs>
2103<rhs>'#REQUIRED'
2104|&nbsp;'#IMPLIED' </rhs>
2105<rhs>| (('#FIXED' S)? <nt def='NT-AttValue'>AttValue</nt>)</rhs>
2106<vc def='RequiredAttr'/>
2107<vc def='defattrvalid'/>
2108<wfc def="CleanAttrVals"/>
2109<vc def='FixedAttr'/>
2110</prod>
2111</prodgroup>
2112</scrap>
2113
2114</p>
2115<p>In an attribute declaration, <kw>#REQUIRED</kw> means that the
2116attribute must always be provided, <kw>#IMPLIED</kw> that no default
2117value is provided.
2118<!-- not any more!!
2119<kw>#IMPLIED</kw> means that if the attribute is omitted
2120from an element of this type,
2121the XML processor must inform the application
2122that no value was specified; no constraint is placed on the behavior
2123of the application. -->
2124<termdef id="dt-default" term="Attribute Default">If the
2125declaration
2126is neither <kw>#REQUIRED</kw> nor <kw>#IMPLIED</kw>, then the
2127<nt def='NT-AttValue'>AttValue</nt> value contains the declared
2128<term>default</term> value; the <kw>#FIXED</kw> keyword states that
2129the attribute must always have the default value.
2130If a default value
2131is declared, when an XML processor encounters an omitted attribute, it
2132is to behave as though the attribute were present with
2133the declared default value.</termdef></p>
2134<vcnote id='RequiredAttr'>
2135<head>Required Attribute</head>
2136<p>If the default declaration is the keyword <kw>#REQUIRED</kw>, then
2137the attribute must be specified for
2138all elements of the type in the attribute-list declaration.
2139</p></vcnote>
2140<vcnote id='defattrvalid'>
2141<head>Attribute Default Legal</head>
2142<p>
2143The declared
2144default value must meet the lexical constraints of the declared attribute type.
2145</p>
2146</vcnote>
2147<vcnote id='FixedAttr'>
2148<head>Fixed Attribute Default</head>
2149<p>If an attribute has a default value declared with the
2150<kw>#FIXED</kw> keyword, instances of that attribute must
2151match the default value.
2152</p></vcnote>
2153
2154<p>Examples of attribute-list declarations:
2155<eg>&lt;!ATTLIST termdef
2156          id      ID      #REQUIRED
2157          name    CDATA   #IMPLIED>
2158&lt;!ATTLIST list
2159          type    (bullets|ordered|glossary)  "ordered">
2160&lt;!ATTLIST form
2161          method  CDATA   #FIXED "POST"></eg></p>
2162</div3>
2163<div3 id='AVNormalize'>
2164<head>Attribute-Value Normalization</head>
2165<p>Before the value of an attribute is passed to the application
2166or checked for validity, the
2167XML processor must normalize it as follows:
2168<ulist>
2169<item><p>a character reference is processed by appending the referenced
2170character to the attribute value</p></item>
2171<item><p>an entity reference is processed by recursively processing the
2172replacement text of the entity</p></item>
2173<item><p>a whitespace character (#x20, #xD, #xA, #x9) is processed by
2174appending #x20 to the normalized value, except that only a single #x20
2175is appended for a "#xD#xA" sequence that is part of an external
2176parsed entity or the literal entity value of an internal parsed
2177entity</p></item>
2178<item><p>other characters are processed by appending them to the normalized
2179value</p>
2180</item></ulist>
2181</p>
2182<p>If the declared value is not CDATA, then the XML processor must
2183further process the normalized attribute value by discarding any
2184leading and trailing space (#x20) characters, and by replacing
2185sequences of space (#x20) characters by a single space (#x20)
2186character.</p>
2187<p>
2188All attributes for which no declaration has been read should be treated
2189by a non-validating parser as if declared
2190<kw>CDATA</kw>.
2191</p>
2192</div3>
2193</div2>
2194<div2 id='sec-condition-sect'>
2195<head>Conditional Sections</head>
2196<p><termdef id='dt-cond-section' term='conditional section'>
2197<term>Conditional sections</term> are portions of the
2198<termref def='dt-doctype'>document type declaration external subset</termref>
2199which are
2200included in, or excluded from, the logical structure of the DTD based on
2201the keyword which governs them.</termdef>
2202<scrap lang='ebnf'>
2203<head>Conditional Section</head>
2204<prodgroup pcw2="9" pcw4="14.5">
2205<prod id='NT-conditionalSect'><lhs>conditionalSect</lhs>
2206<rhs><nt def='NT-includeSect'>includeSect</nt>
2207| <nt def='NT-ignoreSect'>ignoreSect</nt>
2208</rhs>
2209</prod>
2210<prod id='NT-includeSect'><lhs>includeSect</lhs>
2211<rhs>'&lt;![' S? 'INCLUDE' S? '['
2212
2213<nt def="NT-extSubsetDecl">extSubsetDecl</nt>
2214']]&gt;'
2215</rhs>
2216</prod>
2217<prod id='NT-ignoreSect'><lhs>ignoreSect</lhs>
2218<rhs>'&lt;![' S? 'IGNORE' S? '['
2219<nt def="NT-ignoreSectContents">ignoreSectContents</nt>*
2220']]&gt;'</rhs>
2221</prod>
2222
2223<prod id='NT-ignoreSectContents'><lhs>ignoreSectContents</lhs>
2224<rhs><nt def='NT-Ignore'>Ignore</nt>
2225('&lt;![' <nt def='NT-ignoreSectContents'>ignoreSectContents</nt> ']]&gt;'
2226<nt def='NT-Ignore'>Ignore</nt>)*</rhs></prod>
2227<prod id='NT-Ignore'><lhs>Ignore</lhs>
2228<rhs><nt def='NT-Char'>Char</nt>* -
2229(<nt def='NT-Char'>Char</nt>* ('&lt;![' | ']]&gt;')
2230<nt def='NT-Char'>Char</nt>*)
2231</rhs></prod>
2232
2233</prodgroup>
2234</scrap>
2235</p>
2236<p>Like the internal and external DTD subsets, a conditional section
2237may contain one or more complete declarations,
2238comments, processing instructions,
2239or nested conditional sections, intermingled with white space.
2240</p>
2241<p>If the keyword of the
2242conditional section is <kw>INCLUDE</kw>, then the contents of the conditional
2243section are part of the DTD.
2244If the keyword of the conditional
2245section is <kw>IGNORE</kw>, then the contents of the conditional section are
2246not logically part of the DTD.
2247Note that for reliable parsing, the contents of even ignored
2248conditional sections must be read in order to
2249detect nested conditional sections and ensure that the end of the
2250outermost (ignored) conditional section is properly detected.
2251If a conditional section with a
2252keyword of <kw>INCLUDE</kw> occurs within a larger conditional
2253section with a keyword of <kw>IGNORE</kw>, both the outer and the
2254inner conditional sections are ignored.</p>
2255<p>If the keyword of the conditional section is a
2256parameter-entity reference, the parameter entity must be replaced by its
2257content before the processor decides whether to
2258include or ignore the conditional section.</p>
2259<p>An example:
2260<eg>&lt;!ENTITY % draft 'INCLUDE' >
2261&lt;!ENTITY % final 'IGNORE' >
2262
2263&lt;![%draft;[
2264&lt;!ELEMENT book (comments*, title, body, supplements?)>
2265]]&gt;
2266&lt;![%final;[
2267&lt;!ELEMENT book (title, body, supplements?)>
2268]]&gt;
2269</eg>
2270</p>
2271</div2>
2272
2273
2274<!--
2275<div2 id='sec-pass-to-app'>
2276<head>XML Processor Treatment of Logical Structure</head>
2277<p>When an XML processor encounters a start-tag, it must make
2278at least the following information available to the application:
2279<ulist>
2280<item>
2281<p>the element type's generic identifier</p>
2282</item>
2283<item>
2284<p>the names of attributes known to apply to this element type
2285(validating processors must make available names of all attributes
2286declared for the element type; non-validating processors must
2287make available at least the names of the attributes for which
2288values are specified.
2289</p>
2290</item>
2291</ulist>
2292</p>
2293</div2>
2294-->
2295
2296</div1>
2297<!-- &Entities; -->
2298
2299<div1 id='sec-physical-struct'>
2300<head>Physical Structures</head>
2301
2302<p><termdef id="dt-entity" term="Entity">An XML document may consist
2303of one or many storage units.   These are called
2304<term>entities</term>; they all have <term>content</term> and are all
2305(except for the document entity, see below, and
2306the <termref def='dt-doctype'>external DTD subset</termref>)
2307identified by <term>name</term>.
2308</termdef>
2309Each XML document has one entity
2310called the <termref def="dt-docent">document entity</termref>, which serves
2311as the starting point for the <termref def="dt-xml-proc">XML
2312processor</termref> and may contain the whole document.</p>
2313<p>Entities may be either parsed or unparsed.
2314<termdef id="dt-parsedent" term="Text Entity">A <term>parsed entity's</term>
2315contents are referred to as its
2316<termref def='dt-repltext'>replacement text</termref>;
2317this <termref def="dt-text">text</termref> is considered an
2318integral part of the document.</termdef></p>
2319
2320<p><termdef id="dt-unparsed" term="Unparsed Entity">An
2321<term>unparsed entity</term>
2322is a resource whose contents may or may not be
2323<termref def='dt-text'>text</termref>, and if text, may not be XML.
2324Each unparsed entity
2325has an associated <termref
2326def="dt-notation">notation</termref>, identified by name.
2327Beyond a requirement
2328that an XML processor make the identifiers for the entity and
2329notation available to the application,
2330XML places no constraints on the contents of unparsed entities.</termdef>
2331</p>
2332<p>
2333Parsed entities are invoked by name using entity references;
2334unparsed entities by name, given in the value of <kw>ENTITY</kw>
2335or <kw>ENTITIES</kw>
2336attributes.</p>
2337<p><termdef id='gen-entity' term='general entity'
2338><term>General entities</term>
2339are entities for use within the document content.
2340In this specification, general entities are sometimes referred
2341to with the unqualified term <emph>entity</emph> when this leads
2342to no ambiguity.</termdef>
2343<termdef id='dt-PE' term='Parameter entity'>Parameter entities
2344are parsed entities for use within the DTD.</termdef>
2345These two types of entities use different forms of reference and
2346are recognized in different contexts.
2347Furthermore, they occupy different namespaces; a parameter entity and
2348a general entity with the same name are two distinct entities.
2349</p>
2350
2351<div2 id='sec-references'>
2352<head>Character and Entity References</head>
2353<p><termdef id="dt-charref" term="Character Reference">
2354A <term>character reference</term> refers to a specific character in the
2355ISO/IEC 10646 character set, for example one not directly accessible from
2356available input devices.
2357<scrap lang='ebnf'>
2358<head>Character Reference</head>
2359<prod id='NT-CharRef'><lhs>CharRef</lhs>
2360<rhs>'&amp;#' [0-9]+ ';' </rhs>
2361<rhs>| '&hcro;' [0-9a-fA-F]+ ';'</rhs>
2362<wfc def="wf-Legalchar"/>
2363</prod>
2364</scrap>
2365<wfcnote id="wf-Legalchar">
2366<head>Legal Character</head>
2367<p>Characters referred to using character references must
2368match the production for
2369<termref def="NT-Char">Char</termref>.</p>
2370</wfcnote>
2371If the character reference begins with "<code>&amp;#x</code>", the digits and
2372letters up to the terminating <code>;</code> provide a hexadecimal
2373representation of the character's code point in ISO/IEC 10646.
2374If it begins just with "<code>&amp;#</code>", the digits up to the terminating
2375<code>;</code> provide a decimal representation of the character's
2376code point.
2377</termdef>
2378</p>
2379<p><termdef id="dt-entref" term="Entity Reference">An <term>entity
2380reference</term> refers to the content of a named entity.</termdef>
2381<termdef id='dt-GERef' term='General Entity Reference'>References to
2382parsed general entities
2383use ampersand (<code>&amp;</code>) and semicolon (<code>;</code>) as
2384delimiters.</termdef>
2385<termdef id='dt-PERef' term='Parameter-entity reference'>
2386<term>Parameter-entity references</term> use percent-sign (<code>%</code>) and
2387semicolon
2388(<code>;</code>) as delimiters.</termdef>
2389</p>
2390<scrap lang="ebnf">
2391<head>Entity Reference</head>
2392<prod id='NT-Reference'><lhs>Reference</lhs>
2393<rhs><nt def='NT-EntityRef'>EntityRef</nt>
2394| <nt def='NT-CharRef'>CharRef</nt></rhs></prod>
2395<prod id='NT-EntityRef'><lhs>EntityRef</lhs>
2396<rhs>'&amp;' <nt def='NT-Name'>Name</nt> ';'</rhs>
2397<wfc def='wf-entdeclared'/>
2398<vc def='vc-entdeclared'/>
2399<wfc def='textent'/>
2400<wfc def='norecursion'/>
2401</prod>
2402<prod id='NT-PEReference'><lhs>PEReference</lhs>
2403<rhs>'%' <nt def='NT-Name'>Name</nt> ';'</rhs>
2404<vc def='vc-entdeclared'/>
2405<wfc def='norecursion'/>
2406<wfc def='indtd'/>
2407</prod>
2408</scrap>
2409
2410<wfcnote id='wf-entdeclared'>
2411<head>Entity Declared</head>
2412<p>In a document without any DTD, a document with only an internal
2413DTD subset which contains no parameter entity references, or a document with
2414"<code>standalone='yes'</code>",
2415the <nt def='NT-Name'>Name</nt> given in the entity reference must
2416<termref def="dt-match">match</termref> that in an
2417<titleref href='sec-entity-decl'>entity declaration</titleref>, except that
2418well-formed documents need not declare
2419any of the following entities: &magicents;.
2420The declaration of a parameter entity must precede any reference to it.
2421Similarly, the declaration of a general entity must precede any
2422reference to it which appears in a default value in an attribute-list
2423declaration.</p>
2424<p>Note that if entities are declared in the external subset or in
2425external parameter entities, a non-validating processor is
2426<titleref href='include-if-valid'>not obligated to</titleref> read
2427and process their declarations; for such documents, the rule that
2428an entity must be declared is a well-formedness constraint only
2429if <titleref href='sec-rmd'>standalone='yes'</titleref>.</p>
2430</wfcnote>
2431<vcnote id="vc-entdeclared">
2432<head>Entity Declared</head>
2433<p>In a document with an external subset or external parameter
2434entities with "<code>standalone='no'</code>",
2435the <nt def='NT-Name'>Name</nt> given in the entity reference must <termref
2436def="dt-match">match</termref> that in an
2437<titleref href='sec-entity-decl'>entity declaration</titleref>.
2438For interoperability, valid documents should declare the entities
2439&magicents;, in the form
2440specified in <specref ref="sec-predefined-ent"/>.
2441The declaration of a parameter entity must precede any reference to it.
2442Similarly, the declaration of a general entity must precede any
2443reference to it which appears in a default value in an attribute-list
2444declaration.</p>
2445</vcnote>
2446<!-- FINAL EDIT:  is this duplication too clumsy? -->
2447<wfcnote id='textent'>
2448<head>Parsed Entity</head>
2449<p>
2450An entity reference must not contain the name of an <termref
2451def="dt-unparsed">unparsed entity</termref>. Unparsed entities may be referred
2452to only in <termref def="dt-attrval">attribute values</termref> declared to
2453be of type <kw>ENTITY</kw> or <kw>ENTITIES</kw>.
2454</p>
2455</wfcnote>
2456<wfcnote id='norecursion'>
2457<head>No Recursion</head>
2458<p>
2459A parsed entity must not contain a recursive reference to itself,
2460either directly or indirectly.
2461</p>
2462</wfcnote>
2463<wfcnote id='indtd'>
2464<head>In DTD</head>
2465<p>
2466Parameter-entity references may only appear in the
2467<termref def='dt-doctype'>DTD</termref>.
2468</p>
2469</wfcnote>
2470<p>Examples of character and entity references:
2471<eg>Type &lt;key>less-than&lt;/key> (&hcro;3C;) to save options.
2472This document was prepared on &amp;docdate; and
2473is classified &amp;security-level;.</eg></p>
2474<p>Example of a parameter-entity reference:
2475<eg><![CDATA[<!-- declare the parameter entity "ISOLat2"... -->
2476<!ENTITY % ISOLat2
2477         SYSTEM "http://www.xml.com/iso/isolat2-xml.entities" >
2478<!-- ... now reference it. -->
2479%ISOLat2;]]></eg></p>
2480</div2>
2481
2482<div2 id='sec-entity-decl'>
2483<head>Entity Declarations</head>
2484
2485<p><termdef id="dt-entdecl" term="entity declaration">
2486Entities are declared thus:
2487<scrap lang='ebnf'>
2488<head>Entity Declaration</head>
2489<prodgroup pcw2="5" pcw4="18.5">
2490<prod id='NT-EntityDecl'><lhs>EntityDecl</lhs>
2491<rhs><nt def="NT-GEDecl">GEDecl</nt><!--</rhs><com>General entities</com>
2492<rhs>--> | <nt def="NT-PEDecl">PEDecl</nt></rhs>
2493<!--<com>Parameter entities</com>-->
2494</prod>
2495<prod id='NT-GEDecl'><lhs>GEDecl</lhs>
2496<rhs>'&lt;!ENTITY' <nt def='NT-S'>S</nt> <nt def='NT-Name'>Name</nt>
2497<nt def='NT-S'>S</nt> <nt def='NT-EntityDef'>EntityDef</nt>
2498<nt def='NT-S'>S</nt>? '&gt;'</rhs>
2499</prod>
2500<prod id='NT-PEDecl'><lhs>PEDecl</lhs>
2501<rhs>'&lt;!ENTITY' <nt def='NT-S'>S</nt> '%' <nt def='NT-S'>S</nt>
2502<nt def='NT-Name'>Name</nt> <nt def='NT-S'>S</nt>
2503<nt def='NT-PEDef'>PEDef</nt> <nt def='NT-S'>S</nt>? '&gt;'</rhs>
2504<!--<com>Parameter entities</com>-->
2505</prod>
2506<prod id='NT-EntityDef'><lhs>EntityDef</lhs>
2507<rhs><nt def='NT-EntityValue'>EntityValue</nt>
2508<!--</rhs>
2509<rhs>-->| (<nt def='NT-ExternalID'>ExternalID</nt>
2510<nt def='NT-NDataDecl'>NDataDecl</nt>?)</rhs>
2511<!-- <nt def='NT-ExternalDef'>ExternalDef</nt></rhs> -->
2512</prod>
2513<!-- FINAL EDIT: what happened to WFs here? -->
2514<prod id='NT-PEDef'><lhs>PEDef</lhs>
2515<rhs><nt def='NT-EntityValue'>EntityValue</nt>
2516| <nt def='NT-ExternalID'>ExternalID</nt></rhs></prod>
2517</prodgroup>
2518</scrap>
2519The <nt def='NT-Name'>Name</nt> identifies the entity in an
2520<termref def="dt-entref">entity reference</termref> or, in the case of an
2521unparsed entity, in the value of an <kw>ENTITY</kw> or <kw>ENTITIES</kw>
2522attribute.
2523If the same entity is declared more than once, the first declaration
2524encountered is binding; at user option, an XML processor may issue a
2525warning if entities are declared multiple times.</termdef>
2526</p>
2527
2528<div3 id='sec-internal-ent'>
2529<head>Internal Entities</head>
2530
2531<p><termdef id='dt-internent' term="Internal Entity Replacement Text">If
2532the entity definition is an
2533<nt def='NT-EntityValue'>EntityValue</nt>,
2534the defined entity is called an <term>internal entity</term>.
2535There is no separate physical
2536storage object, and the content of the entity is given in the
2537declaration. </termdef>
2538Note that some processing of entity and character references in the
2539<termref def='dt-litentval'>literal entity value</termref> may be required to
2540produce the correct <termref def='dt-repltext'>replacement
2541text</termref>: see <specref ref='intern-replacement'/>.
2542</p>
2543<p>An internal entity is a <termref def="dt-parsedent">parsed
2544entity</termref>.</p>
2545<p>Example of an internal entity declaration:
2546<eg>&lt;!ENTITY Pub-Status "This is a pre-release of the
2547 specification."></eg></p>
2548</div3>
2549
2550<div3 id='sec-external-ent'>
2551<head>External Entities</head>
2552
2553<p><termdef id="dt-extent" term="External Entity">If the entity is not
2554internal, it is an <term>external
2555entity</term>, declared as follows:
2556<scrap lang='ebnf'>
2557<head>External Entity Declaration</head>
2558<!--
2559<prod id='NT-ExternalDef'><lhs>ExternalDef</lhs>
2560<rhs></prod> -->
2561<prod id='NT-ExternalID'><lhs>ExternalID</lhs>
2562<rhs>'SYSTEM' <nt def='NT-S'>S</nt>
2563<nt def='NT-SystemLiteral'>SystemLiteral</nt></rhs>
2564<rhs>| 'PUBLIC' <nt def='NT-S'>S</nt>
2565<nt def='NT-PubidLiteral'>PubidLiteral</nt>
2566<nt def='NT-S'>S</nt>
2567<nt def='NT-SystemLiteral'>SystemLiteral</nt>
2568</rhs>
2569</prod>
2570<prod id='NT-NDataDecl'><lhs>NDataDecl</lhs>
2571<rhs><nt def='NT-S'>S</nt> 'NDATA' <nt def='NT-S'>S</nt>
2572<nt def='NT-Name'>Name</nt></rhs>
2573<vc def='not-declared'/></prod>
2574</scrap>
2575If the <nt def='NT-NDataDecl'>NDataDecl</nt> is present, this is a
2576general <termref def="dt-unparsed">unparsed
2577entity</termref>; otherwise it is a parsed entity.</termdef></p>
2578<vcnote id='not-declared'>
2579<head>Notation Declared</head>
2580<p>
2581The <nt def='NT-Name'>Name</nt> must match the declared name of a
2582<termref def="dt-notation">notation</termref>.
2583</p>
2584</vcnote>
2585<p><termdef id="dt-sysid" term="System Identifier">The
2586<nt def='NT-SystemLiteral'>SystemLiteral</nt>
2587is called the entity's <term>system identifier</term>. It is a URI,
2588which may be used to retrieve the entity.</termdef>
2589Note that the hash mark (<code>#</code>) and fragment identifier
2590frequently used with URIs are not, formally, part of the URI itself;
2591an XML processor may signal an error if a fragment identifier is
2592given as part of a system identifier.
2593Unless otherwise provided by information outside the scope of this
2594specification (e.g. a special XML element type defined by a particular
2595DTD, or a processing instruction defined by a particular application
2596specification), relative URIs are relative to the location of the
2597resource within which the entity declaration occurs.
2598A URI might thus be relative to the
2599<termref def='dt-docent'>document entity</termref>, to the entity
2600containing the <termref def='dt-doctype'>external DTD subset</termref>,
2601or to some other <termref def='dt-extent'>external parameter entity</termref>.
2602</p>
2603<p>An XML processor should handle a non-ASCII character in a URI by
2604representing the character in UTF-8 as one or more bytes, and then
2605escaping these bytes with the URI escaping mechanism (i.e., by
2606converting each byte to %HH, where HH is the hexadecimal notation of the
2607byte value).</p>
2608<p><termdef id="dt-pubid" term="Public identifier">
2609In addition to a system identifier, an external identifier may
2610include a <term>public identifier</term>.</termdef>
2611An XML processor attempting to retrieve the entity's content may use the public
2612identifier to try to generate an alternative URI.  If the processor
2613is unable to do so, it must use the URI specified in the system
2614literal.  Before a match is attempted, all strings
2615of white space in the public identifier must be normalized to single space characters (#x20),
2616and leading and trailing white space must be removed.</p>
2617<p>Examples of external entity declarations:
2618<eg>&lt;!ENTITY open-hatch
2619         SYSTEM "http://www.textuality.com/boilerplate/OpenHatch.xml">
2620&lt;!ENTITY open-hatch
2621         PUBLIC "-//Textuality//TEXT Standard open-hatch boilerplate//EN"
2622         "http://www.textuality.com/boilerplate/OpenHatch.xml">
2623&lt;!ENTITY hatch-pic
2624         SYSTEM "../grafix/OpenHatch.gif"
2625         NDATA gif ></eg></p>
2626</div3>
2627
2628</div2>
2629
2630<div2 id='TextEntities'>
2631<head>Parsed Entities</head>
2632<div3 id='sec-TextDecl'>
2633<head>The Text Declaration</head>
2634<p>External parsed entities may each begin with a <term>text
2635declaration</term>.
2636<scrap lang='ebnf'>
2637<head>Text Declaration</head>
2638<prodgroup pcw4="12.5" pcw5="13">
2639<prod id='NT-TextDecl'><lhs>TextDecl</lhs>
2640<rhs>&xmlpio;
2641<nt def='NT-VersionInfo'>VersionInfo</nt>?
2642<nt def='NT-EncodingDecl'>EncodingDecl</nt>
2643<nt def='NT-S'>S</nt>? &pic;</rhs>
2644</prod>
2645</prodgroup>
2646</scrap>
2647</p>
2648<p>The text declaration must be provided literally, not
2649by reference to a parsed entity.
2650No text declaration may appear at any position other than the beginning of
2651an external parsed entity.</p>
2652</div3>
2653<div3 id='wf-entities'>
2654<head>Well-Formed Parsed Entities</head>
2655<p>The document entity is well-formed if it matches the production labeled
2656<nt def='NT-document'>document</nt>.
2657An external general
2658parsed entity is well-formed if it matches the production labeled
2659<nt def='NT-extParsedEnt'>extParsedEnt</nt>.
2660An external parameter
2661entity is well-formed if it matches the production labeled
2662<nt def='NT-extPE'>extPE</nt>.
2663<scrap lang='ebnf'>
2664<head>Well-Formed External Parsed Entity</head>
2665<prod id='NT-extParsedEnt'><lhs>extParsedEnt</lhs>
2666<rhs><nt def='NT-TextDecl'>TextDecl</nt>?
2667<nt def='NT-content'>content</nt></rhs>
2668</prod>
2669<prod id='NT-extPE'><lhs>extPE</lhs>
2670<rhs><nt def='NT-TextDecl'>TextDecl</nt>?
2671<nt def='NT-extSubsetDecl'>extSubsetDecl</nt></rhs>
2672</prod>
2673</scrap>
2674An internal general parsed entity is well-formed if its replacement text
2675matches the production labeled
2676<nt def='NT-content'>content</nt>.
2677All internal parameter entities are well-formed by definition.
2678</p>
2679<p>A consequence of well-formedness in entities is that the logical
2680and physical structures in an XML document are properly nested; no
2681<termref def='dt-stag'>start-tag</termref>,
2682<termref def='dt-etag'>end-tag</termref>,
2683<termref def="dt-empty">empty-element tag</termref>,
2684<termref def='dt-element'>element</termref>,
2685<termref def='dt-comment'>comment</termref>,
2686<termref def='dt-pi'>processing instruction</termref>,
2687<termref def='dt-charref'>character
2688reference</termref>, or
2689<termref def='dt-entref'>entity reference</termref>
2690can begin in one entity and end in another.</p>
2691</div3>
2692<div3 id='charencoding'>
2693<head>Character Encoding in Entities</head>
2694
2695<p>Each external parsed entity in an XML document may use a different
2696encoding for its characters. All XML processors must be able to read
2697entities in either UTF-8 or UTF-16.
2698
2699</p>
2700<p>Entities encoded in UTF-16 must
2701begin with the Byte Order Mark described by ISO/IEC 10646 Annex E and
2702Unicode Appendix B (the ZERO WIDTH NO-BREAK SPACE character, #xFEFF).
2703This is an encoding signature, not part of either the markup or the
2704character data of the XML document.
2705XML processors must be able to use this character to
2706differentiate between UTF-8 and UTF-16 encoded documents.</p>
2707<p>Although an XML processor is required to read only entities in
2708the UTF-8 and UTF-16 encodings, it is recognized that other encodings are
2709used around the world, and it may be desired for XML processors
2710to read entities that use them.
2711Parsed entities which are stored in an encoding other than
2712UTF-8 or UTF-16 must begin with a <titleref href='TextDecl'>text
2713declaration</titleref> containing an encoding declaration:
2714<scrap lang='ebnf'>
2715<head>Encoding Declaration</head>
2716<prod id='NT-EncodingDecl'><lhs>EncodingDecl</lhs>
2717<rhs><nt def="NT-S">S</nt>
2718'encoding' <nt def='NT-Eq'>Eq</nt>
2719('"' <nt def='NT-EncName'>EncName</nt> '"' |
2720"'" <nt def='NT-EncName'>EncName</nt> "'" )
2721</rhs>
2722</prod>
2723<prod id='NT-EncName'><lhs>EncName</lhs>
2724<rhs>[A-Za-z] ([A-Za-z0-9._] | '-')*</rhs>
2725<com>Encoding name contains only Latin characters</com>
2726</prod>
2727</scrap>
2728In the <termref def='dt-docent'>document entity</termref>, the encoding
2729declaration is part of the <termref def="dt-xmldecl">XML declaration</termref>.
2730The <nt def="NT-EncName">EncName</nt> is the name of the encoding used.
2731</p>
2732<!-- FINAL EDIT:  check name of IANA and charset names -->
2733<p>In an encoding declaration, the values
2734"<code>UTF-8</code>",
2735"<code>UTF-16</code>",
2736"<code>ISO-10646-UCS-2</code>", and
2737"<code>ISO-10646-UCS-4</code>" should be
2738used for the various encodings and transformations of Unicode /
2739ISO/IEC 10646, the values
2740"<code>ISO-8859-1</code>",
2741"<code>ISO-8859-2</code>", ...
2742"<code>ISO-8859-9</code>" should be used for the parts of ISO 8859, and
2743the values
2744"<code>ISO-2022-JP</code>",
2745"<code>Shift_JIS</code>", and
2746"<code>EUC-JP</code>"
2747should be used for the various encoded forms of JIS X-0208-1997.  XML
2748processors may recognize other encodings; it is recommended that
2749character encodings registered (as <emph>charset</emph>s)
2750with the Internet Assigned Numbers
2751Authority <bibref ref='IANA'/>, other than those just listed, should be
2752referred to
2753using their registered names.
2754Note that these registered names are defined to be
2755case-insensitive, so processors wishing to match against them
2756should do so in a case-insensitive
2757way.</p>
2758<p>In the absence of information provided by an external
2759transport protocol (e.g. HTTP or MIME),
2760it is an <termref def="dt-error">error</termref> for an entity including
2761an encoding declaration to be presented to the XML processor
2762in an encoding other than that named in the declaration,
2763for an encoding declaration to occur other than at the beginning
2764of an external entity, or for
2765an entity which begins with neither a Byte Order Mark nor an encoding
2766declaration to use an encoding other than UTF-8.
2767Note that since ASCII
2768is a subset of UTF-8, ordinary ASCII entities do not strictly need
2769an encoding declaration.</p>
2770
2771<p>It is a <termref def='dt-fatal'>fatal error</termref> when an XML processor
2772encounters an entity with an encoding that it is unable to process.</p>
2773<p>Examples of encoding declarations:
2774<eg>&lt;?xml encoding='UTF-8'?>
2775&lt;?xml encoding='EUC-JP'?></eg></p>
2776</div3>
2777</div2>
2778<div2 id='entproc'>
2779<head>XML Processor Treatment of Entities and References</head>
2780<p>The table below summarizes the contexts in which character references,
2781entity references, and invocations of unparsed entities might appear and the
2782required behavior of an <termref def='dt-xml-proc'>XML processor</termref> in
2783each case.
2784The labels in the leftmost column describe the recognition context:
2785<glist>
2786<gitem><label>Reference in Content</label>
2787<def><p>as a reference
2788anywhere after the <termref def='dt-stag'>start-tag</termref> and
2789before the <termref def='dt-etag'>end-tag</termref> of an element; corresponds
2790to the nonterminal <nt def='NT-content'>content</nt>.</p></def>
2791</gitem>
2792<gitem>
2793<label>Reference in Attribute Value</label>
2794<def><p>as a reference within either the value of an attribute in a
2795<termref def='dt-stag'>start-tag</termref>, or a default
2796value in an <termref def='dt-attdecl'>attribute declaration</termref>;
2797corresponds to the nonterminal
2798<nt def='NT-AttValue'>AttValue</nt>.</p></def></gitem>
2799<gitem>
2800<label>Occurs as Attribute Value</label>
2801<def><p>as a <nt def='NT-Name'>Name</nt>, not a reference, appearing either as
2802the value of an
2803attribute which has been declared as type <kw>ENTITY</kw>, or as one of
2804the space-separated tokens in the value of an attribute which has been
2805declared as type <kw>ENTITIES</kw>.</p>
2806</def></gitem>
2807<gitem><label>Reference in Entity Value</label>
2808<def><p>as a reference
2809within a parameter or internal entity's
2810<termref def='dt-litentval'>literal entity value</termref> in
2811the entity's declaration; corresponds to the nonterminal
2812<nt def='NT-EntityValue'>EntityValue</nt>.</p></def></gitem>
2813<gitem><label>Reference in DTD</label>
2814<def><p>as a reference within either the internal or external subsets of the
2815<termref def='dt-doctype'>DTD</termref>, but outside
2816of an <nt def='NT-EntityValue'>EntityValue</nt> or
2817<nt def="NT-AttValue">AttValue</nt>.</p></def>
2818</gitem>
2819</glist></p>
2820<htable border='1' cellpadding='7' align='center'>
2821<htbody>
2822<tr><td bgcolor='&cellback;' rowspan='2' colspan='1'></td>
2823<td bgcolor='&cellback;' align='center' valign='bottom' colspan='4'>Entity Type</td>
2824<td bgcolor='&cellback;' rowspan='2' align='center'>Character</td>
2825</tr>
2826<tr align='center' valign='bottom'>
2827<td bgcolor='&cellback;'>Parameter</td>
2828<td bgcolor='&cellback;'>Internal
2829General</td>
2830<td bgcolor='&cellback;'>External Parsed
2831General</td>
2832<td bgcolor='&cellback;'>Unparsed</td>
2833</tr>
2834<tr align='center' valign='middle'>
2835
2836<td bgcolor='&cellback;' align='right'>Reference
2837in Content</td>
2838<td bgcolor='&cellback;'><titleref href='not-recognized'>Not recognized</titleref></td>
2839<td bgcolor='&cellback;'><titleref href='included'>Included</titleref></td>
2840<td bgcolor='&cellback;'><titleref href='include-if-valid'>Included if validating</titleref></td>
2841<td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
2842<td bgcolor='&cellback;'><titleref href='included'>Included</titleref></td>
2843</tr>
2844<tr align='center' valign='middle'>
2845<td bgcolor='&cellback;' align='right'>Reference
2846in Attribute Value</td>
2847<td bgcolor='&cellback;'><titleref href='not-recognized'>Not recognized</titleref></td>
2848<td bgcolor='&cellback;'><titleref href='inliteral'>Included in literal</titleref></td>
2849<td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
2850<td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
2851<td bgcolor='&cellback;'><titleref href='included'>Included</titleref></td>
2852</tr>
2853<tr align='center' valign='middle'>
2854<td bgcolor='&cellback;' align='right'>Occurs as
2855Attribute Value</td>
2856<td bgcolor='&cellback;'><titleref href='not-recognized'>Not recognized</titleref></td>
2857<td bgcolor='&cellback;'><titleref href='not-recognized'>Forbidden</titleref></td>
2858<td bgcolor='&cellback;'><titleref href='not-recognized'>Forbidden</titleref></td>
2859<td bgcolor='&cellback;'><titleref href='notify'>Notify</titleref></td>
2860<td bgcolor='&cellback;'><titleref href='not recognized'>Not recognized</titleref></td>
2861</tr>
2862<tr align='center' valign='middle'>
2863<td bgcolor='&cellback;' align='right'>Reference
2864in EntityValue</td>
2865<td bgcolor='&cellback;'><titleref href='inliteral'>Included in literal</titleref></td>
2866<td bgcolor='&cellback;'><titleref href='bypass'>Bypassed</titleref></td>
2867<td bgcolor='&cellback;'><titleref href='bypass'>Bypassed</titleref></td>
2868<td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
2869<td bgcolor='&cellback;'><titleref href='included'>Included</titleref></td>
2870</tr>
2871<tr align='center' valign='middle'>
2872<td bgcolor='&cellback;' align='right'>Reference
2873in DTD</td>
2874<td bgcolor='&cellback;'><titleref href='as-PE'>Included as PE</titleref></td>
2875<td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
2876<td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
2877<td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
2878<td bgcolor='&cellback;'><titleref href='forbidden'>Forbidden</titleref></td>
2879</tr>
2880</htbody>
2881</htable>
2882<div3 id='not-recognized'>
2883<head>Not Recognized</head>
2884<p>Outside the DTD, the <code>%</code> character has no
2885special significance; thus, what would be parameter entity references in the
2886DTD are not recognized as markup in <nt def='NT-content'>content</nt>.
2887Similarly, the names of unparsed entities are not recognized except
2888when they appear in the value of an appropriately declared attribute.
2889</p>
2890</div3>
2891<div3 id='included'>
2892<head>Included</head>
2893<p><termdef id="dt-include" term="Include">An entity is
2894<term>included</term> when its
2895<termref def='dt-repltext'>replacement text</termref> is retrieved
2896and processed, in place of the reference itself,
2897as though it were part of the document at the location the
2898reference was recognized.
2899The replacement text may contain both
2900<termref def='dt-chardata'>character data</termref>
2901and (except for parameter entities) <termref def="dt-markup">markup</termref>,
2902which must be recognized in
2903the usual way, except that the replacement text of entities used to escape
2904markup delimiters (the entities &magicents;) is always treated as
2905data.  (The string "<code>AT&amp;amp;T;</code>" expands to
2906"<code>AT&amp;T;</code>" and the remaining ampersand is not recognized
2907as an entity-reference delimiter.)
2908A character reference is <term>included</term> when the indicated
2909character is processed in place of the reference itself.
2910</termdef></p>
2911</div3>
2912<div3 id='include-if-valid'>
2913<head>Included If Validating</head>
2914<p>When an XML processor recognizes a reference to a parsed entity, in order
2915to <termref def="dt-valid">validate</termref>
2916the document, the processor must
2917<termref def="dt-include">include</termref> its
2918replacement text.
2919If the entity is external, and the processor is not
2920attempting to validate the XML document, the
2921processor <termref def="dt-may">may</termref>, but need not,
2922include the entity's replacement text.
2923If a non-validating parser does not include the replacement text,
2924it must inform the application that it recognized, but did not
2925read, the entity.</p>
2926<p>This rule is based on the recognition that the automatic inclusion
2927provided by the SGML and XML entity mechanism, primarily designed
2928to support modularity in authoring, is not necessarily
2929appropriate for other applications, in particular document browsing.
2930Browsers, for example, when encountering an external parsed entity reference,
2931might choose to provide a visual indication of the entity's
2932presence and retrieve it for display only on demand.
2933</p>
2934</div3>
2935<div3 id='forbidden'>
2936<head>Forbidden</head>
2937<p>The following are forbidden, and constitute
2938<termref def='dt-fatal'>fatal</termref> errors:
2939<ulist>
2940<item><p>the appearance of a reference to an
2941<termref def='dt-unparsed'>unparsed entity</termref>.
2942</p></item>
2943<item><p>the appearance of any character or general-entity reference in the
2944DTD except within an <nt def='NT-EntityValue'>EntityValue</nt> or
2945<nt def="NT-AttValue">AttValue</nt>.</p></item>
2946<item><p>a reference to an external entity in an attribute value.</p>
2947</item>
2948</ulist>
2949</p>
2950</div3>
2951<div3 id='inliteral'>
2952<head>Included in Literal</head>
2953<p>When an <termref def='dt-entref'>entity reference</termref> appears in an
2954attribute value, or a parameter entity reference appears in a literal entity
2955value, its <termref def='dt-repltext'>replacement text</termref> is
2956processed in place of the reference itself as though it
2957were part of the document at the location the reference was recognized,
2958except that a single or double quote character in the replacement text
2959is always treated as a normal data character and will not terminate the
2960literal.
2961For example, this is well-formed:
2962<eg><![CDATA[<!ENTITY % YN '"Yes"' >
2963<!ENTITY WhatHeSaid "He said &YN;" >]]></eg>
2964while this is not:
2965<eg>&lt;!ENTITY EndAttr "27'" >
2966&lt;element attribute='a-&amp;EndAttr;></eg>
2967</p></div3>
2968<div3 id='notify'>
2969<head>Notify</head>
2970<p>When the name of an <termref def='dt-unparsed'>unparsed
2971entity</termref> appears as a token in the
2972value of an attribute of declared type <kw>ENTITY</kw> or <kw>ENTITIES</kw>,
2973a validating processor must inform the
2974application of the <termref def='dt-sysid'>system</termref>
2975and <termref def='dt-pubid'>public</termref> (if any)
2976identifiers for both the entity and its associated
2977<termref def="dt-notation">notation</termref>.</p>
2978</div3>
2979<div3 id='bypass'>
2980<head>Bypassed</head>
2981<p>When a general entity reference appears in the
2982<nt def='NT-EntityValue'>EntityValue</nt> in an entity declaration,
2983it is bypassed and left as is.</p>
2984</div3>
2985<div3 id='as-PE'>
2986<head>Included as PE</head>
2987<p>Just as with external parsed entities, parameter entities
2988need only be <titleref href='include-if-valid'>included if
2989validating</titleref>.
2990When a parameter-entity reference is recognized in the DTD
2991and included, its
2992<termref def='dt-repltext'>replacement
2993text</termref> is enlarged by the attachment of one leading and one following
2994space (#x20) character; the intent is to constrain the replacement
2995text of parameter
2996entities to contain an integral number of grammatical tokens in the DTD.
2997</p>
2998</div3>
2999
3000</div2>
3001<div2 id='intern-replacement'>
3002<head>Construction of Internal Entity Replacement Text</head>
3003<p>In discussing the treatment
3004of internal entities, it is
3005useful to distinguish two forms of the entity's value.
3006<termdef id="dt-litentval" term='Literal Entity Value'>The <term>literal
3007entity value</term> is the quoted string actually
3008present in the entity declaration, corresponding to the
3009non-terminal <nt def='NT-EntityValue'>EntityValue</nt>.</termdef>
3010<termdef id='dt-repltext' term='Replacement Text'>The <term>replacement
3011text</term> is the content of the entity, after
3012replacement of character references and parameter-entity
3013references.
3014</termdef></p>
3015
3016<p>The literal entity value
3017as given in an internal entity declaration
3018(<nt def='NT-EntityValue'>EntityValue</nt>) may contain character,
3019parameter-entity, and general-entity references.
3020Such references must be contained entirely within the
3021literal entity value.
3022The actual replacement text that is
3023<termref def='dt-include'>included</termref> as described above
3024must contain the <emph>replacement text</emph> of any
3025parameter entities referred to, and must contain the character
3026referred to, in place of any character references in the
3027literal entity value; however,
3028general-entity references must be left as-is, unexpanded.
3029For example, given the following declarations:
3030
3031<eg><![CDATA[<!ENTITY % pub    "&#xc9;ditions Gallimard" >
3032<!ENTITY   rights "All rights reserved" >
3033<!ENTITY   book   "La Peste: Albert Camus,
3034&#xA9; 1947 %pub;. &rights;" >]]></eg>
3035then the replacement text for the entity "<code>book</code>" is:
3036<eg>La Peste: Albert Camus,
3037&#169; 1947 &#201;ditions Gallimard. &amp;rights;</eg>
3038The general-entity reference "<code>&amp;rights;</code>" would be expanded
3039should the reference "<code>&amp;book;</code>" appear in the document's
3040content or an attribute value.</p>
3041<p>These simple rules may have complex interactions; for a detailed
3042discussion of a difficult example, see
3043<specref ref='sec-entexpand'/>.
3044</p>
3045
3046</div2>
3047<div2 id='sec-predefined-ent'>
3048<head>Predefined Entities</head>
3049<p><termdef id="dt-escape" term="escape">Entity and character
3050references can both be used to <term>escape</term> the left angle bracket,
3051ampersand, and other delimiters.   A set of general entities
3052(&magicents;) is specified for this purpose.
3053Numeric character references may also be used; they are
3054expanded immediately when recognized and must be treated as
3055character data, so the numeric character references
3056"<code>&amp;#60;</code>" and "<code>&amp;#38;</code>" may be used to
3057escape <code>&lt;</code> and <code>&amp;</code> when they occur
3058in character data.</termdef></p>
3059<p>All XML processors must recognize these entities whether they
3060are declared or not.
3061<termref def='dt-interop'>For interoperability</termref>,
3062valid XML documents should declare these
3063entities, like any others, before using them.
3064If the entities in question are declared, they must be declared
3065as internal entities whose replacement text is the single
3066character being escaped or a character reference to
3067that character, as shown below.
3068<eg><![CDATA[<!ENTITY lt     "&#38;#60;">
3069<!ENTITY gt     "&#62;">
3070<!ENTITY amp    "&#38;#38;">
3071<!ENTITY apos   "&#39;">
3072<!ENTITY quot   "&#34;">
3073]]></eg>
3074Note that the <code>&lt;</code> and <code>&amp;</code> characters
3075in the declarations of "<code>lt</code>" and "<code>amp</code>"
3076are doubly escaped to meet the requirement that entity replacement
3077be well-formed.
3078</p>
3079</div2>
3080
3081<div2 id='Notations'>
3082<head>Notation Declarations</head>
3083
3084<p><termdef id="dt-notation" term="Notation"><term>Notations</term> identify by
3085name the format of <termref def="dt-extent">unparsed
3086entities</termref>, the
3087format of elements which bear a notation attribute,
3088or the application to which
3089a <termref def="dt-pi">processing instruction</termref> is
3090addressed.</termdef></p>
3091<p><termdef id="dt-notdecl" term="Notation Declaration">
3092<term>Notation declarations</term>
3093provide a name for the notation, for use in
3094entity and attribute-list declarations and in attribute specifications,
3095and an external identifier for the notation which may allow an XML
3096processor or its client application to locate a helper application
3097capable of processing data in the given notation.
3098<scrap lang='ebnf'>
3099<head>Notation Declarations</head>
3100<prod id='NT-NotationDecl'><lhs>NotationDecl</lhs>
3101<rhs>'&lt;!NOTATION' <nt def='NT-S'>S</nt> <nt def='NT-Name'>Name</nt>
3102<nt def='NT-S'>S</nt>
3103(<nt def='NT-ExternalID'>ExternalID</nt> |
3104<nt def='NT-PublicID'>PublicID</nt>)
3105<nt def='NT-S'>S</nt>? '>'</rhs></prod>
3106<prod id='NT-PublicID'><lhs>PublicID</lhs>
3107<rhs>'PUBLIC' <nt def='NT-S'>S</nt>
3108<nt def='NT-PubidLiteral'>PubidLiteral</nt>
3109</rhs></prod>
3110</scrap>
3111</termdef></p>
3112<p>XML processors must provide applications with the name and external
3113identifier(s) of any notation declared and referred to in an attribute
3114value, attribute definition, or entity declaration.  They may
3115additionally resolve the external identifier into the
3116<termref def="dt-sysid">system identifier</termref>,
3117file name, or other information needed to allow the
3118application to call a processor for data in the notation described.  (It
3119is not an error, however, for XML documents to declare and refer to
3120notations for which notation-specific applications are not available on
3121the system where the XML processor or application is running.)</p>
3122</div2>
3123
3124
3125<div2 id='sec-doc-entity'>
3126<head>Document Entity</head>
3127
3128<p><termdef id="dt-docent" term="Document Entity">The <term>document
3129entity</term> serves as the root of the entity
3130tree and a starting-point for an <termref def="dt-xml-proc">XML
3131processor</termref>.</termdef>
3132This specification does
3133not specify how the document entity is to be located by an XML
3134processor; unlike other entities, the document entity has no name and might
3135well appear on a processor input stream
3136without any identification at all.</p>
3137</div2>
3138
3139
3140</div1>
3141<!-- &Conformance; -->
3142
3143<div1 id='sec-conformance'>
3144<head>Conformance</head>
3145
3146<div2 id='proc-types'>
3147<head>Validating and Non-Validating Processors</head>
3148<p>Conforming <termref def="dt-xml-proc">XML processors</termref> fall into two
3149classes: validating and non-validating.</p>
3150<p>Validating and non-validating processors alike must report
3151violations of this specification's well-formedness constraints
3152in the content of the
3153<termref def='dt-docent'>document entity</termref> and any
3154other <termref def='dt-parsedent'>parsed entities</termref> that
3155they read.</p>
3156<p><termdef id="dt-validating" term="Validating Processor">
3157<term>Validating processors</term> must report
3158violations of the constraints expressed by the declarations in the
3159<termref def="dt-doctype">DTD</termref>, and
3160failures to fulfill the validity constraints given
3161in this specification.
3162</termdef>
3163To accomplish this, validating XML processors must read and process the entire
3164DTD and all external parsed entities referenced in the document.
3165</p>
3166<p>Non-validating processors are required to check only the
3167<termref def='dt-docent'>document entity</termref>, including
3168the entire internal DTD subset, for well-formedness.
3169<termdef id='dt-use-mdecl' term='Process Declarations'>
3170While they are not required to check the document for validity,
3171they are required to
3172<term>process</term> all the declarations they read in the
3173internal DTD subset and in any parameter entity that they
3174read, up to the first reference
3175to a parameter entity that they do <emph>not</emph> read; that is to
3176say, they must
3177use the information in those declarations to
3178<titleref href='AVNormalize'>normalize</titleref> attribute values,
3179<titleref href='included'>include</titleref> the replacement text of
3180internal entities, and supply
3181<titleref href='sec-attr-defaults'>default attribute values</titleref>.
3182</termdef>
3183They must not <termref def='dt-use-mdecl'>process</termref>
3184<termref def='dt-entdecl'>entity declarations</termref> or
3185<termref def='dt-attdecl'>attribute-list declarations</termref>
3186encountered after a reference to a parameter entity that is not
3187read, since the entity may have contained overriding declarations.
3188</p>
3189</div2>
3190<div2 id='safe-behavior'>
3191<head>Using XML Processors</head>
3192<p>The behavior of a validating XML processor is highly predictable; it
3193must read every piece of a document and report all well-formedness and
3194validity violations.
3195Less is required of a non-validating processor; it need not read any
3196part of the document other than the document entity.
3197This has two effects that may be important to users of XML processors:
3198<ulist>
3199<item><p>Certain well-formedness errors, specifically those that require
3200reading external entities, may not be detected by a non-validating processor.
3201Examples include the constraints entitled
3202<titleref href='wf-entdeclared'>Entity Declared</titleref>,
3203<titleref href='wf-textent'>Parsed Entity</titleref>, and
3204<titleref href='wf-norecursion'>No Recursion</titleref>, as well
3205as some of the cases described as
3206<titleref href='forbidden'>forbidden</titleref> in
3207<specref ref='entproc'/>.</p></item>
3208<item><p>The information passed from the processor to the application may
3209vary, depending on whether the processor reads
3210parameter and external entities.
3211For example, a non-validating processor may not
3212<titleref href='AVNormalize'>normalize</titleref> attribute values,
3213<titleref href='included'>include</titleref> the replacement text of
3214internal entities, or supply
3215<titleref href='sec-attr-defaults'>default attribute values</titleref>,
3216where doing so depends on having read declarations in
3217external or parameter entities.</p></item>
3218</ulist>
3219</p>
3220<p>For maximum reliability in interoperating between different XML
3221processors, applications which use non-validating processors should not
3222rely on any behaviors not required of such processors.
3223Applications which require facilities such as the use of default
3224attributes or internal entities which are declared in external
3225entities should use validating XML processors.</p>
3226</div2>
3227</div1>
3228
3229<div1 id='sec-notation'>
3230<head>Notation</head>
3231
3232<p>The formal grammar of XML is given in this specification using a simple
3233Extended Backus-Naur Form (EBNF) notation.  Each rule in the grammar defines
3234one symbol, in the form
3235<eg>symbol ::= expression</eg></p>
3236<p>Symbols are written with an initial capital letter if they are
3237defined by a regular expression, or with an initial lower case letter
3238otherwise.
3239Literal strings are quoted.
3240
3241</p>
3242
3243<p>Within the expression on the right-hand side of a rule, the following
3244expressions are used to match strings of one or more characters:
3245<glist>
3246<gitem>
3247<label><code>#xN</code></label>
3248<def><p>where <code>N</code> is a hexadecimal integer, the
3249expression matches the character in ISO/IEC 10646 whose canonical
3250(UCS-4)
3251code value, when interpreted as an unsigned binary number, has
3252the value indicated.  The number of leading zeros in the
3253<code>#xN</code> form is insignificant; the number of leading
3254zeros in the corresponding code value
3255is governed by the character
3256encoding in use and is not significant for XML.</p></def>
3257</gitem>
3258<gitem>
3259<label><code>[a-zA-Z]</code>, <code>[#xN-#xN]</code></label>
3260<def><p>matches any <termref def='dt-character'>character</termref>
3261with a value in the range(s) indicated (inclusive).</p></def>
3262</gitem>
3263<gitem>
3264<label><code>[^a-z]</code>, <code>[^#xN-#xN]</code></label>
3265<def><p>matches any <termref def='dt-character'>character</termref>
3266with a value <emph>outside</emph> the
3267range indicated.</p></def>
3268</gitem>
3269<gitem>
3270<label><code>[^abc]</code>, <code>[^#xN#xN#xN]</code></label>
3271<def><p>matches any <termref def='dt-character'>character</termref>
3272with a value not among the characters given.</p></def>
3273</gitem>
3274<gitem>
3275<label><code>"string"</code></label>
3276<def><p>matches a literal string <termref def="dt-match">matching</termref>
3277that given inside the double quotes.</p></def>
3278</gitem>
3279<gitem>
3280<label><code>'string'</code></label>
3281<def><p>matches a literal string <termref def="dt-match">matching</termref>
3282that given inside the single quotes.</p></def>
3283</gitem>
3284</glist>
3285These symbols may be combined to match more complex patterns as follows,
3286where <code>A</code> and <code>B</code> represent simple expressions:
3287<glist>
3288<gitem>
3289<label>(<code>expression</code>)</label>
3290<def><p><code>expression</code> is treated as a unit
3291and may be combined as described in this list.</p></def>
3292</gitem>
3293<gitem>
3294<label><code>A?</code></label>
3295<def><p>matches <code>A</code> or nothing; optional <code>A</code>.</p></def>
3296</gitem>
3297<gitem>
3298<label><code>A B</code></label>
3299<def><p>matches <code>A</code> followed by <code>B</code>.</p></def>
3300</gitem>
3301<gitem>
3302<label><code>A | B</code></label>
3303<def><p>matches <code>A</code> or <code>B</code> but not both.</p></def>
3304</gitem>
3305<gitem>
3306<label><code>A - B</code></label>
3307<def><p>matches any string that matches <code>A</code> but does not match
3308<code>B</code>.
3309</p></def>
3310</gitem>
3311<gitem>
3312<label><code>A+</code></label>
3313<def><p>matches one or more occurrences of <code>A</code>.</p></def>
3314</gitem>
3315<gitem>
3316<label><code>A*</code></label>
3317<def><p>matches zero or more occurrences of <code>A</code>.</p></def>
3318</gitem>
3319
3320</glist>
3321Other notations used in the productions are:
3322<glist>
3323<gitem>
3324<label><code>/* ... */</code></label>
3325<def><p>comment.</p></def>
3326</gitem>
3327<gitem>
3328<label><code>[ wfc: ... ]</code></label>
3329<def><p>well-formedness constraint; this identifies by name a
3330constraint on
3331<termref def="dt-wellformed">well-formed</termref> documents
3332associated with a production.</p></def>
3333</gitem>
3334<gitem>
3335<label><code>[ vc: ... ]</code></label>
3336<def><p>validity constraint; this identifies by name a constraint on
3337<termref def="dt-valid">valid</termref> documents associated with
3338a production.</p></def>
3339</gitem>
3340</glist>
3341</p></div1>
3342
3343</body>
3344<back>
3345<!-- &SGML; -->
3346
3347
3348<!-- &Biblio; -->
3349<div1 id='sec-bibliography'>
3350
3351<head>References</head>
3352<div2 id='sec-existing-stds'>
3353<head>Normative References</head>
3354
3355<blist>
3356<bibl id='IANA' key='IANA'>
3357(Internet Assigned Numbers Authority) <emph>Official Names for
3358Character Sets</emph>,
3359ed. Keld Simonsen et al.
3360See <loc href='ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets'>ftp://ftp.isi.edu/in-notes/iana/assignments/character-sets</loc>.
3361</bibl>
3362
3363<bibl id='RFC1766' key='IETF RFC 1766'>
3364IETF (Internet Engineering Task Force).
3365<emph>RFC 1766:  Tags for the Identification of Languages</emph>,
3366ed. H. Alvestrand.
33671995.
3368</bibl>
3369
3370<bibl id='ISO639' key='ISO 639'>
3371(International Organization for Standardization).
3372<emph>ISO 639:1988 (E).
3373Code for the representation of names of languages.</emph>
3374[Geneva]:  International Organization for
3375Standardization, 1988.</bibl>
3376
3377<bibl id='ISO3166' key='ISO 3166'>
3378(International Organization for Standardization).
3379<emph>ISO 3166-1:1997 (E).
3380Codes for the representation of names of countries and their subdivisions
3381&mdash; Part 1: Country codes</emph>
3382[Geneva]:  International Organization for
3383Standardization, 1997.</bibl>
3384
3385<bibl id='ISO10646' key='ISO/IEC 10646'>ISO
3386(International Organization for Standardization).
3387<emph>ISO/IEC 10646-1993 (E).  Information technology &mdash; Universal
3388Multiple-Octet Coded Character Set (UCS) &mdash; Part 1:
3389Architecture and Basic Multilingual Plane.</emph>
3390[Geneva]:  International Organization for
3391Standardization, 1993 (plus amendments AM 1 through AM 7).
3392</bibl>
3393
3394<bibl id='Unicode' key='Unicode'>The Unicode Consortium.
3395<emph>The Unicode Standard, Version 2.0.</emph>
3396Reading, Mass.:  Addison-Wesley Developers Press, 1996.</bibl>
3397
3398</blist>
3399
3400</div2>
3401
3402<div2><head>Other References</head>
3403
3404<blist>
3405
3406<bibl id='Aho' key='Aho/Ullman'>Aho, Alfred V.,
3407Ravi Sethi, and Jeffrey D. Ullman.
3408<emph>Compilers:  Principles, Techniques, and Tools</emph>.
3409Reading:  Addison-Wesley, 1986, rpt. corr. 1988.</bibl>
3410
3411<bibl id="Berners-Lee" xml-link="simple" key="Berners-Lee et al.">
3412Berners-Lee, T., R. Fielding, and L. Masinter.
3413<emph>Uniform Resource Identifiers (URI):  Generic Syntax and
3414Semantics</emph>.
34151997.
3416(Work in progress; see updates to RFC1738.)</bibl>
3417
3418<bibl id='ABK' key='Brggemann-Klein'>Br�ggemann-Klein, Anne.
3419<emph>Regular Expressions into Finite Automata</emph>.
3420Extended abstract in I. Simon, Hrsg., LATIN 1992,
3421S. 97-98. Springer-Verlag, Berlin 1992.
3422Full Version in Theoretical Computer Science 120: 197-213, 1993.
3423
3424</bibl>
3425
3426<bibl id='ABKDW' key='Brggemann-Klein and Wood'>Br�ggemann-Klein, Anne,
3427and Derick Wood.
3428<emph>Deterministic Regular Languages</emph>.
3429Universit�t Freiburg, Institut f�r Informatik,
3430Bericht 38, Oktober 1991.
3431</bibl>
3432
3433<bibl id='Clark' key='Clark'>James Clark.
3434Comparison of SGML and XML. See
3435<loc href='http://www.w3.org/TR/NOTE-sgml-xml-971215'>http://www.w3.org/TR/NOTE-sgml-xml-971215</loc>.
3436</bibl>
3437<bibl id="RFC1738" xml-link="simple" key="IETF RFC1738">
3438IETF (Internet Engineering Task Force).
3439<emph>RFC 1738:  Uniform Resource Locators (URL)</emph>,
3440ed. T. Berners-Lee, L. Masinter, M. McCahill.
34411994.
3442</bibl>
3443
3444<bibl id="RFC1808" xml-link="simple" key="IETF RFC1808">
3445IETF (Internet Engineering Task Force).
3446<emph>RFC 1808:  Relative Uniform Resource Locators</emph>,
3447ed. R. Fielding.
34481995.
3449</bibl>
3450
3451<bibl id="RFC2141" xml-link="simple" key="IETF RFC2141">
3452IETF (Internet Engineering Task Force).
3453<emph>RFC 2141:  URN Syntax</emph>,
3454ed. R. Moats.
34551997.
3456</bibl>
3457
3458<bibl id='ISO8879' key='ISO 8879'>ISO
3459(International Organization for Standardization).
3460<emph>ISO 8879:1986(E).  Information processing &mdash; Text and Office
3461Systems &mdash; Standard Generalized Markup Language (SGML).</emph>  First
3462edition &mdash; 1986-10-15.  [Geneva]:  International Organization for
3463Standardization, 1986.
3464</bibl>
3465
3466
3467<bibl id='ISO10744' key='ISO/IEC 10744'>ISO
3468(International Organization for Standardization).
3469<emph>ISO/IEC 10744-1992 (E).  Information technology &mdash;
3470Hypermedia/Time-based Structuring Language (HyTime).
3471</emph>
3472[Geneva]:  International Organization for
3473Standardization, 1992.
3474<emph>Extended Facilities Annexe.</emph>
3475[Geneva]:  International Organization for
3476Standardization, 1996.
3477</bibl>
3478
3479
3480
3481</blist>
3482</div2>
3483</div1>
3484<div1 id='CharClasses'>
3485<head>Character Classes</head>
3486<p>Following the characteristics defined in the Unicode standard,
3487characters are classed as base characters (among others, these
3488contain the alphabetic characters of the Latin alphabet, without
3489diacritics), ideographic characters, and combining characters (among
3490others, this class contains most diacritics); these classes combine
3491to form the class of letters.  Digits and extenders are
3492also distinguished.
3493<scrap lang="ebnf" id="CHARACTERS">
3494<head>Characters</head>
3495<prodgroup pcw3="3" pcw4="15">
3496<prod id="NT-Letter"><lhs>Letter</lhs>
3497<rhs><nt def="NT-BaseChar">BaseChar</nt>
3498| <nt def="NT-Ideographic">Ideographic</nt></rhs> </prod>
3499<prod id='NT-BaseChar'><lhs>BaseChar</lhs>
3500<rhs>[#x0041-#x005A]
3501|&nbsp;[#x0061-#x007A]
3502|&nbsp;[#x00C0-#x00D6]
3503|&nbsp;[#x00D8-#x00F6]
3504|&nbsp;[#x00F8-#x00FF]
3505|&nbsp;[#x0100-#x0131]
3506|&nbsp;[#x0134-#x013E]
3507|&nbsp;[#x0141-#x0148]
3508|&nbsp;[#x014A-#x017E]
3509|&nbsp;[#x0180-#x01C3]
3510|&nbsp;[#x01CD-#x01F0]
3511|&nbsp;[#x01F4-#x01F5]
3512|&nbsp;[#x01FA-#x0217]
3513|&nbsp;[#x0250-#x02A8]
3514|&nbsp;[#x02BB-#x02C1]
3515|&nbsp;#x0386
3516|&nbsp;[#x0388-#x038A]
3517|&nbsp;#x038C
3518|&nbsp;[#x038E-#x03A1]
3519|&nbsp;[#x03A3-#x03CE]
3520|&nbsp;[#x03D0-#x03D6]
3521|&nbsp;#x03DA
3522|&nbsp;#x03DC
3523|&nbsp;#x03DE
3524|&nbsp;#x03E0
3525|&nbsp;[#x03E2-#x03F3]
3526|&nbsp;[#x0401-#x040C]
3527|&nbsp;[#x040E-#x044F]
3528|&nbsp;[#x0451-#x045C]
3529|&nbsp;[#x045E-#x0481]
3530|&nbsp;[#x0490-#x04C4]
3531|&nbsp;[#x04C7-#x04C8]
3532|&nbsp;[#x04CB-#x04CC]
3533|&nbsp;[#x04D0-#x04EB]
3534|&nbsp;[#x04EE-#x04F5]
3535|&nbsp;[#x04F8-#x04F9]
3536|&nbsp;[#x0531-#x0556]
3537|&nbsp;#x0559
3538|&nbsp;[#x0561-#x0586]
3539|&nbsp;[#x05D0-#x05EA]
3540|&nbsp;[#x05F0-#x05F2]
3541|&nbsp;[#x0621-#x063A]
3542|&nbsp;[#x0641-#x064A]
3543|&nbsp;[#x0671-#x06B7]
3544|&nbsp;[#x06BA-#x06BE]
3545|&nbsp;[#x06C0-#x06CE]
3546|&nbsp;[#x06D0-#x06D3]
3547|&nbsp;#x06D5
3548|&nbsp;[#x06E5-#x06E6]
3549|&nbsp;[#x0905-#x0939]
3550|&nbsp;#x093D
3551|&nbsp;[#x0958-#x0961]
3552|&nbsp;[#x0985-#x098C]
3553|&nbsp;[#x098F-#x0990]
3554|&nbsp;[#x0993-#x09A8]
3555|&nbsp;[#x09AA-#x09B0]
3556|&nbsp;#x09B2
3557|&nbsp;[#x09B6-#x09B9]
3558|&nbsp;[#x09DC-#x09DD]
3559|&nbsp;[#x09DF-#x09E1]
3560|&nbsp;[#x09F0-#x09F1]
3561|&nbsp;[#x0A05-#x0A0A]
3562|&nbsp;[#x0A0F-#x0A10]
3563|&nbsp;[#x0A13-#x0A28]
3564|&nbsp;[#x0A2A-#x0A30]
3565|&nbsp;[#x0A32-#x0A33]
3566|&nbsp;[#x0A35-#x0A36]
3567|&nbsp;[#x0A38-#x0A39]
3568|&nbsp;[#x0A59-#x0A5C]
3569|&nbsp;#x0A5E
3570|&nbsp;[#x0A72-#x0A74]
3571|&nbsp;[#x0A85-#x0A8B]
3572|&nbsp;#x0A8D
3573|&nbsp;[#x0A8F-#x0A91]
3574|&nbsp;[#x0A93-#x0AA8]
3575|&nbsp;[#x0AAA-#x0AB0]
3576|&nbsp;[#x0AB2-#x0AB3]
3577|&nbsp;[#x0AB5-#x0AB9]
3578|&nbsp;#x0ABD
3579|&nbsp;#x0AE0
3580|&nbsp;[#x0B05-#x0B0C]
3581|&nbsp;[#x0B0F-#x0B10]
3582|&nbsp;[#x0B13-#x0B28]
3583|&nbsp;[#x0B2A-#x0B30]
3584|&nbsp;[#x0B32-#x0B33]
3585|&nbsp;[#x0B36-#x0B39]
3586|&nbsp;#x0B3D
3587|&nbsp;[#x0B5C-#x0B5D]
3588|&nbsp;[#x0B5F-#x0B61]
3589|&nbsp;[#x0B85-#x0B8A]
3590|&nbsp;[#x0B8E-#x0B90]
3591|&nbsp;[#x0B92-#x0B95]
3592|&nbsp;[#x0B99-#x0B9A]
3593|&nbsp;#x0B9C
3594|&nbsp;[#x0B9E-#x0B9F]
3595|&nbsp;[#x0BA3-#x0BA4]
3596|&nbsp;[#x0BA8-#x0BAA]
3597|&nbsp;[#x0BAE-#x0BB5]
3598|&nbsp;[#x0BB7-#x0BB9]
3599|&nbsp;[#x0C05-#x0C0C]
3600|&nbsp;[#x0C0E-#x0C10]
3601|&nbsp;[#x0C12-#x0C28]
3602|&nbsp;[#x0C2A-#x0C33]
3603|&nbsp;[#x0C35-#x0C39]
3604|&nbsp;[#x0C60-#x0C61]
3605|&nbsp;[#x0C85-#x0C8C]
3606|&nbsp;[#x0C8E-#x0C90]
3607|&nbsp;[#x0C92-#x0CA8]
3608|&nbsp;[#x0CAA-#x0CB3]
3609|&nbsp;[#x0CB5-#x0CB9]
3610|&nbsp;#x0CDE
3611|&nbsp;[#x0CE0-#x0CE1]
3612|&nbsp;[#x0D05-#x0D0C]
3613|&nbsp;[#x0D0E-#x0D10]
3614|&nbsp;[#x0D12-#x0D28]
3615|&nbsp;[#x0D2A-#x0D39]
3616|&nbsp;[#x0D60-#x0D61]
3617|&nbsp;[#x0E01-#x0E2E]
3618|&nbsp;#x0E30
3619|&nbsp;[#x0E32-#x0E33]
3620|&nbsp;[#x0E40-#x0E45]
3621|&nbsp;[#x0E81-#x0E82]
3622|&nbsp;#x0E84
3623|&nbsp;[#x0E87-#x0E88]
3624|&nbsp;#x0E8A
3625|&nbsp;#x0E8D
3626|&nbsp;[#x0E94-#x0E97]
3627|&nbsp;[#x0E99-#x0E9F]
3628|&nbsp;[#x0EA1-#x0EA3]
3629|&nbsp;#x0EA5
3630|&nbsp;#x0EA7
3631|&nbsp;[#x0EAA-#x0EAB]
3632|&nbsp;[#x0EAD-#x0EAE]
3633|&nbsp;#x0EB0
3634|&nbsp;[#x0EB2-#x0EB3]
3635|&nbsp;#x0EBD
3636|&nbsp;[#x0EC0-#x0EC4]
3637|&nbsp;[#x0F40-#x0F47]
3638|&nbsp;[#x0F49-#x0F69]
3639|&nbsp;[#x10A0-#x10C5]
3640|&nbsp;[#x10D0-#x10F6]
3641|&nbsp;#x1100
3642|&nbsp;[#x1102-#x1103]
3643|&nbsp;[#x1105-#x1107]
3644|&nbsp;#x1109
3645|&nbsp;[#x110B-#x110C]
3646|&nbsp;[#x110E-#x1112]
3647|&nbsp;#x113C
3648|&nbsp;#x113E
3649|&nbsp;#x1140
3650|&nbsp;#x114C
3651|&nbsp;#x114E
3652|&nbsp;#x1150
3653|&nbsp;[#x1154-#x1155]
3654|&nbsp;#x1159
3655|&nbsp;[#x115F-#x1161]
3656|&nbsp;#x1163
3657|&nbsp;#x1165
3658|&nbsp;#x1167
3659|&nbsp;#x1169
3660|&nbsp;[#x116D-#x116E]
3661|&nbsp;[#x1172-#x1173]
3662|&nbsp;#x1175
3663|&nbsp;#x119E
3664|&nbsp;#x11A8
3665|&nbsp;#x11AB
3666|&nbsp;[#x11AE-#x11AF]
3667|&nbsp;[#x11B7-#x11B8]
3668|&nbsp;#x11BA
3669|&nbsp;[#x11BC-#x11C2]
3670|&nbsp;#x11EB
3671|&nbsp;#x11F0
3672|&nbsp;#x11F9
3673|&nbsp;[#x1E00-#x1E9B]
3674|&nbsp;[#x1EA0-#x1EF9]
3675|&nbsp;[#x1F00-#x1F15]
3676|&nbsp;[#x1F18-#x1F1D]
3677|&nbsp;[#x1F20-#x1F45]
3678|&nbsp;[#x1F48-#x1F4D]
3679|&nbsp;[#x1F50-#x1F57]
3680|&nbsp;#x1F59
3681|&nbsp;#x1F5B
3682|&nbsp;#x1F5D
3683|&nbsp;[#x1F5F-#x1F7D]
3684|&nbsp;[#x1F80-#x1FB4]
3685|&nbsp;[#x1FB6-#x1FBC]
3686|&nbsp;#x1FBE
3687|&nbsp;[#x1FC2-#x1FC4]
3688|&nbsp;[#x1FC6-#x1FCC]
3689|&nbsp;[#x1FD0-#x1FD3]
3690|&nbsp;[#x1FD6-#x1FDB]
3691|&nbsp;[#x1FE0-#x1FEC]
3692|&nbsp;[#x1FF2-#x1FF4]
3693|&nbsp;[#x1FF6-#x1FFC]
3694|&nbsp;#x2126
3695|&nbsp;[#x212A-#x212B]
3696|&nbsp;#x212E
3697|&nbsp;[#x2180-#x2182]
3698|&nbsp;[#x3041-#x3094]
3699|&nbsp;[#x30A1-#x30FA]
3700|&nbsp;[#x3105-#x312C]
3701|&nbsp;[#xAC00-#xD7A3]
3702</rhs></prod>
3703<prod id='NT-Ideographic'><lhs>Ideographic</lhs>
3704<rhs>[#x4E00-#x9FA5]
3705|&nbsp;#x3007
3706|&nbsp;[#x3021-#x3029]
3707</rhs></prod>
3708<prod id='NT-CombiningChar'><lhs>CombiningChar</lhs>
3709<rhs>[#x0300-#x0345]
3710|&nbsp;[#x0360-#x0361]
3711|&nbsp;[#x0483-#x0486]
3712|&nbsp;[#x0591-#x05A1]
3713|&nbsp;[#x05A3-#x05B9]
3714|&nbsp;[#x05BB-#x05BD]
3715|&nbsp;#x05BF
3716|&nbsp;[#x05C1-#x05C2]
3717|&nbsp;#x05C4
3718|&nbsp;[#x064B-#x0652]
3719|&nbsp;#x0670
3720|&nbsp;[#x06D6-#x06DC]
3721|&nbsp;[#x06DD-#x06DF]
3722|&nbsp;[#x06E0-#x06E4]
3723|&nbsp;[#x06E7-#x06E8]
3724|&nbsp;[#x06EA-#x06ED]
3725|&nbsp;[#x0901-#x0903]
3726|&nbsp;#x093C
3727|&nbsp;[#x093E-#x094C]
3728|&nbsp;#x094D
3729|&nbsp;[#x0951-#x0954]
3730|&nbsp;[#x0962-#x0963]
3731|&nbsp;[#x0981-#x0983]
3732|&nbsp;#x09BC
3733|&nbsp;#x09BE
3734|&nbsp;#x09BF
3735|&nbsp;[#x09C0-#x09C4]
3736|&nbsp;[#x09C7-#x09C8]
3737|&nbsp;[#x09CB-#x09CD]
3738|&nbsp;#x09D7
3739|&nbsp;[#x09E2-#x09E3]
3740|&nbsp;#x0A02
3741|&nbsp;#x0A3C
3742|&nbsp;#x0A3E
3743|&nbsp;#x0A3F
3744|&nbsp;[#x0A40-#x0A42]
3745|&nbsp;[#x0A47-#x0A48]
3746|&nbsp;[#x0A4B-#x0A4D]
3747|&nbsp;[#x0A70-#x0A71]
3748|&nbsp;[#x0A81-#x0A83]
3749|&nbsp;#x0ABC
3750|&nbsp;[#x0ABE-#x0AC5]
3751|&nbsp;[#x0AC7-#x0AC9]
3752|&nbsp;[#x0ACB-#x0ACD]
3753|&nbsp;[#x0B01-#x0B03]
3754|&nbsp;#x0B3C
3755|&nbsp;[#x0B3E-#x0B43]
3756|&nbsp;[#x0B47-#x0B48]
3757|&nbsp;[#x0B4B-#x0B4D]
3758|&nbsp;[#x0B56-#x0B57]
3759|&nbsp;[#x0B82-#x0B83]
3760|&nbsp;[#x0BBE-#x0BC2]
3761|&nbsp;[#x0BC6-#x0BC8]
3762|&nbsp;[#x0BCA-#x0BCD]
3763|&nbsp;#x0BD7
3764|&nbsp;[#x0C01-#x0C03]
3765|&nbsp;[#x0C3E-#x0C44]
3766|&nbsp;[#x0C46-#x0C48]
3767|&nbsp;[#x0C4A-#x0C4D]
3768|&nbsp;[#x0C55-#x0C56]
3769|&nbsp;[#x0C82-#x0C83]
3770|&nbsp;[#x0CBE-#x0CC4]
3771|&nbsp;[#x0CC6-#x0CC8]
3772|&nbsp;[#x0CCA-#x0CCD]
3773|&nbsp;[#x0CD5-#x0CD6]
3774|&nbsp;[#x0D02-#x0D03]
3775|&nbsp;[#x0D3E-#x0D43]
3776|&nbsp;[#x0D46-#x0D48]
3777|&nbsp;[#x0D4A-#x0D4D]
3778|&nbsp;#x0D57
3779|&nbsp;#x0E31
3780|&nbsp;[#x0E34-#x0E3A]
3781|&nbsp;[#x0E47-#x0E4E]
3782|&nbsp;#x0EB1
3783|&nbsp;[#x0EB4-#x0EB9]
3784|&nbsp;[#x0EBB-#x0EBC]
3785|&nbsp;[#x0EC8-#x0ECD]
3786|&nbsp;[#x0F18-#x0F19]
3787|&nbsp;#x0F35
3788|&nbsp;#x0F37
3789|&nbsp;#x0F39
3790|&nbsp;#x0F3E
3791|&nbsp;#x0F3F
3792|&nbsp;[#x0F71-#x0F84]
3793|&nbsp;[#x0F86-#x0F8B]
3794|&nbsp;[#x0F90-#x0F95]
3795|&nbsp;#x0F97
3796|&nbsp;[#x0F99-#x0FAD]
3797|&nbsp;[#x0FB1-#x0FB7]
3798|&nbsp;#x0FB9
3799|&nbsp;[#x20D0-#x20DC]
3800|&nbsp;#x20E1
3801|&nbsp;[#x302A-#x302F]
3802|&nbsp;#x3099
3803|&nbsp;#x309A
3804</rhs></prod>
3805<prod id='NT-Digit'><lhs>Digit</lhs>
3806<rhs>[#x0030-#x0039]
3807|&nbsp;[#x0660-#x0669]
3808|&nbsp;[#x06F0-#x06F9]
3809|&nbsp;[#x0966-#x096F]
3810|&nbsp;[#x09E6-#x09EF]
3811|&nbsp;[#x0A66-#x0A6F]
3812|&nbsp;[#x0AE6-#x0AEF]
3813|&nbsp;[#x0B66-#x0B6F]
3814|&nbsp;[#x0BE7-#x0BEF]
3815|&nbsp;[#x0C66-#x0C6F]
3816|&nbsp;[#x0CE6-#x0CEF]
3817|&nbsp;[#x0D66-#x0D6F]
3818|&nbsp;[#x0E50-#x0E59]
3819|&nbsp;[#x0ED0-#x0ED9]
3820|&nbsp;[#x0F20-#x0F29]
3821</rhs></prod>
3822<prod id='NT-Extender'><lhs>Extender</lhs>
3823<rhs>#x00B7
3824|&nbsp;#x02D0
3825|&nbsp;#x02D1
3826|&nbsp;#x0387
3827|&nbsp;#x0640
3828|&nbsp;#x0E46
3829|&nbsp;#x0EC6
3830|&nbsp;#x3005
3831|&nbsp;[#x3031-#x3035]
3832|&nbsp;[#x309D-#x309E]
3833|&nbsp;[#x30FC-#x30FE]
3834</rhs></prod>
3835
3836</prodgroup>
3837</scrap>
3838</p>
3839<p>The character classes defined here can be derived from the
3840Unicode character database as follows:
3841<ulist>
3842<item>
3843<p>Name start characters must have one of the categories Ll, Lu,
3844Lo, Lt, Nl.</p>
3845</item>
3846<item>
3847<p>Name characters other than Name-start characters
3848must have one of the categories Mc, Me, Mn, Lm, or Nd.</p>
3849</item>
3850<item>
3851<p>Characters in the compatibility area (i.e. with character code
3852greater than #xF900 and less than #xFFFE) are not allowed in XML
3853names.</p>
3854</item>
3855<item>
3856<p>Characters which have a font or compatibility decomposition (i.e. those
3857with a "compatibility formatting tag" in field 5 of the database --
3858marked by field 5 beginning with a "&lt;") are not allowed.</p>
3859</item>
3860<item>
3861<p>The following characters are treated as name-start characters
3862rather than name characters, because the property file classifies
3863them as Alphabetic:  [#x02BB-#x02C1], #x0559, #x06E5, #x06E6.</p>
3864</item>
3865<item>
3866<p>Characters #x20DD-#x20E0 are excluded (in accordance with
3867Unicode, section 5.14).</p>
3868</item>
3869<item>
3870<p>Character #x00B7 is classified as an extender, because the
3871property list so identifies it.</p>
3872</item>
3873<item>
3874<p>Character #x0387 is added as a name character, because #x00B7
3875is its canonical equivalent.</p>
3876</item>
3877<item>
3878<p>Characters ':' and '_' are allowed as name-start characters.</p>
3879</item>
3880<item>
3881<p>Characters '-' and '.' are allowed as name characters.</p>
3882</item>
3883</ulist>
3884</p>
3885</div1>
3886<inform-div1 id="sec-xml-and-sgml">
3887<head>XML and SGML</head>
3888
3889<p>XML is designed to be a subset of SGML, in that every
3890<termref def="dt-valid">valid</termref> XML document should also be a
3891conformant SGML document.
3892For a detailed comparison of the additional restrictions that XML places on
3893documents beyond those of SGML, see <bibref ref='Clark'/>.
3894</p>
3895</inform-div1>
3896<inform-div1 id="sec-entexpand">
3897<head>Expansion of Entity and Character References</head>
3898<p>This appendix contains some examples illustrating the
3899sequence of entity- and character-reference recognition and
3900expansion, as specified in <specref ref='entproc'/>.</p>
3901<p>
3902If the DTD contains the declaration
3903<eg><![CDATA[<!ENTITY example "<p>An ampersand (&#38;#38;) may be escaped
3904numerically (&#38;#38;#38;) or with a general entity
3905(&amp;amp;).</p>" >
3906]]></eg>
3907then the XML processor will recognize the character references
3908when it parses the entity declaration, and resolve them before
3909storing the following string as the
3910value of the entity "<code>example</code>":
3911<eg><![CDATA[<p>An ampersand (&#38;) may be escaped
3912numerically (&#38;#38;) or with a general entity
3913(&amp;amp;).</p>
3914]]></eg>
3915A reference in the document to "<code>&amp;example;</code>"
3916will cause the text to be reparsed, at which time the
3917start- and end-tags of the "<code>p</code>" element will be recognized
3918and the three references will be recognized and expanded,
3919resulting in a "<code>p</code>" element with the following content
3920(all data, no delimiters or markup):
3921<eg><![CDATA[An ampersand (&) may be escaped
3922numerically (&#38;) or with a general entity
3923(&amp;).
3924]]></eg>
3925</p>
3926<p>A more complex example will illustrate the rules and their
3927effects fully.  In the following example, the line numbers are
3928solely for reference.
3929<eg><![CDATA[1 <?xml version='1.0'?>
39302 <!DOCTYPE test [
39313 <!ELEMENT test (#PCDATA) >
39324 <!ENTITY % xx '&#37;zz;'>
39335 <!ENTITY % zz '&#60;!ENTITY tricky "error-prone" >' >
39346 %xx;
39357 ]>
39368 <test>This sample shows a &tricky; method.</test>
3937]]></eg>
3938This produces the following:
3939<ulist spacing="compact">
3940<item><p>in line 4, the reference to character 37 is expanded immediately,
3941and the parameter entity "<code>xx</code>" is stored in the symbol
3942table with the value "<code>%zz;</code>".  Since the replacement text
3943is not rescanned, the reference to parameter entity "<code>zz</code>"
3944is not recognized.  (And it would be an error if it were, since
3945"<code>zz</code>" is not yet declared.)</p></item>
3946<item><p>in line 5, the character reference "<code>&amp;#60;</code>" is
3947expanded immediately and the parameter entity "<code>zz</code>" is
3948stored with the replacement text
3949"<code>&lt;!ENTITY tricky "error-prone" ></code>",
3950which is a well-formed entity declaration.</p></item>
3951<item><p>in line 6, the reference to "<code>xx</code>" is recognized,
3952and the replacement text of "<code>xx</code>" (namely
3953"<code>%zz;</code>") is parsed.  The reference to "<code>zz</code>"
3954is recognized in its turn, and its replacement text
3955("<code>&lt;!ENTITY tricky "error-prone" ></code>") is parsed.
3956The general entity "<code>tricky</code>" has now been
3957declared, with the replacement text "<code>error-prone</code>".</p></item>
3958<item><p>
3959in line 8, the reference to the general entity "<code>tricky</code>" is
3960recognized, and it is expanded, so the full content of the
3961"<code>test</code>" element is the self-describing (and ungrammatical) string
3962<emph>This sample shows a error-prone method.</emph>
3963</p></item>
3964</ulist>
3965</p>
3966</inform-div1>
3967<inform-div1 id="determinism">
3968<head>Deterministic Content Models</head>
3969<p><termref def='dt-compat'>For compatibility</termref>, it is
3970required
3971that content models in element type declarations be deterministic.
3972</p>
3973<!-- FINAL EDIT:  WebSGML allows ambiguity? -->
3974<p>SGML
3975requires deterministic content models (it calls them
3976"unambiguous"); XML processors built using SGML systems may
3977flag non-deterministic content models as errors.</p>
3978<p>For example, the content model <code>((b, c) | (b, d))</code> is
3979non-deterministic, because given an initial <code>b</code> the parser
3980cannot know which <code>b</code> in the model is being matched without
3981looking ahead to see which element follows the <code>b</code>.
3982In this case, the two references to
3983<code>b</code> can be collapsed
3984into a single reference, making the model read
3985<code>(b, (c | d))</code>.  An initial <code>b</code> now clearly
3986matches only a single name in the content model.  The parser doesn't
3987need to look ahead to see what follows; either <code>c</code> or
3988<code>d</code> would be accepted.</p>
3989<p>More formally:  a finite state automaton may be constructed from the
3990content model using the standard algorithms, e.g. algorithm 3.5
3991in section 3.9
3992of Aho, Sethi, and Ullman <bibref ref='Aho'/>.
3993In many such algorithms, a follow set is constructed for each
3994position in the regular expression (i.e., each leaf
3995node in the
3996syntax tree for the regular expression);
3997if any position has a follow set in which
3998more than one following position is
3999labeled with the same element type name,
4000then the content model is in error
4001and may be reported as an error.
4002</p>
4003<p>Algorithms exist which allow many but not all non-deterministic
4004content models to be reduced automatically to equivalent deterministic
4005models; see Br�ggemann-Klein 1991 <bibref ref='ABK'/>.</p>
4006</inform-div1>
4007<inform-div1 id="sec-guessing">
4008<head>Autodetection of Character Encodings</head>
4009<p>The XML encoding declaration functions as an internal label on each
4010entity, indicating which character encoding is in use.  Before an XML
4011processor can read the internal label, however, it apparently has to
4012know what character encoding is in use&mdash;which is what the internal label
4013is trying to indicate.  In the general case, this is a hopeless
4014situation. It is not entirely hopeless in XML, however, because XML
4015limits the general case in two ways:  each implementation is assumed
4016to support only a  finite set of character encodings, and the XML
4017encoding declaration is restricted in position and content in order to
4018make it feasible to autodetect the character encoding in use in each
4019entity in normal cases.  Also, in many cases other sources of information
4020are available in addition to the XML data stream itself.
4021Two cases may be distinguished,
4022depending on whether the XML entity is presented to the
4023processor without, or with, any accompanying
4024(external) information.  We consider the first case first.
4025</p>
4026<p>
4027Because each XML entity not in UTF-8 or UTF-16 format <emph>must</emph>
4028begin with an XML encoding declaration, in which the first  characters
4029must be '<code>&lt;?xml</code>', any conforming processor can detect,
4030after two to four octets of input, which of the following cases apply.
4031In reading this list, it may help to know that in UCS-4, '&lt;' is
4032"<code>#x0000003C</code>" and '?' is "<code>#x0000003F</code>", and the Byte
4033Order Mark required of UTF-16 data streams is "<code>#xFEFF</code>".</p>
4034<p>
4035<ulist>
4036<item>
4037<p><code>00 00 00 3C</code>: UCS-4, big-endian machine (1234 order)</p>
4038</item>
4039<item>
4040<p><code>3C 00 00 00</code>: UCS-4, little-endian machine (4321 order)</p>
4041</item>
4042<item>
4043<p><code>00 00 3C 00</code>: UCS-4, unusual octet order (2143)</p>
4044</item>
4045<item>
4046<p><code>00 3C 00 00</code>: UCS-4, unusual octet order (3412)</p>
4047</item>
4048<item>
4049<p><code>FE FF</code>: UTF-16, big-endian</p>
4050</item>
4051<item>
4052<p><code>FF FE</code>: UTF-16, little-endian</p>
4053</item>
4054<item>
4055<p><code>00 3C 00 3F</code>: UTF-16, big-endian, no Byte Order Mark
4056(and thus, strictly speaking, in error)</p>
4057</item>
4058<item>
4059<p><code>3C 00 3F 00</code>: UTF-16, little-endian, no Byte Order Mark
4060(and thus, strictly speaking, in error)</p>
4061</item>
4062<item>
4063<p><code>3C 3F 78 6D</code>: UTF-8, ISO 646, ASCII, some part of ISO 8859,
4064Shift-JIS, EUC, or any other 7-bit, 8-bit, or mixed-width encoding
4065which ensures that the characters of ASCII have their normal positions,
4066width,
4067and values; the actual encoding declaration must be read to
4068detect which of these applies, but since all of these encodings
4069use the same bit patterns for the ASCII characters, the encoding
4070declaration itself may be read reliably
4071</p>
4072</item>
4073<item>
4074<p><code>4C 6F A7 94</code>: EBCDIC (in some flavor; the full
4075encoding declaration must be read to tell which code page is in
4076use)</p>
4077</item>
4078<item>
4079<p>other: UTF-8 without an encoding declaration, or else
4080the data stream is corrupt, fragmentary, or enclosed in
4081a wrapper of some kind</p>
4082</item>
4083</ulist>
4084</p>
4085<p>
4086This level of autodetection is enough to read the XML encoding
4087declaration and parse the character-encoding identifier, which is
4088still necessary to distinguish the individual members of each family
4089of encodings (e.g. to tell  UTF-8 from 8859, and the parts of 8859
4090from each other, or to distinguish the specific EBCDIC code page in
4091use, and so on).
4092</p>
4093<p>
4094Because the contents of the encoding declaration are restricted to
4095ASCII characters, a processor can reliably read the entire encoding
4096declaration as soon as it has detected which family of encodings is in
4097use.  Since in practice, all widely used character encodings fall into
4098one of the categories above, the XML encoding declaration allows
4099reasonably reliable in-band labeling of character encodings, even when
4100external sources of information at the operating-system or
4101transport-protocol level are unreliable.
4102</p>
4103<p>
4104Once the processor has detected the character encoding in use, it can
4105act appropriately, whether by invoking a separate input routine for
4106each case, or by calling the proper conversion function on each
4107character of input.
4108</p>
4109<p>
4110Like any self-labeling system, the XML encoding declaration will not
4111work if any software changes the entity's character set or encoding
4112without updating the encoding declaration.  Implementors of
4113character-encoding routines should be careful to ensure the accuracy
4114of the internal and external information used to label the entity.
4115</p>
4116<p>The second possible case occurs when the XML entity is accompanied
4117by encoding information, as in some file systems and some network
4118protocols.
4119When multiple sources of information are available,
4120
4121their relative
4122priority and the preferred method of handling conflict should be
4123specified as part of the higher-level protocol used to deliver XML.
4124Rules for the relative priority of the internal label and the
4125MIME-type label in an external header, for example, should be part of the
4126RFC document defining the text/xml and application/xml MIME types. In
4127the interests of interoperability, however, the following rules
4128are recommended.
4129<ulist>
4130<item><p>If an XML entity is in a file, the Byte-Order Mark
4131and encoding-declaration PI are used (if present) to determine the
4132character encoding.  All other heuristics and sources of information
4133are solely for error recovery.
4134</p></item>
4135<item><p>If an XML entity is delivered with a
4136MIME type of text/xml, then the <code>charset</code> parameter
4137on the MIME type determines the
4138character encoding method; all other heuristics and sources of
4139information are solely for error recovery.
4140</p></item>
4141<item><p>If an XML entity is delivered
4142with a
4143MIME type of application/xml, then the Byte-Order Mark and
4144encoding-declaration PI are used (if present) to determine the
4145character encoding.  All other heuristics and sources of
4146information are solely for error recovery.
4147</p></item>
4148</ulist>
4149These rules apply only in the absence of protocol-level documentation;
4150in particular, when the MIME types text/xml and application/xml are
4151defined, the recommendations of the relevant RFC will supersede
4152these rules.
4153</p>
4154
4155</inform-div1>
4156
4157<inform-div1 id="sec-xml-wg">
4158<head>W3C XML Working Group</head>
4159
4160<p>This specification was prepared and approved for publication by the
4161W3C XML Working Group (WG).  WG approval of this specification does
4162not necessarily imply that all WG members voted for its approval.
4163The current and former members of the XML WG are:</p>
4164
4165<orglist>
4166<member><name>Jon Bosak, Sun</name><role>Chair</role></member>
4167<member><name>James Clark</name><role>Technical Lead</role></member>
4168<member><name>Tim Bray, Textuality and Netscape</name><role>XML Co-editor</role></member>
4169<member><name>Jean Paoli, Microsoft</name><role>XML Co-editor</role></member>
4170<member><name>C. M. Sperberg-McQueen, U. of Ill.</name><role>XML
4171Co-editor</role></member>
4172<member><name>Dan Connolly, W3C</name><role>W3C Liaison</role></member>
4173<member><name>Paula Angerstein, Texcel</name></member>
4174<member><name>Steve DeRose, INSO</name></member>
4175<member><name>Dave Hollander, HP</name></member>
4176<member><name>Eliot Kimber, ISOGEN</name></member>
4177<member><name>Eve Maler, ArborText</name></member>
4178<member><name>Tom Magliery, NCSA</name></member>
4179<member><name>Murray Maloney, Muzmo and Grif</name></member>
4180<member><name>Makoto Murata, Fuji Xerox Information Systems</name></member>
4181<member><name>Joel Nava, Adobe</name></member>
4182<member><name>Conleth O'Connell, Vignette</name></member>
4183<member><name>Peter Sharpe, SoftQuad</name></member>
4184<member><name>John Tigue, DataChannel</name></member>
4185</orglist>
4186
4187</inform-div1>
4188</back>
4189</spec>
4190<!-- Keep this comment at the end of the file
4191Local variables:
4192mode: sgml
4193sgml-default-dtd-file:"~/sgml/spec.ced"
4194sgml-omittag:t
4195sgml-shorttag:t
4196End:
4197-->
4198