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