Parent Directory
|
Revision Log
Some scope notes; more on parsing
| 1 | <!DOCTYPE html> |
| 2 | <html lang="en" class="formal-specification status-work-in-progress"> |
| 3 | <head> |
| 4 | <title>manakai's XML Conformance Checking</title> |
| 5 | <link rel="stylesheet" href="http://suika.fam.cx/www/style/html/spec"> |
| 6 | <link rel="license" href="http://suika.fam.cx/c/gnu/fdl"> |
| 7 | <style> |
| 8 | a[id]::before { |
| 9 | content: "[" attr(id) "]"; |
| 10 | color: gray; |
| 11 | font-size: 70%; |
| 12 | font-family: Courier New, monospace; |
| 13 | vertical-align: 60%; |
| 14 | } |
| 15 | </style> |
| 16 | </head> |
| 17 | <body class="has-abstract"> |
| 18 | |
| 19 | <div class="header"> |
| 20 | <h1>manakai's <abbr>XML</abbr> Conformance Checking</h1> |
| 21 | <h2>Working Draft <time datetime=2008-03-29>29 March 2008</time></h2> |
| 22 | |
| 23 | <dl class="versions-uri"> |
| 24 | <dt>This Version</dt> |
| 25 | <dd><code class="URI"><<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work" |
| 26 | >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work</a>></code></dd> |
| 27 | <dt>Latest Version</dt> |
| 28 | <dd><code class="URI"><<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc" |
| 29 | >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc</a>></code></dd> |
| 30 | <dt>Latest Working Draft</dt> |
| 31 | <dd><code class="URI"><<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work" |
| 32 | >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work</a>></code></dd> |
| 33 | <!-- <dt>Previous Version</dt> --> |
| 34 | <dt>Version History</dt> |
| 35 | <dd><code class=URI><<a href="http://suika.fam.cx/gate/cvs/markup/xml/xmlcc/xmlcc-work.en.html">http://suika.fam.cx/gate/cvs/markup/xml/xmlcc/xmlcc-work.en.html</a>></code></dd> |
| 36 | </dl> |
| 37 | <dl class="authors" id="author"> |
| 38 | <dt>Author</dt> |
| 39 | <dd><a href="http://suika.fam.cx/~wakaba/who?" rel="author" |
| 40 | lang=ja>Wakaba</a> |
| 41 | <code class="mail"><<a href="mailto:[email protected]" rel="author" |
| 42 | >[email protected]</a>></code></dd> |
| 43 | </dl> |
| 44 | |
| 45 | <p class="copyright" lang="en">© <time>2007</time>$B!>(B<time>2008</time> <a |
| 46 | href="http://suika.fam.cx/~wakaba/who?" rel="author">Wakaba</a>. |
| 47 | Permission is granted to copy, distribute and/or modify this document |
| 48 | under the terms of the <a rel="license" |
| 49 | href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>, |
| 50 | Version 1.2 |
| 51 | or any later version published by the <a |
| 52 | href="http://www.fsf.org/">Free Software Foundation</a>; |
| 53 | with no Invariant Sections, no Front$B!>(BCover Texts, and no Back$B!>(BCover |
| 54 | Texts. A copy of the license is |
| 55 | available at <code class="URI"><<a |
| 56 | href="http://www.gnu.org/copyleft/fdl.html" |
| 57 | rel="license">http://www.gnu.org/copyleft/fdl.html</a>></code>.</p> |
| 58 | </div> |
| 59 | |
| 60 | <div id="abstract" class="section"> |
| 61 | <h2>Abstract</h2> |
| 62 | |
| 63 | <div class="ed issue">...</div> |
| 64 | |
| 65 | </div> |
| 66 | |
| 67 | <div id="status" class="section"> |
| 68 | <h2>Status of This Document</h2> |
| 69 | |
| 70 | <p class=section-info><em>This section describes the status of this document |
| 71 | at the time of its publication. Other documents |
| 72 | might supersede this document.</em></p> |
| 73 | |
| 74 | <p>This document is a working draft, produced as part of the |
| 75 | <a href="http://suika.fam.cx/www/markup/html/whatpm/readme">Whatpm</a> |
| 76 | subproject of the |
| 77 | <a href="http://suika.fam.cx/www/manakai-core/doc/web/">manakai</a> |
| 78 | project. It might be updated, replaced, or obsoleted by |
| 79 | other documents at any time. It is inappropriate to |
| 80 | cite this document as other than <q>work in progress</q>.</p> |
| 81 | |
| 82 | <p>Comments on this document are welcome and |
| 83 | may be sent to the <a href="#author">author</a>.</p> |
| 84 | |
| 85 | <p>Translations of thie document might be available. |
| 86 | The English version of the document is the only |
| 87 | normative version.</p> |
| 88 | </div> |
| 89 | |
| 90 | <div id="introduction" class="section"> |
| 91 | <h2>Introduction</h2> |
| 92 | |
| 93 | <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
| 94 | |
| 95 | <div class="issue ed">... |
| 96 | |
| 97 | <p>Much of invalid (well-formed or not) XML document parsing and XML document |
| 98 | / XML DOM conformance is left undefined so that this document provides a |
| 99 | guideline for conformance checkers. |
| 100 | </div> |
| 101 | |
| 102 | |
| 103 | </div> |
| 104 | |
| 105 | <div class="section" id="terminology"> |
| 106 | <h2>Terminology</h2> |
| 107 | |
| 108 | <p>The key words <q><em class="rfc2119">MUST</em></q>, |
| 109 | <q><em class="rfc2119">MUST NOT</em></q>, |
| 110 | <q><em class="rfc2119">SHOULD</em></q>, |
| 111 | <q><em class="rfc2119">SHOULD NOT</em></q>, and |
| 112 | <q><em class=rfc2119>MAY</em></q> in this |
| 113 | document are to be interpreted as described in |
| 114 | <a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr> |
| 115 | 2119</a> |
| 116 | <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p> |
| 117 | |
| 118 | <!-- Strictly speaking the paragraph below is not part of terminology. --> |
| 119 | <p>All examples and notes in this specification are non$B!>(Bnormative, |
| 120 | as are all sections explicitly marked non$B!>(Bnormative. Everything |
| 121 | else in this specification is normative.</p> |
| 122 | |
| 123 | <p><span class=ed>Algorithm is normative but non-normative</span>. |
| 124 | In addition, the order in which <a href="#errors">errors</a> are |
| 125 | raised is undefined.</p> |
| 126 | |
| 127 | <p>This document sometimes cites parts of <abbr>XML</abbr> 1.0 specification |
| 128 | by hyperlinks. When the document being processed is an <abbr>XML</abbr> 1.1 |
| 129 | document, however, corresponding parts of the <abbr>XML</abbr> 1.1 |
| 130 | specification should be consulted instead.</p> |
| 131 | </div> |
| 132 | |
| 133 | |
| 134 | <div class=section id=error-categories> |
| 135 | <h2>Error Classification</h2> |
| 136 | |
| 137 | <p class=ed>If a <code>Document</code> node has no |
| 138 | xml-well-formedness-error, entity-error, and unknown-error, |
| 139 | then it is well-formed. If a well-formed <code>Document</code> |
| 140 | node has no xml-validity-error, it is valid.</p> |
| 141 | |
| 142 | <div class="note memo"> |
| 143 | <p>A well$B!>(Bformed <code>Document</code> can be safely serialized |
| 144 | into a well$B!>(Bformed XML document. A valid <code>Document</code> |
| 145 | can be easily serialized into a valid XML document.</p> |
| 146 | </div> |
| 147 | |
| 148 | <p class=ed>To be a conforming <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-validating">validating XML processor</a>, |
| 149 | ...</p> |
| 150 | |
| 151 | <p>Errors are classified into these |
| 152 | <dfn id=error-category title="error category">error categories</dfn>:</p> |
| 153 | |
| 154 | <dl id=errors> |
| 155 | <dt><dfn id=entity-error><code>entity-error</code></dfn></dt> |
| 156 | <dd> |
| 157 | <p class=ed>@@</p> |
| 158 | <div class="note memo"> |
| 159 | <p>This <span class=ed>algorithm</span> does not support |
| 160 | <abbr>DOM</abbr> tree with one or more <code>EntityReference</code> |
| 161 | nodes. It is expected that any entity references are expanded |
| 162 | at the parse time and any unexpandable entity references |
| 163 | make parse time errors raised so that never result in |
| 164 | <abbr>DOM</abbr> tree with <code>EntityReference</code> nodes.</p> |
| 165 | </div> |
| 166 | </dd> |
| 167 | <dt><dfn id=round-trip-error><code>round-trip-error</code></dfn></dt> |
| 168 | <dd class=ed>@@</dd> |
| 169 | <dt><dfn id=round-trip-warning><code>round-trip-warning</code></dfn></dt> |
| 170 | <dd> |
| 171 | <p>A <a href="#round-trip-warning"><code>round-trip-warning</code></a> |
| 172 | will be raised when a construct, which might not be restored to the same |
| 173 | construct when it is serialized and then re-parsed by a conforming |
| 174 | processor, is encountered.</p> |
| 175 | <div class="example memo"> |
| 176 | <p>For a <code>Comment</code> node a |
| 177 | <a href="#round-trip-warning"><code>round-trip-warning</code></a> will |
| 178 | be raised, since <abbr>XML</abbr> processors are not required to |
| 179 | report texts of comments for applications.</p> |
| 180 | </div> |
| 181 | </dd> |
| 182 | <dt class=ed><dfn id=unknown-error><code>unknown-error</code></dfn>?</dt> |
| 183 | <dd class=ed>@@</dd> |
| 184 | <dt><dfn id=xml-misc-error><code>xml-misc-error</code></dt> |
| 185 | <dd>An <abbr>XML</abbr> <i>error</i> (<abbr>XML</abbr> 1.0 |
| 186 | <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite> |
| 187 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-error">error</a> / |
| 188 | <abbr>XML</abbr> 1.1 |
| 189 | <cite class="bibref normative">[<a href="#ref-XML11">XML11</a>]</cite> |
| 190 | <a href="@@/#dt-error">error</a>) |
| 191 | that is not classified to any other <a href="#error-category">error |
| 192 | category</a>.</dd> |
| 193 | <dt><dfn id=xml-misc-fatal-error><code>xml-misc-fatal-error</code></dt> |
| 194 | <dd>An <abbr>XML</abbr> <i>fatal error</i> (<abbr>XML</abbr> 1.0 |
| 195 | <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite> |
| 196 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-fatal">fatal |
| 197 | error</a> / <abbr>XML</abbr> 1.1 |
| 198 | <cite class="bibref normative">[<a href="#ref-XML11">XML11</a>]</cite> |
| 199 | <a href="@@/#dt-fatal">fatal error</a>) |
| 200 | that is not classified to any other <a href="#error-category">error |
| 201 | category</a>. <span class=ed>@@ What errors fall into this category?</span></dd> |
| 202 | <dt><dfn id=xml-misc-recommendation><code>xml-misc-recommendation</code></dfn></dt> |
| 203 | <dd> |
| 204 | <p>An |
| 205 | <a href="#xml-misc-recommendation"><code>xml-misc-recommendation</code></a> |
| 206 | will be raised if a <em class=rfc2119>SHOULD</em>$B!>(Blevel requirement |
| 207 | in <abbr>XML</abbr> specification is not met.</p> |
| 208 | </dd> |
| 209 | <dt><dfn id=xml-validity-error><code>xml-validity-error</code></dfn></dt> |
| 210 | <dd>A violation of validity constraint in XML document.</dd> |
| 211 | <dt><dfn id=xml-well-formedness-error><code>xml-well-formedness-error</code></dfn></dt> |
| 212 | <dd><p>If an <code>xml-well-formedness-error</code> is raised, |
| 213 | it would not be possible to generate an XML serialization that |
| 214 | would match to the appropriate production rule and that would not |
| 215 | violate to any well$B!>(Bformedness constraint in XML |
| 216 | specification <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>, |
| 217 | <a href="#ref-XML11">XML11</a>]</cite>.</p></dd> |
| 218 | <dt><dfn id=misc-info><code>misc-info</code></dfn> |
| 219 | <dd><p>A <code>misc-info</code> is raised when some status information |
| 220 | on parsing or checking process that are considered useful for debugging |
| 221 | and so on is available. It by no means implies the non-conformance of |
| 222 | the document. |
| 223 | </dl> |
| 224 | |
| 225 | <div class=ed><p>@@ TODO: #dt-atuseroption at user option |
| 226 | (MAY or MUST), #dt-compat for compatibility, |
| 227 | #dt-interop for interoperability</p> |
| 228 | |
| 229 | <p>TODO: XML 1.1, XML Namespace 1.0/1.1, xml:base, xml:id |
| 230 | |
| 231 | <p>TODO: XML "error"/"fatal error" is not always non-conforming (only |
| 232 | when MUST or SHOULD). |
| 233 | </div> |
| 234 | |
| 235 | <p>The parser <em class=rfc2119>MAY</em> continue the parsing of the document |
| 236 | even after a fatal error (as defined by the relavant specification) is |
| 237 | encountered. How the parsing ought to be continued is not defined by this |
| 238 | specification. |
| 239 | |
| 240 | <div class="note memo informative"> |
| 241 | <p>It is expected that the XML5 specification <span class=ed>@@ ref</span> |
| 242 | will define how the parser has to convert any string into DOM tree |
| 243 | completely. |
| 244 | </div> |
| 245 | |
| 246 | </div> |
| 247 | |
| 248 | <div class=section id=parsing-xml> |
| 249 | <h2>Parsing <abbr>XML</abbr> Document</h2> |
| 250 | |
| 251 | <p>When an <abbr>XML</abbr> document is parsed, the following clauses |
| 252 | are applied:</p> |
| 253 | <dl class=switch> |
| 254 | <dt>For each external entity (including the document entity and the external |
| 255 | subset entity, if any) |
| 256 | <dd>If there is a byte sequence that are not legal in the encoding in use, |
| 257 | then the parser <em class=rfc2119>MUST</em> raise an |
| 258 | <a href="#xml-misc-error" id=xme-illegal-bytes><code>xml-misc-error</code></a>. |
| 259 | <!-- |
| 260 | <q>It is a fatal error when an XML processor encounters an entity with an |
| 261 | encoding that it is unable to process. It is a fatal error if an XML |
| 262 | entity is determined (via default, encoding declaration, or higher-level |
| 263 | protocol) to be in a certain encoding but contains byte sequences that are |
| 264 | not legal in that encoding.</q> |
| 265 | --> |
| 266 | |
| 267 | <dd>If it is the document entity or a general entity, then: |
| 268 | <ul> |
| 269 | <li>If the input byte sequence for the entity begins with the |
| 270 | <abbr title="BYTE ORDER MARK" class=charname>BOM</abbr>, then the parser |
| 271 | <em class=rfc2119>MUST</em> set the <span class=ed>BOM flag</span> of |
| 272 | the node corresponding to the entity (the <code>Document</code> node |
| 273 | for the document entity or an <code>Entity</code> node for a general |
| 274 | entity) to <code>true</code>. |
| 275 | <!-- |
| 276 | <q>Entities encoded in UTF-16 MUST and entities encoded in UTF-8 MAY |
| 277 | begin with the Byte Order Mark</q> |
| 278 | --> |
| 279 | <span class=ed>@@ flag must be checked later</span> |
| 280 | <!-- <?xml encoding=""?> must be reflected to xmlEncoding; this should be |
| 281 | enforced by DOM Core spec. --> |
| 282 | </ul> |
| 283 | <dd>If it is a parameter entity or the external subset entity, then: |
| 284 | <ul> |
| 285 | <li>If the character encoding of the entity is <code>UTF-16</code> but |
| 286 | the input byte stream for the entity does not begin with the |
| 287 | <abbr title="BYTE ORDER MARK" class=charname>BOM</abbr>, then the parser |
| 288 | <em class=rfc2119>MUST</em> raise an |
| 289 | <a href="#xml-misc-error" id=xme-pe-bom><code>xml-misc-error</code></a>. |
| 290 | <li class=ed>@@ encoding="" preferred name? |
| 291 | <!-- |
| 292 | "In an encoding declaration, the values "UTF-8", "UTF-16", "ISO-10646-UCS-2", and "ISO-10646-UCS-4" SHOULD be used for the various encodings and transformations of Unicode / ISO/IEC 10646, the values "ISO-8859-1", "ISO-8859-2", ... "ISO-8859-n" (where n is the part number) SHOULD be used for the parts of ISO 8859, and the values "ISO-2022-JP", "Shift_JIS", and "EUC-JP" SHOULD be used for the various encoded forms of JIS X-0208-1997. It is RECOMMENDED that character encodings registered (as charsets) with the Internet Assigned Numbers Authority [IANA-CHARSETS], other than those just listed, be referred to using their registered names; other encodings SHOULD use names starting with an "x-" prefix." |
| 293 | |
| 294 | In addition, this should be checked later for Document and Entity nodes. |
| 295 | --> |
| 296 | </ul> |
| 297 | |
| 298 | <dt>For the document |
| 299 | <dd>If the <abbr>XML</abbr> document does not begin with an |
| 300 | <abbr>XML</abbr> declaration, then the parser <em class=rfc2119>MUST</em> |
| 301 | raise an |
| 302 | <a href="#xml-misc-recommentation" id=xmr-xml-decl><code>xml-misc-recommendation</code></a>. |
| 303 | <dd>If the document does not contain the document type declaration, or |
| 304 | if it does but the document type definition does not contain entity |
| 305 | declaration for any of <code>amp</code>, <code>lt</code>, <code>gt</code>, |
| 306 | <code>apos</code>, or <code>quot</code>, then the parser |
| 307 | <em class=rfc2119>MUST</em> raise |
| 308 | <a href="#xml-misc-recommentation" id=xmr-predefined-decl><code>xml-misc-recommendation</code></a>(s). |
| 309 | <!-- |
| 310 | <q>For interoperability, valid documents SHOULD declare the entities |
| 311 | amp, lt, gt, apos, quot, in the form specified in 4.6 Predefined |
| 312 | Entities.</q> |
| 313 | --> |
| 314 | <dt>For the document type declaration |
| 315 | <dd class=ed>@@ read external entity |
| 316 | <dd>The <code>entities</code> attribute of the <code>DocumentType</code> |
| 317 | node <em class=rfc2119>MUST</em> contain a <code>NamedNodeMap</code> object |
| 318 | whose first five items are as follows: |
| 319 | <ol start=0> |
| 320 | <li>An <code>Entity</code> node whose <code>nodeName</code> attribute |
| 321 | is <code>amp</code>. It contains a <code>Text</code> node whose |
| 322 | <code>data</code> attribute is set to <code>&</code>. |
| 323 | <li>An <code>Entity</code> node whose <code>nodeName</code> attribute |
| 324 | is <code>lt</code>. It contains a <code>Text</code> node whose |
| 325 | <code>data</code> attribute is set to <code><</code>. |
| 326 | <li>An <code>Entity</code> node whose <code>nodeName</code> attribute |
| 327 | is <code>gt</code>. It contains a <code>Text</code> node whose |
| 328 | <code>data</code> attribute is set to <code>></code>. |
| 329 | <li>An <code>Entity</code> node whose <code>nodeName</code> attribute |
| 330 | is <code>quot</code>. It contains a <code>Text</code> node whose |
| 331 | <code>data</code> attribute is set to <code>"</code>. |
| 332 | <li>An <code>Entity</code> node whose <code>nodeName</code> attribute |
| 333 | is <code>apos</code>. It contains a <code>Text</code> node whose |
| 334 | <code>data</code> attribute is set to <code>'</code>. |
| 335 | </ol> |
| 336 | <dt>For each internal general entity declaration being processed by the parser |
| 337 | <dd>If the |
| 338 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-EntityValue"><code>EntityValue</code></a> |
| 339 | part of the general entity declaration contains a bare <code>U+003C</code> |
| 340 | <code>LESS-THAN SIGN</code> (<code><</code>) character, then the parser |
| 341 | <em class=rfc2119>MUST</em> raise an |
| 342 | <a href="#xml-misc-warning" id=xmw-entity-value-lt><code>xml-misc-warning</code></a>.<!-- |
| 343 | "strongly advised to avoid" in a Note in Section 2.3 of [XML10], [XML11]. |
| 344 | --> |
| 345 | <dt>For each element type declaration being processed by the parser |
| 346 | <dd>If there is another processed element type declaration whose |
| 347 | <code>Name</code> is equal to the <code>Name</code> of the element type |
| 348 | declaration, then the parser <em class=rfc2119>MUST</em> raise an |
| 349 | <a href="#xml-validity-error" id=vc-edunique><code>xml-validity-error</code></a>. |
| 350 | <dt>For each attribute definition list declaration being processed by the |
| 351 | parser |
| 352 | <dd>If there is another processed attribute defintion list declaration whose |
| 353 | <code>Name</code> is equal to the <code>Name</code> of the attribute |
| 354 | definition list declaration, then the parser <em class=rfc2119>MUST</em> |
| 355 | raise an |
| 356 | <a href="#xml-misc-warning" id=xme-attlist-unique><code>xml-misc-warning</code></a>. |
| 357 | <dd>For each attribute definition in the attribute definition list |
| 358 | declaration, if there is another processed attribute definition whose |
| 359 | <code>Name</code> is equal to the <code>Name</code> of the attribute |
| 360 | definition (whether or not in the same attribute definition list |
| 361 | declaration), then the parser <em class=rfc2119>MUST</em> raise an |
| 362 | <a href="#xml-misc-warning" id=xme-attrdef-unique><code>xml-misc-warning</code></a>. |
| 363 | <!-- |
| 364 | <q>For interoperability, an XML processor <em class=rfc2119>MAY</em> at |
| 365 | user option issue a warning when more than one attribute-list declaration |
| 366 | is provided for a given element type, or more than one attribute definition |
| 367 | is provided for a given attribute, but this is not an error.</q> |
| 368 | --> |
| 369 | <!-- |
| 370 | NOTE: <!ATTLIST a xml:space (default) #IMPLIED xml:space CDATA #IMPLIED> |
| 371 | will not be warned. |
| 372 | --> |
| 373 | |
| 374 | <dt>For each entity declaration being processed by the parser |
| 375 | <dd>Handle as follows: |
| 376 | <ol> |
| 377 | <li><p>If the entity declaration declares a general entity, the following |
| 378 | is applied: |
| 379 | <dl> |
| 380 | <dt>If the <code>Name</code> is <code>lt</code> or <code>amp</code> |
| 381 | <dd><p>If the entity declaration does not declare an internal entity, |
| 382 | or if the replacement text of the entity is not the escaped form of |
| 383 | <code><</code> (if <code>lt</code>) or <code>&</code> (if |
| 384 | <code>amp</code>), then the parser <em class=rfc2119>MUST</em> raise an |
| 385 | <a href="#xml-misc-error" id=xme-double-escape><code>xml-misc-error</code></a>. |
| 386 | |
| 387 | <div class="note memo informative"> |
| 388 | <p>In other word, the character in the <code>EntityValue</code> |
| 389 | has to be double-escaped. |
| 390 | </div> |
| 391 | <dt>If the <code>Name</code> is <code>gt</code>, <code>quot</code>, or |
| 392 | <code>apos</code> |
| 393 | <dd><p>If the entity declaration does not declare an internal entity, |
| 394 | or if the replacement text of the entity is not equal to or not the |
| 395 | escaped form of <code>></code> (if <code>gt</code>), <code>"</code> (if |
| 396 | <code>quot</code>), or <code>'</code> (if <code>apos</code>), then the |
| 397 | parser <em class=rfc2119>MUST</em> raise an |
| 398 | <a href="#xml-misc-error" id=xme-single-escape><code>xml-misc-error</code></a>. |
| 399 | |
| 400 | <div class="note memo informative"> |
| 401 | <p>In other word, the character in the <code>EntityValue</code> |
| 402 | has to be single- or double-escaped. |
| 403 | </div> |
| 404 | </dl> |
| 405 | <!-- |
| 406 | <q>If the entities lt or amp are declared, they MUST be declared as internal entities whose replacement text is a character reference to the respective character (less-than sign or ampersand) being escaped; the double escaping is REQUIRED for these entities so that references to them produce a well-formed result. If the entities gt, apos, or quot are declared, they MUST be declared as internal entities whose replacement text is the single character being escaped (or a character reference to that character; the double escaping here is OPTIONAL but harmless).</q> |
| 407 | --> |
| 408 | |
| 409 | <li><p>If the entity declaration has to be ignored since there has already |
| 410 | been declared an entity with the same <code>Name</code> as the declaration, |
| 411 | then the parser <em class=rfc2119>MUST</em> raise a |
| 412 | <a href="#misc-info" id=mi-ent-unique><code>misc-info</code></a> |
| 413 | and abort these steps. |
| 414 | |
| 415 | <div class="informative note memo"> |
| 416 | <p>Five predefined entities, i.e. <code>amp</code>, <code>lt</code>, |
| 417 | <code>gt</code>, <code>quot</code>, and <code>apos</code>, are always |
| 418 | declared implicitly and therefore any declaration for such an entity |
| 419 | always raises an |
| 420 | <a href="#misc-info" id=mi-ent-unique><code>misc-info</code></a>. |
| 421 | </div> |
| 422 | |
| 423 | <li><p>If the entity declaration declares a parameter entity and the |
| 424 | <code>Name</code> of the entity begins with the string <code>xml</code> |
| 425 | (in any combination of upper- and lowercase letters), then the parser |
| 426 | <em class=rfc2119>MUST</em> raise an |
| 427 | <a href="#xml-misc-warning" id=xmw-reserved-pe-name><code>xml-misc-warning</code></a>. |
| 428 | |
| 429 | <li><p>If the entity declaration contains the <code>EntityValue</code>, |
| 430 | then for each occurence of any references to unparsed entities in the |
| 431 | <code>EntityValue</code>, the parser <em class=rfc2119>MUST</em> raise an |
| 432 | <a href="#xml-misc-error" id=xme-unparsed-in-ev><code>xml-misc-error</code></a>. |
| 433 | <!-- |
| 434 | <q>It is an error for a reference to an unparsed entity to appear in the |
| 435 | EntityValue in an entity declaration.</q> |
| 436 | --> |
| 437 | <li><p>If the entity declaration declares a general entity, then an |
| 438 | <code>Entity</code> node <em class=rfc2119>MUST</em> be created and |
| 439 | appended to the <code>NamedNodeMap</code> object in the |
| 440 | <code>entities</code> attribute of the <code>DocumentType</code> node. |
| 441 | |
| 442 | <p class=ed>Read the external entity |
| 443 | |
| 444 | <p>If the replacement text of the entity is read, then parse the |
| 445 | replacement text as if it were referenced from the content of an |
| 446 | element (with no namespace bindings). If no <span class=ed>@@ parse error</span> |
| 447 | is raised by the parsing process, then the nodes generated by the |
| 448 | parsing <em class=rfc2119>MUST</em> be appended to the <code>Entity</code> |
| 449 | node. The parse error <em class=rfc2119>MUST NOT</em> be propagated to |
| 450 | the entire parsing process. Other kinds of errors |
| 451 | <em class=rfc2119>MUST</em> be propagated. The first parse error |
| 452 | <em class=rfc2119>MUST</em> abort the internal parsing process. |
| 453 | <span class=ed>@@ better wording</span> |
| 454 | |
| 455 | <p class=ed>@@ prop |
| 456 | |
| 457 | <p>Then, the <code>Entity</code> node and its descendant |
| 458 | <em class=rfc2119>MUST</em> be marked as read-only. |
| 459 | </ol> |
| 460 | |
| 461 | <dt>For each notation declaration being processed by the parser |
| 462 | <dd>If there is another processed notation declaration whose |
| 463 | <code>Name</code> is equal to the <code>Name</code> of the notation |
| 464 | declaration, then the parser <em class=rfc2119>MUST</em> raise an |
| 465 | <a href="#xml-validity-error" id=vc-uniquenotationname><code>xml-validity-error</code></a>. |
| 466 | <!-- <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#UniqueNotationName">Validity constraint: Unique Notation Name</a> --> |
| 467 | |
| 468 | <dt>For each empty-element tag |
| 469 | <dd>If the <code>Name</code> of the tag is not declared by a processed |
| 470 | element type declaration as <code>EMPTY</code> content, then the parser |
| 471 | <em class=rfc2119>MUST</em> raise an |
| 472 | <a href="#xml-misc-recommentation" id=xmr-emptyelemtag-not-empty><code>xml-misc-recommendation</code></a>. |
| 473 | <dt>For each start-tag |
| 474 | <dd>If the <code>Name</code> of the tag is declared by a processed element |
| 475 | type declaration as <code>EMPTY</code> content, then the parser |
| 476 | <em class=rfc2119>MUST</em> raise an |
| 477 | <a href="#xml-misc-recommentation" id=xmr-empty-not-emptyelemtag><code>xml-misc-recommendation</code></a>. |
| 478 | <dt>For each attribute |
| 479 | <dd><p>The parser <em class=rfc2119>MUST</em> set the normalized value of |
| 480 | the attribute to the <code>value</code> attribute of the <code>Attr</code> |
| 481 | node created for the attribute. |
| 482 | |
| 483 | <div class="note memo informative"> |
| 484 | <p>That is, any entity reference has to be expanded. Unexpanded entity |
| 485 | references in attribute values are discarded. |
| 486 | </div> |
| 487 | <dt>For each <code>xml:space</code> attribute |
| 488 | <dd>The parser <em class=rfc2119>MUST</em> set the normalized value of |
| 489 | the <code>xml:space</code> attribute to the <code>value</code> attribute |
| 490 | of the <code>Attr</code> node created for the attribute even if the |
| 491 | normalized value is different from <code>default</code> or |
| 492 | <code>preserve</code>. |
| 493 | <!-- In XML 1.0/1.1 specification, the attribute specification MAY be |
| 494 | ignored. --> |
| 495 | |
| 496 | <dt>For each parameter entity reference |
| 497 | <dd>If the declaration for the entity is not read (i.e. no declaration |
| 498 | for the entity is processed or the external entity referenced by the |
| 499 | declaration cannot be retrieved), then: |
| 500 | <ul> |
| 501 | <li>If the parameter entity is contained in a declaration, then the |
| 502 | declaration <em class=rfc2119>MUST</em> be ignored <em>except</em> that |
| 503 | any error before the parameter entity <em class=rfc2119>MUST</em> be |
| 504 | raised as usual. |
| 505 | <li>If the parameter entity is contained in the status portion of a |
| 506 | conditional section, then the conditional section |
| 507 | <em class=rfc2119>MUST</em> be processed as if it were an |
| 508 | <code>IGNORE</code>d section. |
| 509 | <li>The parser <em class=rfc2119>MUST NOT</em> process any entity or |
| 510 | attribute-list declaration after the parameter entity reference in the DTD |
| 511 | <em>except</em> when the <code>standalone</code> pseudo-attribute of the |
| 512 | XML declaration (if any) is set to <code>yes</code>. |
| 513 | <!-- This requirement is enforced for internal DTD subset case in |
| 514 | XML 1.0/1.1 specification (section 5.1) but not for any other cases. --> |
| 515 | <!-- According to this definition, element type declarations, notation |
| 516 | declarations, and PIs ARE processed. --> |
| 517 | <li>If the parameter entity reference is the first reference to an entity |
| 518 | that is not read, then the parser <em class=rfc2119>MUST</em> raise an |
| 519 | <a href="#entity-error" id=ee-unread-pe><code>entity-error</code></a>. |
| 520 | <li>The <code>allDeclarationsProcessed</code> <span class=ed>@@ ref</span> |
| 521 | attribute of the <code>Document</code> node <em class=rfc2119>MUST</em> be |
| 522 | set to <code>false</code>. |
| 523 | </ul> |
| 524 | <dt>For each general entity reference in an attribute value or in the content |
| 525 | of an element |
| 526 | <dd>If the declaration for the entity is not read (i.e. no declaration for |
| 527 | the entity is processed or the external entity referenced by the declaration |
| 528 | cannot be retrieved), then: |
| 529 | <ul> |
| 530 | <li>If the general entity reference is the first reference to an entity |
| 531 | that is not read, then the parser <em class=rfc2119>MUST</em> raise an |
| 532 | <a href="#entity-error" id=ee-unread-ge><code>entity-error</code></a>. |
| 533 | <span class=ed>@@ entity declared WFC?</span> |
| 534 | <li class=ed>An unexpended entity reference node <em class=rfc2119>MUST</em> be inserted to the current node. |
| 535 | </ul> |
| 536 | |
| 537 | <dt>For each comment <em>outside</em> of document type declaration |
| 538 | <dd>A <code>Comment</code> node <em class=rfc2119>MUST</em> be created |
| 539 | and inserted appropriately. |
| 540 | <!-- In XML 1.0/1.1 spec, this is optional. --> |
| 541 | </dl> |
| 542 | |
| 543 | <p class=ed>@@ MUST try to read external entity |
| 544 | |
| 545 | <p>In addition, the parser has to check whether the |
| 546 | following constraints are met. |
| 547 | |
| 548 | <p><strong>Well-formedness constraints</strong>. For each violation to |
| 549 | one of constraints below, an |
| 550 | <a href="#xml-well-formedness-error"><code>xml-well-formedness-error</code></a> |
| 551 | <em class=rfc2119>MUST</em> be raised. The list of well-formedness |
| 552 | constraints is below: |
| 553 | <ul> |
| 554 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#wfc-PEinInternalSubset">Well-formedness constraint: PEs in Internal Subset</a> |
| 555 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#GIMatch">Well-formedness constraint: Element Type Match</a> |
| 556 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#uniqattspec">Well-formedness constraint: Unique Att Spec</a> |
| 557 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NoExternalRefs">Well-formedness constraint: No External Entity References</a> |
| 558 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#CleanAttrVals">Well-formedness constraint: No < in Attribute Values</a> |
| 559 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#wf-Legalchar">Well-formedness constraint: Legal Character</a> |
| 560 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#textent">Well-formedness constraint: Parsed Entity</a> |
| 561 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#norecursion">Well-formedness constraint: No Recursion</a> |
| 562 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#indtd">Well-formedness constraint: In DTD</a> |
| 563 | </ul> |
| 564 | |
| 565 | <p><strong>Validity constraints</strong>. For each violation to |
| 566 | one of constraints below, an |
| 567 | <a href="#xml-validity-error"><code>xml-validity-error</code></a>. |
| 568 | <em class=rfc2119>MUST</em> be raised. The list of validity |
| 569 | constraints is below: |
| 570 | <ul> |
| 571 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#vc-PEinMarkupDecl">Validity constraint: Proper Declaration/PE Nesting</a> |
| 572 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#vc-PEinGroup">Validity constraint: Proper Group/PE Nesting</a> |
| 573 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#condsec-nesting">Validity constraint: Proper Conditional Section/PE Nesting</a> |
| 574 | </ul> |
| 575 | |
| 576 | <p><strong>Other creteria</strong>. For each violation to |
| 577 | one of constraints below, an |
| 578 | <a href="#xml-misc-recommendation"><code>xml-misc-recommendation</code></a> |
| 579 | <em class=rfc2119>MUST</em> be raised. The list of constraints is below: |
| 580 | <ul> |
| 581 | <li><q>For interoperability, if a parameter-entity reference appears in a |
| 582 | <code>choice</code>, <code>seq</code>, or <code>Mixed</code> construct, its |
| 583 | replacement text <em class=rfc2119>SHOULD</em> contain at least one non-blank |
| 584 | character, and neither the first nor last non-blank character of the |
| 585 | replacement text <em class=rfc2119>SHOULD</em> be a connector (<code>|</code> |
| 586 | or <code>,</code>).</q> |
| 587 | <li><q>External parsed entities <em class=rfc2119>SHOULD</em> each begin with a |
| 588 | text declaration.</q> |
| 589 | </ul> |
| 590 | |
| 591 | |
| 592 | <!-- |
| 593 | |
| 594 | @@ Need detailed review, but maybe should be in parsing phase |
| 595 | |
| 596 | #vc-check-rmd Validity constraint: Standalone Document Declaration |
| 597 | |
| 598 | @@ Need dtailed review |
| 599 | |
| 600 | #wf-entdeclared Well-formedness constraint: Entity Declared |
| 601 | #vc-entdeclared Validity constraint: Entity Declared |
| 602 | |
| 603 | --> |
| 604 | |
| 605 | <p>The parser <em class=rfc2119>MUST</em> act as if it is a |
| 606 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-validating">validating |
| 607 | XML processor</a> for the informing of white space appearing in |
| 608 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-elemcontent">element |
| 609 | content</a> (See |
| 610 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#sec-white-space">Section |
| 611 | 2.10</a> of the XML specification). |
| 612 | |
| 613 | <div class="note memo informative"> |
| 614 | <p>In other word, the <code>isElementContentWhitespace</code> attribute |
| 615 | of <code>Text</code> nodes has to be set appropriately. Note that the |
| 616 | value of the attribute will be set to <code>false</code> for any |
| 617 | <code>Text</code> node in the content of an element whose declaration |
| 618 | is not processed. |
| 619 | </div> |
| 620 | |
| 621 | <p>The parser <em class=rfc2119>MUST</em> raise an |
| 622 | <a href="#xml-well-formedness-error" id=wfe-syntax><code>xml-well-formedness-error</code></a> |
| 623 | for any failure to match to a production rule in the XML specification. |
| 624 | <!-- |
| 625 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#ExtSubset">Well-formedness constraint: External Subset</a> |
| 626 | <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#PE-between-Decls">Well-formedness constraint: PE Between Declarations</a> |
| 627 | --> |
| 628 | |
| 629 | <!-- |
| 630 | Inpossible to test: |
| 631 | "In the absence of external character encoding information (such as MIME |
| 632 | headers), parsed entities which are stored in an encoding other than UTF-8 |
| 633 | or UTF-16 MUST begin with a text declaration" |
| 634 | --> |
| 635 | </div> |
| 636 | |
| 637 | <div class="section" id=checking-dom> |
| 638 | <h2>Checking <abbr>DOM</abbr></h2> |
| 639 | |
| 640 | <p>The following algorithms and definitions are applied to |
| 641 | <abbr>XML</abbr> documents; especially, they are not applied |
| 642 | to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p> |
| 643 | |
| 644 | <div class=section id=definitions> |
| 645 | <h3>Definitions</h3> |
| 646 | |
| 647 | <p>The <dfn id=xml-version><abbr>XML</abbr> version</dfn> of a node is |
| 648 | the <abbr>XML</abbr> version of the document to which the node belongs. |
| 649 | For a <code>Documemt</code> node, the <abbr>XML</abbr> version |
| 650 | of the document is the value of the <code>xmlVersion</code> |
| 651 | attribute of the node. For a <code>DocumentType</code> node whose |
| 652 | <code>ownerDocument</code> attribute is set to <code>null</code>, |
| 653 | the <abbr>XML</abbr> version of the document is <code>1.0</code><!-- |
| 654 | since createDocumentType [DOM3CORE] assumes XML 1.0 [XML10TE] -->. |
| 655 | For any other node, the <abbr>XML</abbr> version of the document |
| 656 | is that of the <code>Document</code> node contained in the |
| 657 | <code>ownerDocument</code> attribute of the node.</p> |
| 658 | |
| 659 | </div> |
| 660 | |
| 661 | |
| 662 | <div class=section id=checking-components> |
| 663 | <h3>Conformance Checking Algorithms for Components</h3> |
| 664 | |
| 665 | <p>To |
| 666 | <dfn id=algorithm-to-validate-an-xml-character-data title="validate an XML string">to |
| 667 | validate an <abbr>XML</abbr> string (<dfn id=var-s><var>s</var></dfn>)</dfn>, |
| 668 | the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
| 669 | <ol> |
| 670 | <li>If <var>s</var> contains a character that is <em>not</em> in |
| 671 | the character class <a href="#class-Char10"><code>Char10</code></a>, |
| 672 | then raise an |
| 673 | <a href="#xml-well-formedness-error" id=wfe-illegal-char><code>xml-well-formedness-error</code></a>.</li> |
| 674 | <li>If <var>s</var> contains a character that is in the character |
| 675 | class <a href="#class-CompatChar10"><code>CompatChar10</code></a>, |
| 676 | then raise an |
| 677 | <a href="#xml-misc-warning" id=xmw-compat-char><code>xml-misc-warning</code></a>.</li> |
| 678 | <li>If <var>s</var> contains a character that is in the character |
| 679 | class <a href="#class-ControlChar10"><code>ControlChar10</code></a>, |
| 680 | then raise an |
| 681 | <a href="#xml-misc-warning" id=xmw-control-char><code>xml-misc-warning</code></a>.</li> |
| 682 | <li class=ed>@@ XML 1.1 support</li> |
| 683 | <li>If <var>s</var> contains a <code class=char>U+000D</code> |
| 684 | <code class=charname>CARRIAGE RETURN</code> character, then |
| 685 | raise a |
| 686 | <a href="#round-trip-error" id=rte-cr><code>round-trip-error</code></a>. |
| 687 | <span class=ed>@@ We should not raise duplicate errors for U+000D |
| 688 | in attribute values. In addition, we should support a mode where |
| 689 | U+000D will be serialized as 
 (so that no round-trip-error |
| 690 | will be raised).</span></li> |
| 691 | </ol> |
| 692 | |
| 693 | <p>To |
| 694 | <dfn id=algorithm-to-validate-a-name title="validate a Name">validate a |
| 695 | <code>Name</code> (<dfn id=var-name-s><var>s</var></dfn>)</dfn>, the following |
| 696 | algorithm <em class=rfc2119>MUST</em> be used:</p> |
| 697 | <ol> |
| 698 | <li>If <var>s</var> is an empty string, then raise an |
| 699 | <a href="#xml-well-formedness-error" id=wfe-name-empty><code>xml-well-formedness-error</code></a>. |
| 700 | Abort these steps.</li> |
| 701 | <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate |
| 702 | <var>s</var> as an <abbr>XML</abbr> string</a>.</li> |
| 703 | <li>If the first character in <var>s</var> is a character that is |
| 704 | <em>not</em> in the character class |
| 705 | <a href="#class-NameStartChar10"><code>NameStartChar10</code></a>, then raise |
| 706 | an |
| 707 | <a href="#xml-well-formedness-error" id=wfe-name-startchar><code>xml-well-formedness-error</code></a>.</li> |
| 708 | <li>If a character other than the first character in <var>s</var> is a |
| 709 | character that is <em>not</em> in the character class |
| 710 | <a href="#class-NameChar10"><code>NameChar10</code></a>, then raise an |
| 711 | <a href="#xml-well-formedness-error" id=wfe-name-char><code>xml-well-formedness-error</code></a>.</li> |
| 712 | <li>If <var>s</var> begins with the string <code>xml</code> (in any |
| 713 | case combination), then raise an |
| 714 | <a href="#xml-misc-warning" id=xmw-reserved-name><code>xml-misc-warning</code></a>. |
| 715 | <span class=ed>@@ except for attribute names <code>xml:lang</code>, |
| 716 | <code>xml:space</code><!--, <code>xml:base</code>, <code>xml:id</code>, |
| 717 | <code>xmlns</code>, <code>xmlns:<var>*</var></code>, |
| 718 | pi name <code>xml-stylesheet</code>-->.</span><!-- |
| 719 | "names beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) are reserved for standardization in this or future versions of this specification.": |
| 720 | xmlns, xml-stylesheet, xml:base and xml:id specifications violate to this sentense! |
| 721 | --></li> |
| 722 | <!-- COLON in Name is a lowercase "should not" in a Note of [XML10], |
| 723 | [XML11]. --> |
| 724 | <li class=ed>@@ XML 1.1 support</li> |
| 725 | </ol> |
| 726 | |
| 727 | <p>To |
| 728 | <dfn id=algorithm-to-validate-an-ncname title="validate an NCName">validate |
| 729 | an <code>NCName</code> (<dfn id=var-ncname-s><var>s</var></dfn>)</dfn>, the |
| 730 | following algorithm <em class=rfc2119>MUST</em> be used:</p> |
| 731 | <ol> |
| 732 | <li><a href="#algorithm-to-validate-a-name" title="validate a Name">Validate |
| 733 | <var>s</var> as a <code>Name</code></a>.</li> |
| 734 | <li class=ed>@@</li> |
| 735 | </ol> |
| 736 | |
| 737 | <p>To |
| 738 | <dfn id=algorithm-to-validate-a-public-identifier title="validate a public identifier">validate |
| 739 | a public identifier (<dfn id=var-pid><var>pid</var></dfn>)</dfn>, the |
| 740 | following algorithm <em class=rfc2119>MUST</em> be used:</p> |
| 741 | <ol> |
| 742 | <li>If <var>pid</var> is <code>null</code>, abort these steps.</li> |
| 743 | <li>If <var>pid</var> contains a character that is <em>not</em> in the |
| 744 | character class <a href="#class-PubidChar"><code>PubidChar</code></a>, then |
| 745 | raise an |
| 746 | <a href="#xml-well-formedness-error" id=wfe-pubid-char><code>xml-well-formedness-error</code></a>.</li> |
| 747 | <li>If <var>pid</var> contains one of <code class=char>U+0009</code> |
| 748 | <code class=charname>CHARACTER TABULATION</code>, |
| 749 | <code class=char>U+000A</code> <code class=charname>CARRIAGE RETURN</code>, |
| 750 | and <code class=char>U+000D</code> <code class=charname>LINE FEED</code> |
| 751 | characters, if the first character of <var>pid</var> is |
| 752 | <code class=char>U+0020</code> <code class=charname>SPACE</code> character, |
| 753 | if the last character of <var>pid</var> is <code class=char>U+0020</code> |
| 754 | <code class=charname>SPACE</code> character, or if there is a |
| 755 | <code class=char>U+0020</code> <code class=charname>SPACE</code> character |
| 756 | immediately followed by another <code class=char>U+0020</code> |
| 757 | <code class=charname>SPACE</code> character in <var>pid</var>, then it is a |
| 758 | <a href="#round-trip-error" id=rte-pubid-space><code>round-trip-error</code></a>. |
| 759 | <span class=ed>Is this really a roundtripness problem? XML spec |
| 760 | does only define the way to match public identifiers in fact, no |
| 761 | canonical form.</span></li> |
| 762 | </ol> |
| 763 | |
| 764 | <p>To |
| 765 | <dfn id=algorithm-to-validate-a-system-identifier title="validate a system identifier">validate |
| 766 | a system identifier (<dfn id=var-sid><var>sid</var></dfn>)</dfn>, the |
| 767 | following algorithm <em class=rfc2119>MUST</em> be used:</p> |
| 768 | <ol> |
| 769 | <li>If <var>sid</var> is <code>null</code>, abort these steps.</li> |
| 770 | <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate |
| 771 | <var>sid</var> as an <abbr>XML</abbr> string</a>.</li> |
| 772 | <li>If <var>sid</var> contains both <code class=char>U+0022</code> |
| 773 | <code class=charname>QUOTATION MARK</code> (<code class=char>"</code>) and |
| 774 | <code class=char>U+0027</code> <code class=charname>APOSTROPHE</code> |
| 775 | (<code class=char>'</code>) characters, raise an |
| 776 | <a href="#xml-well-formedness-error" id=wfe-sid-lit><code>xml-well-formedness-error</code></a>.</li> |
| 777 | <li>If <var>sid</var> contains at least one <code class=char>U+0023</code> |
| 778 | <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) |
| 779 | character, then raise an |
| 780 | <a href="#xml-misc-error" id=xme-sid-fragment><code>xml-misc-error</code></a>.</li> |
| 781 | <li class=ed>@@ If <var>sid</var> cannot be converted to a URI |
| 782 | reference, then raise a fact-level error (xml-misc-warning?).<!-- |
| 783 | XML 1.0 has no conformance language for system identifier being |
| 784 | a URI reference. --></li> |
| 785 | </ol> |
| 786 | |
| 787 | </div> |
| 788 | |
| 789 | <div class=section id=checking-node> |
| 790 | <h3>Checking <code>Node</code></h3> |
| 791 | |
| 792 | <p>The algorithm <dfn title="to check a node" id=algorithm-to-check-a-node>to |
| 793 | check a node (<dfn id=var-n><var>n</var></dfn>)</dfn> is defined as |
| 794 | following:</p> |
| 795 | <dl class=switch> |
| 796 | <dt>If <var>n</var> is an <code>Attr</code> node</dt> |
| 797 | <dd> |
| 798 | <ol> |
| 799 | <li><a href="#algorithm-to-validate-an-ncname">Validate the |
| 800 | <code>localName</code> attribute value as an <code>NCName</code></a>.</li> |
| 801 | <li>If the <code>prefix</code> attribute value is different from |
| 802 | <code>null</code>, then <a href="#algorithm-to-validate-an-ncname">validate |
| 803 | the <code>prefix</code> attribute value as an <code>NCName</code></a>.</li> |
| 804 | <li>For each node <dfn id=var-attr-nc><var>n<sub><var>c</var></sub></var></dfn> in the |
| 805 | <code>childNodes</code> list of <var>n</var>, |
| 806 | <ol> |
| 807 | <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a |
| 808 | <code>Text</code> or <code>EntityReference</code> node, then it is an |
| 809 | <a href="#xml-well-formedness-error" id=wfe-attr-child><code>xml-well-formedness-error</code></a>.</li> |
| 810 | <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an |
| 811 | <code>EntityReference</code> node, then it is an |
| 812 | <a href="#entity-error" id=ee-attr-er><code>entity-error</code></a>.</li> |
| 813 | <li>Otherwise, |
| 814 | <a href="#algorithm-to-check-a-node" title="check a node">check |
| 815 | <var>n<sub><var>c</var></sub></var></a> recusrively.</li> |
| 816 | </ol></li> |
| 817 | <li>If <code>nodeName</code> attribute of <var>n</var> is |
| 818 | <code>xml:space</code> <span class=ed>@@ or {xml namespace}:space ?</span> |
| 819 | and <code>value</code> attribute of <var>n</var> is neither |
| 820 | <code>default</code> nor <code>preserve</code>, then it is an |
| 821 | <a href="#xml-misc-error" id=xme-attr-xml-space><code>xml-misc-error</code></a>.<!-- |
| 822 | Note that <!ATTLIST e xml:space (default|preserve) "a">... |
| 823 | <e xml:space="default"/> is conforming and valid. --></li> |
| 824 | <li class=ed>@@ xml:lang value is not a language tag [RFC 3066 or its |
| 825 | successor] or an empty string, then xml-misc-warning |
| 826 | (a "fact"-level error; not an XML error).</li> |
| 827 | <li class=ed>@@ <code>specified</code>, |
| 828 | <code>manakaiAttributeType</code> (#ValueType Validity constraint: Attribute Value Type)</li> |
| 829 | <!-- xml:space MUST be declared to be valid. --> |
| 830 | <li>Let <dfn id=var-v><var>v</var></dfn> be the value of the |
| 831 | attribute <code>value</code> of <var>n</var>.</li> |
| 832 | <li>Validate the <var>n</var> against the <span class=ed>declared |
| 833 | type</span> as following: |
| 834 | <dl class=switch> |
| 835 | <dt class=ed><code>ID_ATTR</code></dt> |
| 836 | <dd> |
| 837 | <ol> |
| 838 | <li><span class=ed>Validate <var>v</var> as an |
| 839 | <code>Name</code>.</span> If it fails, then raise an |
| 840 | <a href="#xml-validity-error" id=vc-id-name><code>xml-validity-error</code></a>.</li> |
| 841 | <li><span class=ed>If <code>ID</code> <var>v</var> is defined,</span> |
| 842 | then raise an |
| 843 | <a href="#xml-validity-error" id=vc-id-duplication><code>xml-validity-error</code></a>.</li> |
| 844 | </ol> |
| 845 | </dd> |
| 846 | <dt class=ed>IDREF_ATTR</dt> |
| 847 | <dd> |
| 848 | <ol> |
| 849 | <li><span class=ed>Validate <var>v</var> as an |
| 850 | <code>Name</code>.</span> If it fails, then raise an |
| 851 | <a href="#xml-validity-error" id=vc-idref-name><code>xml-validity-error</code></a>.</li> |
| 852 | <li><span class=ed>If <code>ID</code> <var>v</var> is NOT |
| 853 | defined,</span> then raise an |
| 854 | <a href="#xml-validity-error" id=vc-idref-match><code>xml-validity-error</code></a>.</li> |
| 855 | </ol> |
| 856 | </dd> |
| 857 | <dt class=ed>IDREFS_ATTR</dt> |
| 858 | <dd class=ed>@@</dd> |
| 859 | <dt class=ed>ENTITY_ATTR</dt> |
| 860 | <dd> |
| 861 | <ol> |
| 862 | <li><span class=ed>Validate <var>v</var> as an |
| 863 | <code>Name</code>.</span> If it fails, then raise an |
| 864 | <a href="#xml-validity-error" id=vc-entname-name><code>xml-validity-error</code></a>.</li> |
| 865 | <li><span class=ed>If <code>Entity</code> <var>v</var> is NOT |
| 866 | defined,</span> then raise an |
| 867 | <a href="#xml-validity-error" id=vc-entname-match><code>xml-validity-error</code></a>.</li> |
| 868 | </ol> |
| 869 | </dd> |
| 870 | <dt class=ed>ENTITIES_ATTR</dt> |
| 871 | <dd class=ed>@@</dd> |
| 872 | <dt class=ed>NMTOKEN_ATTR</dt> |
| 873 | <dd> |
| 874 | <ol> |
| 875 | <li><span class=ed>Validate <var>v</var> as an |
| 876 | <code>Nmtoken</code>.</span> If it fails, then raise an |
| 877 | <a href="#xml-validity-error" id=vc-nmtok-name><code>xml-validity-error</code></a>.</li> |
| 878 | </ol> |
| 879 | </dd> |
| 880 | <dt class=ed>NMTOKENS_ATTR</dt> |
| 881 | <dd class=ed>@@</dd> |
| 882 | <dt class=ed>NOTATION_ATTR</dt> |
| 883 | <dd class=ed><var>v</var> must be one of enumerated values. |
| 884 | If not, then raise an |
| 885 | <a href="#xml-validity-error" id=vc-notatn-match><code>xml-validity-error</code></a>.</dd> |
| 886 | <dt class=ed>ENUMERATED_ATTR</dt> |
| 887 | <dd class=ed><var>v</var> must be one of enumerated values. |
| 888 | If not, then raise an |
| 889 | <a href="#xml-validity-error" id=vc-enum><code>xml-validity-error</code></a>.</dd> |
| 890 | <dt class=ed>@@</dt> |
| 891 | </dl> |
| 892 | </li> |
| 893 | <li>If <span class=ed>type ID and default is NOT #IMPLIED or #REQUIRED</span>, then |
| 894 | raise an |
| 895 | <a href="#xml-validity-error" id=vc-id-default><code>xml-validity-error</code></a>.</li> |
| 896 | <li class=ed>@@ #FixedAttr Validity constraint: Fixed Attribute Default</li> |
| 897 | <li class=ed>@@ strict serialization error for U+000D, U+000A, and |
| 898 | U+0009 characters, leading/trailing U+0020, and U+0020{2,} string?</li> |
| 899 | </ol> |
| 900 | </dd> |
| 901 | <dt>If <var>n</var> is an <code>AttributeDefinition</code> node</dt> |
| 902 | <dd> |
| 903 | <ol> |
| 904 | <li class=ed></li> |
| 905 | <li>If <code>nodeName</code> attribute of <var>n</var> is |
| 906 | <code>xml:space</code> <span class=ed>@@ or {xml namespace}:space ?</span> |
| 907 | and <span class=ed>its declared type is different from (default|preserve), |
| 908 | (preserve|default), (default), or (preserve)</span>, then raise an |
| 909 | <a href="#xml-misc-error" id=xme-at-xml-space><code>xml-misc-error</code></a>.</li> |
| 910 | <li>For each node <dfn id=var-ad-nc><var>n<sub><var>c</var></sub></var></dfn> in the |
| 911 | <code>childNodes</code> list of <var>n</var>, |
| 912 | <ol> |
| 913 | <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a |
| 914 | <code>Text</code> or <code>EntityReference</code> node, then it is an |
| 915 | <a href="#xml-well-formedness-error" id=wfe-at-child><code>xml-well-formedness-error</code></a>.</li> |
| 916 | <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an |
| 917 | <code>EntityReference</code> node, then it is an |
| 918 | <a href="#entity-error" id=ee-at-er><code>entity-error</code></a>.</li> |
| 919 | <li>Otherwise, |
| 920 | <a href="#algorithm-to-check-a-node" title="check a node">check |
| 921 | <var>n<sub><var>c</var></sub></var></a> recusrively.</li> |
| 922 | </ol></li> |
| 923 | <li class=ed>If <code>NOTATION_ATTR</code>, enumerated values MUST |
| 924 | be declared. If not, then raise an |
| 925 | <a href="#xml-validity-error" id=vc-notatn-declared><code>xml-validity-error</code></a>.</li> |
| 926 | <li class=ed>If <code>NOTATION_ATTR</code> or <code>ENUMERATED_ATTR</code>, |
| 927 | values MUST all be distinct. If not, then raise an |
| 928 | <a href="#xml-validity-error" id=vc-no-duplicate-tokens><code>xml-validity-error</code></a>.</li> |
| 929 | <li class=ed>If <code>NOTATION_ATTR</code> on an <code>EMPTY</code> |
| 930 | element, then raise an |
| 931 | <a href="#xml-validity-error" id=vc-no-notation-empty><code>xml-validity-error</code></a>.</li> |
| 932 | <li class=ed>@@ #defattrvalid Validity constraint: Attribute Default Value Syntactically Correct</li> |
| 933 | </ol> |
| 934 | </dd> |
| 935 | <dt>If <var>n</var> is a <code>CDATASection</code> node</dt> |
| 936 | <dd> |
| 937 | <ol> |
| 938 | <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the |
| 939 | <code>data</code> attribute value as an <abbr>XML</abbr> character |
| 940 | data</a>.</li> |
| 941 | <li>If the <code>data</code> attribute value contains |
| 942 | a string <code>]]></code>, then raise an |
| 943 | <a href="#xml-well-formedness-error" id=wfe-cs-mse><code>xml-well-formedness-error</code></a>.<!-- "for compatibility" --></li> |
| 944 | <li>If the <code>childNodes</code> list of <var>n</var> contains |
| 945 | any nodes, they are in |
| 946 | <a href="#xml-well-formedness-error" id=wfe-cs-child><code>xml-well-formedness-error</code></a>.</li> |
| 947 | </ol> |
| 948 | </dd> |
| 949 | <dt>If <var>n</var> is a <code>Comment</code> node</dt> |
| 950 | <dd> |
| 951 | <ol> |
| 952 | <li>Raise an |
| 953 | <a href="#round-trip-warning" id=rtw-comment><code>round-trip-warning</code></a>.</li> |
| 954 | <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the |
| 955 | <code>data</code> attribute value as an <abbr>XML</abbr> character |
| 956 | data</a>.</li> |
| 957 | <li>If the <code>data</code> attribute value contains |
| 958 | a string <code>--</code>, or if it ends with a character |
| 959 | <code>-</code>, then raise an |
| 960 | <a href="#xml-well-formedness-error" id=wfe-comment-com><code>xml-well-formedness-error</code></a>.<!-- |
| 961 | "for compatibility" --></li> |
| 962 | <li>If the <code>childNodes</code> list of <var>n</var> contains |
| 963 | any nodes, they are in |
| 964 | <a href="#xml-well-formedness-error" id=wfe-comment-child><code>xml-well-formedness-error</code></a>.</li> |
| 965 | </ol> |
| 966 | </dd> |
| 967 | <dt>If <var>n</var> is a <code>Document</code> node</dt> |
| 968 | <dd> |
| 969 | <ol> |
| 970 | <li>If <a href="#xml-version"><abbr>XML</abbr> version</a> of <var>n</var> |
| 971 | is different from <code>1.0</code> or <code>1.1</code>, |
| 972 | then it is an <code class=ed>unknown-error?</code>.</li> |
| 973 | <li>If the <code>xmlEncoding</code> attribute value does <em>not</em> |
| 974 | match to <code>[A-Za-z] ([A-Za-z0-9._] | '-')*</code> |
| 975 | <span class=ed>@@ formal def</span>, then it is an |
| 976 | <a href="#xml-well-formedness-error" id=wfe-encoding><code>xml-well-formedness-error</code></a>.</li> |
| 977 | <li>The <code>childNodes</code> list of <var>n</var> have to |
| 978 | consist of zero or more <code>Comment</code> and/or |
| 979 | <code>ProcessingInstruction</code> nodes, followed by |
| 980 | an optional <code>DocumentType</code> node, followed |
| 981 | by zero or more <code>Comment</code> and/or |
| 982 | <code>ProcessingInstruction</code> nodes, followed by |
| 983 | an <code>Element</code> node, followed |
| 984 | by zero or more <code>Comment</code> and/or |
| 985 | <code>ProcessingInstruction</code> nodes. Any violation to this is an |
| 986 | <a href="#xml-well-formedness-error" id=wfe-document-child><code>xml-well-formedness-error</code></a>.</li> |
| 987 | <li>For each node <dfn id=var-document-nc><var>n<sub><var>c</var></sub></var></dfn> |
| 988 | in the <code>childNodes</code> list of <var>n</var>, |
| 989 | <ol> |
| 990 | <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an |
| 991 | <code>EntityReference</code> node, then |
| 992 | <a href="#algorithm-to-check-a-node" title="check a node">check |
| 993 | <var>n<sub><var>c</var></sub></var></a> recursively.</li> |
| 994 | </ol></li> |
| 995 | <li class=ed>@@ <code>allDeclarationsProcessed</code></li> |
| 996 | </ol> |
| 997 | </dd> |
| 998 | <dt>If <var>n</var> is a <code>DocumentFragment</code> node</dt> |
| 999 | <dd> |
| 1000 | <ol> |
| 1001 | <li>For each node <dfn id=var-df-nc><var>n<sub><var>c</var></sub></var></dfn> |
| 1002 | in the <code>childNodes</code> list of <var>n</var>, |
| 1003 | <ol> |
| 1004 | <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an |
| 1005 | <code>Element</code>, <code>Text</code>, <code>CDATASection</code>, |
| 1006 | <code>Comment</code>, <code>ProcessingInstruction</code>, or |
| 1007 | <code>EntityReference</code> node, then it is an |
| 1008 | <a href="#xml-well-formedness-error" id=wfe-df-child><code>xml-well-formedness-error</code></a>.</li> |
| 1009 | <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an |
| 1010 | <code>EntityReference</code> node, then it is an |
| 1011 | <a href="#entity-error" id=ee-df-er><code>entity-error</code></a>.</li> |
| 1012 | <li>Otherwise, |
| 1013 | <a href="#algorithm-to-check-a-node" title="check a node">check |
| 1014 | <var>n<sub><var>c</var></sub></var></a> recursively.</li> |
| 1015 | </ol></li> |
| 1016 | </ol> |
| 1017 | </dd> |
| 1018 | <dt>If <var>n</var> is a <code>DocumentType</code> node</dt> |
| 1019 | <dd> |
| 1020 | <ol> |
| 1021 | <li><a href="#algorithm-to-validate-an-ncname">Validate the |
| 1022 | <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li> |
| 1023 | <li>Follow the following substeps: |
| 1024 | <ol> |
| 1025 | <li>If <code>ownerDocument</code> attribute of <var>n</var> is |
| 1026 | <code>null</code>, then abort these substeps.</li> |
| 1027 | <li>If <code>documentElement</code> attribute of the node |
| 1028 | set to <code>ownerDocument</code> attribute of <var>n</var> is |
| 1029 | <code>null</code>, then abort these substeps.</li> |
| 1030 | <li>If <code>nodeName</code> attribute of the node set to |
| 1031 | <code>documentElement</code> attribute of the node set to |
| 1032 | <code>ownerDocument</code> attribute of <var>n</var> is |
| 1033 | different from <code>nodeName</code> of <var>n</var>, |
| 1034 | then raise an |
| 1035 | <a href="#xml-validity-error" id=vc-roottype><code>xml-validity-error</code></a>.</li></li> |
| 1036 | </ol> |
| 1037 | </li> |
| 1038 | <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate |
| 1039 | the <code>publicId</code> attribute value as a public identifier</a>.</li> |
| 1040 | <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate |
| 1041 | the <code>systemId</code> attribute value as a system identifier</a>.</li> |
| 1042 | <li>If the <code>publicId</code> attribute value of <var>n</var> is |
| 1043 | <em>not</em> <code>null</code> and the <code>systemId</code> attribute |
| 1044 | value of <var>n</var> is <code>null</code>, then raise an |
| 1045 | <a href="#xml-well-formedness-error" id=wfe-dt-sid><code>xml-well-formedness-error</code></a>. |
| 1046 | <span class=ed>@@ publicId == null? Or, publicId == ""</span></li> |
| 1047 | <li>For each node <dfn id=var-dt-nc><var>n<sub><var>c</var></sub></var></dfn> |
| 1048 | in the <code>childNodes</code> list of <var>n</var>, |
| 1049 | <ol> |
| 1050 | <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a |
| 1051 | <code>ProcessingInstruction</code> node, then it is an |
| 1052 | <a href="#xml-well-formedness-error" id=wfe-dt-child><code>xml-well-formedness-error</code></a>. |
| 1053 | <span class=ed>@@ ref to manakai's extensions</span></li> |
| 1054 | <li>Otherwise, <!-- if n_c is not an EntityReference node, --> |
| 1055 | <a href="#algorithm-to-check-a-node" title="check a node">check |
| 1056 | <var>n<sub><var>c</var></sub></var></a> recusrively.</li> |
| 1057 | </ol></li> |
| 1058 | <li>For each node in the <code>entities</code>, <code>notations</code>, |
| 1059 | and <code>elementTypes</code> lists of <var>n</var>, |
| 1060 | <a href="#algorithm-to-check-a-node" title="check a node">check the |
| 1061 | node</a> recursively.</li> |
| 1062 | <li class=ed>@@ externally declared?</li> |
| 1063 | <li>If the <code>NamedNodeMap</code> object in the <code>entities</code> |
| 1064 | attribute of <var>n</var> does not contain <code>Entity</code> nodes |
| 1065 | whose <code>nodeName</code> attribute are <code>amp</code>, |
| 1066 | <code>lt</code>, <code>gt</code>, <code>apos</code>, and <code>quot</code> |
| 1067 | then raise |
| 1068 | <a href="#xml-misc-recommentation" id=xmr-predefined><code>xml-misc-recommendation</code></a>(s). |
| 1069 | </ol> |
| 1070 | </dd> |
| 1071 | <dt>If <var>n</var> is an <code>Element</code> node</dt> |
| 1072 | <dd> |
| 1073 | <ol> |
| 1074 | <li><a href="#algorithm-to-validate-an-ncname">Validate the |
| 1075 | <code>localName</code> attribute value as an <code>NCName</code></a>.</li> |
| 1076 | <li>If the <code>prefix</code> attribute value is different from |
| 1077 | <code>null</code>, then <a href="#algorithm-to-validate-an-ncname">validate |
| 1078 | the <code>prefix</code> attribute value as an <code>NCName</code></a>.</li> |
| 1079 | <li>For each node <dfn id=var-element-nc><var>n<sub><var>c</var></sub></var></dfn> |
| 1080 | in the <code>childNodes</code> list of <var>n</var>, |
| 1081 | <ol> |
| 1082 | <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an |
| 1083 | <code>Element</code>, |
| 1084 | <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>, |
| 1085 | <code>ProcessingInstruction</code>, or |
| 1086 | <code>EntityReference</code> node, then it is an |
| 1087 | <a href="#xml-well-formedness-error" id=wfe-element-child><code>xml-well-formedness-error</code></a>.</li> |
| 1088 | <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an |
| 1089 | <code>EntityReference</code> node, then it is an |
| 1090 | <a href="#entity-error" id=ee-element-er><code>entity-error</code></a>.</li> |
| 1091 | <li>Otherwise, |
| 1092 | <a href="#algorithm-to-check-a-node" title="check a node">check |
| 1093 | <var>n<sub><var>c</var></sub></var></a> recursively.</li> |
| 1094 | </ol></li> |
| 1095 | <li class=ed>@@ #elementvalid Validity constraint: Element Valid</li> |
| 1096 | <li>Let <var>attrs</var> be the value of the <code>attribute</code> |
| 1097 | attribute of <var>n</var>. Check conformance of <var>attrs</var> |
| 1098 | as following: |
| 1099 | <ol> |
| 1100 | <li>If <var>attrs</var> contains an <code>Attr</code> node whose |
| 1101 | <code>nodeName</code> attribute value is equal to that of another |
| 1102 | <code>Attr</code> node in <var>attrs</var>, then raise an |
| 1103 | <a href="#xml-well-formedness-error" id=wfe-uniqattspec><code>xml-well-formedness-error</code></a>.<!-- |
| 1104 | #uniqattspec Well-formedness constraint: Unique Att Spec --></li> |
| 1105 | <li class=ed>@@ #RequiredAttr Validity constraint: Required Attribute</li> |
| 1106 | </ol> |
| 1107 | </li> |
| 1108 | </ol> |
| 1109 | </dd> |
| 1110 | <dt>If <var>n</var> is an <code>ElementTypeDefinition</code> node</dt> |
| 1111 | <dd> |
| 1112 | <ol> |
| 1113 | <li class=ed></li> |
| 1114 | <li>If the <code>childNodes</code> list of <var>n</var> contains |
| 1115 | any nodes, they are in |
| 1116 | <a href="#xml-well-formedness-error" id=wfe-et-child><code>xml-well-formedness-error</code></a>.</li> |
| 1117 | <li class=ed>@@ <q cite="http://www.w3.org/TR/2006/REC-xml-20060816/#elemdecls">At user option, an XML processor MAY issue a warning when a declaration mentions an element type for which no declaration is provided, but this is not an error.</q></li> |
| 1118 | <li class=ed>@@ <q cite="http://www.w3.org/TR/2006/REC-xml-20060816/#sec-element-content">For compatibility, it is an error if the content model allows an element to match more than one occurrence of an element type in the content model. </q></li> |
| 1119 | <li class=ed>@@ #vc-MixedChildrenUnique |
| 1120 | Validity constraint: No Duplicate Types</li> |
| 1121 | <li class=ed>@@ <q cite="http://www.w3.org/TR/2006/REC-xml-20060816/#attdecls">At user option, an XML processor MAY issue a warning if attributes are declared for an element type not itself declared, but this is not an error.</q></li> |
| 1122 | <li>If there is more than one <code>AttributeDefinition</code> node |
| 1123 | with <span class=ed>attribute type <code>ID</code></span> in the |
| 1124 | <code>NamedNodeMap</code> list contained in the |
| 1125 | <code>attributeDefinitions</code> attribute of <var>n</var>, then raise an |
| 1126 | <a href="#xml-validity-error" id=vc-one-id-per-el><code>xml-validity-error</code></a>.</li> |
| 1127 | <li>If there is more than one <code>AttributeDefinition</code> node |
| 1128 | with <span class=ed>attribute type <code>NOTATION</code></span> in the |
| 1129 | <code>NamedNodeMap</code> list contained in the |
| 1130 | <code>attributeDefinitions</code> attribute of <var>n</var>, then raise an |
| 1131 | <a href="#xml-validity-error" id=vc-one-notation-per><code>xml-validity-error</code></a>.</li> |
| 1132 | <li class=ed>"For interoperability, the same Nmtoken SHOULD NOT occur more than once in the enumerated attribute types of a single element type."</li> |
| 1133 | </ol> |
| 1134 | </dd> |
| 1135 | <dt>If <var>n</var> is an <code>Entity</code> node whose |
| 1136 | <code>notationName</code> attribute value is <code>null</code> (i.e. a |
| 1137 | parsed entity)</dt> |
| 1138 | <dd> |
| 1139 | <ol> |
| 1140 | <li>Raise an |
| 1141 | <a href="#entity-error" id=ee-entity-node><code>entity-error</code></a>.</li> |
| 1142 | <li><a href="#algorithm-to-validate-an-ncname">Validate the |
| 1143 | <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li> |
| 1144 | <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate |
| 1145 | the <code>publicId</code> attribute value as a public identifier</a>.</li> |
| 1146 | <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate |
| 1147 | the <code>systemId</code> attribute value as a system identifier</a>.</li> |
| 1148 | <li>If the <code>publicId</code> attribute value of <var>n</var> is |
| 1149 | <em>not</em> <code>null</code> and the <code>systemId</code> attribute |
| 1150 | value of <var>n</var> is <code>null</code>, then raise an |
| 1151 | <a href="#xml-well-formedness-error" id=wfe-entity-sid><code>xml-well-formedness-error</code></a>.</li> |
| 1152 | <li>For each node <dfn id=var-entity-nc><var>n<sub><var>c</var></sub></var></dfn> |
| 1153 | in the <code>childNodes</code> list of <var>n</var>, |
| 1154 | <ol> |
| 1155 | <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an |
| 1156 | <code>Element</code>, |
| 1157 | <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>, |
| 1158 | <code>ProcessingInstruction</code>, or <code>EntityReference</code> |
| 1159 | node, then it is an |
| 1160 | <a href="#xml-well-formedness-error" id=wfe-entity-child><code>xml-well-formedness-error</code></a>.</li> |
| 1161 | <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an |
| 1162 | <code>EntityReference</code> node, then it is an |
| 1163 | <a href="#entity-error" id=ee-er-er><code>entity-error</code></a>.</li> |
| 1164 | <li>Otherwise, |
| 1165 | <a href="#algorithm-to-check-a-node" title="check a node">check |
| 1166 | <var>n<sub><var>c</var></sub></var></a> recursively.</li> |
| 1167 | </ol></li> |
| 1168 | </ol> |
| 1169 | </dd> |
| 1170 | <dt>If <var>n</var> is an <code>Entity</code> node whose |
| 1171 | <code>notationName</code> attribute value is <em>not</em> <code>null</code> |
| 1172 | (i.e. an unparsed entity)</dt> |
| 1173 | <dd> |
| 1174 | <ol> |
| 1175 | <li><a href="#algorithm-to-validate-an-ncname">Validate the |
| 1176 | <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li> |
| 1177 | <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate |
| 1178 | the <code>publicId</code> attribute value as a public identifier</a>.</li> |
| 1179 | <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate |
| 1180 | the <code>systemId</code> attribute value as a system identifier</a>.</li> |
| 1181 | <li>If the <code>systemId</code> attribute value of <var>n</var> is |
| 1182 | <code>null</code>, then raise an |
| 1183 | <a href="#xml-well-formedness-error" id=wfe-uentity-sid><code>xml-well-formedness-error</code></a>.</li> |
| 1184 | <li><a href="#algorithm-to-validate-an-ncname">Validate the |
| 1185 | <code>notationName</code> attribute value of <var>n</var> as an |
| 1186 | <code>NCName</code></a>.</li> |
| 1187 | <li class=ed>@@ #not-declared Validity constraint: Notation Declared</li> |
| 1188 | <li>If the <code>childNodes</code> list of <var>n</var> contains |
| 1189 | any nodes, they are in |
| 1190 | <a href="#xml-well-formedness-error" id=wfe-uentity-child><code>xml-well-formedness-error</code></a>.</li> |
| 1191 | </ol> |
| 1192 | </dd> |
| 1193 | <dt>If <var>n</var> is an <code>EntityReference</code> node</dt> |
| 1194 | <dd> |
| 1195 | <ol> |
| 1196 | <li>An <a href="#entity-error" id=ee-er-node><code>entity-error</code></a>.</li> |
| 1197 | <li><a href="#algorithm-to-validate-an-ncname">Validate the |
| 1198 | <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li> |
| 1199 | <li>For each node <dfn id=var-er-nc><var>n<sub><var>c</var></sub></var></dfn> |
| 1200 | in the <code>childNodes</code> list of <var>n</var>, |
| 1201 | <ol> |
| 1202 | <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an |
| 1203 | <code>Element</code>, |
| 1204 | <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>, |
| 1205 | <code>ProcessingInstruction</code>, or <code>EntityReference</code> |
| 1206 | node, then it is an |
| 1207 | <a href="#xml-well-formedness-error" id=wfe-er-child><code>xml-well-formedness-error</code></a>.</li> |
| 1208 | <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is <em>not</em> an |
| 1209 | <code>EntityReference</code> node, then it is an |
| 1210 | <a href="#entity-error" id=ee-entity-er><code>entity-error</code></a>.</li> |
| 1211 | <li>Otherwise, |
| 1212 | <a href="#algorithm-to-check-a-node" title="check a node">check |
| 1213 | <var>n<sub><var>c</var></sub></var></a> recursively.</li> |
| 1214 | </ol></li> |
| 1215 | </ol> |
| 1216 | </dd> |
| 1217 | <dt>If <var>n</var> is a <code>Notation</code> node</dt> |
| 1218 | <dd> |
| 1219 | <ol> |
| 1220 | <li><a href="#algorithm-to-validate-an-ncname">Validate the |
| 1221 | <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li> |
| 1222 | <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate |
| 1223 | the <code>publicId</code> attribute value as a public identifier</a>.</li> |
| 1224 | <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate |
| 1225 | the <code>systemId</code> attribute value as a system identifier</a>.</li> |
| 1226 | <li>If the <code>childNodes</code> list of <var>n</var> contains |
| 1227 | any nodes, they are in |
| 1228 | <a href="#xml-well-formedness-error" id=wfe-notation-child><code>xml-well-formedness-error</code></a>.</li> |
| 1229 | </ol> |
| 1230 | </dd> |
| 1231 | <dt>If <var>n</var> is a <code>ProcessingInstruction</code> node</dt> |
| 1232 | <dd> |
| 1233 | <ol> |
| 1234 | <li>If the <code>target</code> attribute value matches to the string |
| 1235 | <code>xml</code> in any case combination, then raise a |
| 1236 | <a href="#xml-well-formedness-error" id=wfe-pi-xml><code>xml-well-formedness-error</code></a>.</li> |
| 1237 | <li>Otherwise, <a href="#algorithm-to-validate-an-ncname">validate the |
| 1238 | <code>target</code> attribute value as an <code>NCName</code></a>.</li> |
| 1239 | <li>Then, |
| 1240 | <a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">validate |
| 1241 | the <code>data</code> attribute value as an <abbr>XML</abbr> character |
| 1242 | data</a>.</li> |
| 1243 | <li>If the <code>data</code> attribute value contains a string |
| 1244 | <code>?></code>, then raise a |
| 1245 | <a href="#xml-well-formedness-error" id=wfe-pi-pic><code>xml-well-formedness-error</code></a>.</li> |
| 1246 | <li>If the <code>data</code> attribute value starts with either |
| 1247 | <code class=char>U+0009</code> <code class=charname>CHARACTER |
| 1248 | TABULATION</code>, <code class=char>U+000A</code> <code class=charname>LINE |
| 1249 | FEED</code>, <code class=char>U+000D</code> <code class=charname>CARRIAGE |
| 1250 | RETURN</code>, or <code class=char>U+0020</code> |
| 1251 | <code class=charname>SPACE</code> character, then raise a |
| 1252 | <a href="#round-trip-error" id=rte-pi-s><code>round-trip-error</code></a>.</li> |
| 1253 | <li>If the <code>childNodes</code> list of <var>n</var> contains |
| 1254 | any nodes, then raise an |
| 1255 | <a href="#xml-well-formedness-error" id=wfe-pi-child><code>xml-well-formedness-error</code></a>.</li> |
| 1256 | <li class=ed>@@ Warn if not declared |
| 1257 | </ol> |
| 1258 | </dd> |
| 1259 | <dt>If <var>n</var> is a <code>Text</code> node</dt> |
| 1260 | <dd> |
| 1261 | <ol> |
| 1262 | <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the |
| 1263 | <code>data</code> attribute value as an <abbr>XML</abbr> character |
| 1264 | data</a>.</li> |
| 1265 | <li>If the <code>childNodes</code> list of <var>n</var> contains |
| 1266 | any nodes, they are in |
| 1267 | <a href="#xml-well-formedness-error" id=wfe-text-child><code>xml-well-formedness-error</code></a>.</li> |
| 1268 | </ol> |
| 1269 | </dd> |
| 1270 | <dt>Otherwise</dt> |
| 1271 | <dd><span class=ed>xml-well-formedness-error? unknown-error?</span></dd> |
| 1272 | </dl> |
| 1273 | |
| 1274 | </div> |
| 1275 | |
| 1276 | </div> |
| 1277 | |
| 1278 | <div id=classes class=section> |
| 1279 | <h2>Character Classes</h2> |
| 1280 | |
| 1281 | <p>This section defines a couple of character classes. |
| 1282 | These classes are referred to by algorithms specified above.</p> |
| 1283 | |
| 1284 | <p>Character class <dfn id=class-Char10><code>Char10</code></dfn> |
| 1285 | contains the following characters:</p> |
| 1286 | <ul> |
| 1287 | <li><code class=char>U+0009</code> <code class=charname>CHARACTER |
| 1288 | TABULATION</code></li> |
| 1289 | <li><code class=char>U+000A</code> <code class=charname>LINE FEED</code></li> |
| 1290 | <li><code class=char>U+000D</code> <code class=charname>CARRIAGE |
| 1291 | RETURN</code></li> |
| 1292 | <li><code class=char>U+0020</code> <code class=charname>SPACE</code> |
| 1293 | .. <code class=char>U+D7FF</code></li> |
| 1294 | <li><code class=char>U+E000</code> .. <code class=char>U+FFFD</code> |
| 1295 | <code class=charname>REPLACEMENT CHARACTER</code></li> |
| 1296 | <li><code class=char>U+10000</code> .. <code class=char>U+10FFFF</code></li> |
| 1297 | </ul> |
| 1298 | <div class="note memo"> |
| 1299 | <p>This character class contains all characters allowed in the production rule |
| 1300 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Char"><code>Char</code></a> |
| 1301 | of <abbr>XML</abbr> 1.0 |
| 1302 | <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p> |
| 1303 | </div> |
| 1304 | |
| 1305 | <p>Character class <dfn id=class-CompatChar10><code>CompatChar10</code></dfn> |
| 1306 | contains the following characters:</p> |
| 1307 | <ul> |
| 1308 | <li class=ed>@@ <q>Document authors are encouraged to avoid "compatibility characters", as defined in section 6.8 of [Unicode @@ Unicode 2.0 @@] (see also D21 in section 3.6 of [Unicode3]).</q></li> |
| 1309 | </ul> |
| 1310 | |
| 1311 | <p>Character class <dfn id=class-ControlChar10><code>ControlChar10</code></dfn> |
| 1312 | contains the following characters:</p> |
| 1313 | <ul> |
| 1314 | <li><code class=char>U+007F</code> <code class=charname>DELETE</code> .. |
| 1315 | <code class=char>U+0084</code> <code class=charname>INDEX</code></li> |
| 1316 | <li><code class=char>U+0086</code> <code class=charname>START OF SELECTED |
| 1317 | AREA</code> .. <code class=char>U+009F</code> <code class=charname>APPLICATION |
| 1318 | PROGRAM COMMAND</code></li> |
| 1319 | <li><code class=char>U+FDD0</code> .. <code class=char>U+FDEF</code></li> |
| 1320 | <li><code class=char>U+1FFFE</code> .. <code class=char>U+1FFFF</code></li> |
| 1321 | <li><code class=char>U+2FFFE</code> .. <code class=char>U+2FFFF</code></li> |
| 1322 | <li><code class=char>U+3FFFE</code> .. <code class=char>U+3FFFF</code></li> |
| 1323 | <li><code class=char>U+4FFFE</code> .. <code class=char>U+4FFFF</code></li> |
| 1324 | <li><code class=char>U+5FFFE</code> .. <code class=char>U+5FFFF</code></li> |
| 1325 | <li><code class=char>U+6FFFE</code> .. <code class=char>U+6FFFF</code></li> |
| 1326 | <li><code class=char>U+7FFFE</code> .. <code class=char>U+7FFFF</code></li> |
| 1327 | <li><code class=char>U+8FFFE</code> .. <code class=char>U+8FFFF</code></li> |
| 1328 | <li><code class=char>U+9FFFE</code> .. <code class=char>U+9FFFF</code></li> |
| 1329 | <li><code class=char>U+AFFFE</code> .. <code class=char>U+AFFFF</code></li> |
| 1330 | <li><code class=char>U+BFFFE</code> .. <code class=char>U+BFFFF</code></li> |
| 1331 | <li><code class=char>U+CFFFE</code> .. <code class=char>U+CFFFF</code></li> |
| 1332 | <li><code class=char>U+DFFFE</code> .. <code class=char>U+DFFFF</code></li> |
| 1333 | <li><code class=char>U+EFFFE</code> .. <code class=char>U+EFFFF</code></li> |
| 1334 | <li><code class=char>U+FFFFE</code> .. <code class=char>U+FFFFF</code></li> |
| 1335 | <li><code class=char>U+10FFFE</code> .. <code class=char>U+10FFFF</code></li> |
| 1336 | </ul> |
| 1337 | <div class="note memo"> |
| 1338 | <p>This character class contains the characters listed in the Note in |
| 1339 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#charsets">Section 2.2</a> |
| 1340 | of <abbr>XML</abbr> 1.0 |
| 1341 | <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>, |
| 1342 | as amended by |
| 1343 | <a href="http://www.w3.org/XML/xml-V10-4e-errata#E02">errata</a>.</p> |
| 1344 | </div> |
| 1345 | |
| 1346 | <p>The character class <dfn id=class-NameStartChar10><code>NameStartChar10</code></dfn> |
| 1347 | contains the following characters:</p> |
| 1348 | <ul class=ed> |
| 1349 | </ul> |
| 1350 | <div class="note memo"> |
| 1351 | <p>This character class contains all characters allowed as the first character |
| 1352 | of a string matching to the production rule |
| 1353 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Name"><code>Name</code></a> |
| 1354 | of <abbr>XML</abbr> 1.0 |
| 1355 | <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p> |
| 1356 | </div> |
| 1357 | |
| 1358 | <p>The character class <dfn id=class-NameChar10><code>NameChar10</code></dfn> |
| 1359 | contains the following characters:</p> |
| 1360 | <ul> |
| 1361 | <li>The characters in the character class |
| 1362 | <a href="#class-NameStartChar10">NameStartChar10</a>.</li> |
| 1363 | <li class=ed></li> |
| 1364 | </ul> |
| 1365 | <div class="note memo"> |
| 1366 | <p>This character class contains all characters allowed as the second |
| 1367 | character of a string matching to the production rule |
| 1368 | <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Name"><code>Name</code></a> |
| 1369 | of <abbr>XML</abbr> 1.0 |
| 1370 | <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p> |
| 1371 | </div> |
| 1372 | |
| 1373 | <p>The character class <dfn id=class-PubidChar><code>PubidChar</code></dfn> |
| 1374 | contains the following characters:</p> |
| 1375 | <ul> |
| 1376 | <li><code class=char>U+0009</code> <code class=charname>CHARACTER |
| 1377 | TABULATION</code></li> |
| 1378 | <li><code class=char>U+000A</code> <code class=charname>LINE FEED</code></li> |
| 1379 | <li><code class=char>U+000D</code> <code class=charname>CARRIAGE |
| 1380 | RETURN</code></li> |
| 1381 | <li><code class=char>U+0020</code> <code class=charname>SPACE</code></li> |
| 1382 | <li><code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code> |
| 1383 | (<code class=char>!</code>)</li> |
| 1384 | <li><code class=char>U+0023</code> <code class=charname>DOLLAR SIGN</code> |
| 1385 | (<code class=char>$</code>)</li> |
| 1386 | <li><code class=char>U+0024</code> <code class=charname>NUMBER SIGN</code> |
| 1387 | (<code class=char>#</code>)</li> |
| 1388 | <li><code class=char>U+0025</code> <code class=charname>PERCENT SIGN</code> |
| 1389 | (<code class=char>%</code>)</li> |
| 1390 | <li><code class=char>U+0027</code> <code class=charname>APOSTROPHE</code> |
| 1391 | (<code class=char>'</code>)</li> |
| 1392 | <li><code class=char>U+0028</code> <code class=charname>LEFT PARENTHESIS</code> |
| 1393 | (<code class=char>(</code>)</li> |
| 1394 | <li><code class=char>U+0029</code> <code class=charname>RIGHT |
| 1395 | PARENTHESIS</code> (<code class=char>)</code>)</li> |
| 1396 | <li><code class=char>U+002A</code> <code class=charname>ASTERISK</code> |
| 1397 | (<code class=char>*</code>)</li> |
| 1398 | <li><code class=char>U+002B</code> <code class=charname>PLUS SIGN</code> |
| 1399 | (<code class=char>+</code>)</li> |
| 1400 | <li><code class=char>U+002C</code> <code class=charname>COMMA</code> |
| 1401 | (<code class=char>,</code>)</li> |
| 1402 | <li><code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code> |
| 1403 | (<code class=char>-</code>)</li> |
| 1404 | <li><code class=char>U+002E</code> <code class=charname>FULL STOP</code> |
| 1405 | (<code class=char>.</code>)</li> |
| 1406 | <li><code class=char>U+002F</code> <code class=charname>SOLIDUS</code> |
| 1407 | (<code class=char>/</code>)</li> |
| 1408 | <li><code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code> |
| 1409 | (<code class=char>0</code>) .. <code class=char>U+0039</code> |
| 1410 | <code class=charname>DIGIT NINE</code> (<code class=char>9</code>)</li> |
| 1411 | <li><code class=char>U+003A</code> <code class=charname>COLON</code> |
| 1412 | (<code class=char>:</code>)</li> |
| 1413 | <li><code class=char>U+003B</code> <code class=charname>SEMICOLON</code> |
| 1414 | (<code class=char>;</code>)</li> |