| 92 |
|
|
| 93 |
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
| 94 |
|
|
| 95 |
<div class="issue ed">...</div> |
<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> |
</div> |
| 215 |
violate to any well$B!>(Bformedness constraint in XML |
violate to any well$B!>(Bformedness constraint in XML |
| 216 |
specification <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>, |
specification <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>, |
| 217 |
<a href="#ref-XML11">XML11</a>]</cite>.</p></dd> |
<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> |
</dl> |
| 224 |
|
|
| 225 |
<div class=ed><p>@@ TODO: #dt-atuseroption at user option |
<div class=ed><p>@@ TODO: #dt-atuseroption at user option |
| 227 |
#dt-interop for interoperability</p> |
#dt-interop for interoperability</p> |
| 228 |
|
|
| 229 |
<p>TODO: XML 1.1, XML Namespace 1.0/1.1, xml:base, xml:id |
<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> |
</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> |
</div> |
| 247 |
|
|
| 248 |
<div class=section id=parsing-xml> |
<div class=section id=parsing-xml> |
| 250 |
|
|
| 251 |
<p>When an <abbr>XML</abbr> document is parsed, the following clauses |
<p>When an <abbr>XML</abbr> document is parsed, the following clauses |
| 252 |
are applied:</p> |
are applied:</p> |
| 253 |
<dl> |
<dl class=switch> |
| 254 |
<dt>For each document |
<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 |
<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> |
<abbr>XML</abbr> declaration, then the parser <em class=rfc2119>MUST</em> |
| 301 |
raise an |
raise an |
| 302 |
<a href="#xml-misc-recommentation" id=xmr-xml-decl><code>xml-misc-recommendation</code></a>. |
<a href="#xml-misc-recommentation" id=xmr-xml-decl><code>xml-misc-recommendation</code></a>. |
| 303 |
<dt>For each internal general entity declaration processed by the parser |
<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 |
<dd>If the |
| 338 |
<a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-EntityValue"><code>EntityValue</code></a> |
<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> |
part of the general entity declaration contains a bare <code>U+003C</code> |
| 342 |
<a href="#xml-misc-warning" id=xmw-entity-value-lt><code>xml-misc-warning</code></a>.<!-- |
<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]. |
"strongly advised to avoid" in a Note in Section 2.3 of [XML10], [XML11]. |
| 344 |
--> |
--> |
| 345 |
<dt>For each element type declaration processed by the parser |
<dt>For each element type declaration being processed by the parser |
| 346 |
<dd>If there is another element type declaration whose <code>Name</code> |
<dd>If there is another processed element type declaration whose |
| 347 |
is equal to the <code>Name</code> of the element type declaration, then |
<code>Name</code> is equal to the <code>Name</code> of the element type |
| 348 |
the parser <em class=rfc2119>MUST</em> raise an |
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>. |
<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> |
NOTE: <!ATTLIST a xml:space (default) #IMPLIED xml:space CDATA #IMPLIED> |
| 371 |
will not be warned. |
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 |
<dt>For each empty-element tag |
| 469 |
<dd>If the <code>Name</code> of the tag is not declared by a processed |
<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 |
element type declaration as <code>EMPTY</code> content, then the parser |
| 475 |
type declaration as <code>EMPTY</code> content, then the parser |
type declaration as <code>EMPTY</code> content, then the parser |
| 476 |
<em class=rfc2119>MUST</em> raise an |
<em class=rfc2119>MUST</em> raise an |
| 477 |
<a href="#xml-misc-recommentation" id=xmr-empty-not-emptyelemtag><code>xml-misc-recommendation</code></a>. |
<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> |
</dl> |
| 542 |
|
|
| 543 |
<p>In addition, the parser <em class=rfc2119>MUST</em> check whether the |
<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. |
following constraints are met. |
| 547 |
|
|
| 548 |
<p><strong>Well-formedness constraints</strong>. For each violation to |
<p><strong>Well-formedness constraints</strong>. For each violation to |
| 552 |
constraints is below: |
constraints is below: |
| 553 |
<ul> |
<ul> |
| 554 |
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#wfc-PEinInternalSubset">Well-formedness constraint: PEs in Internal Subset</a> |
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#wfc-PEinInternalSubset">Well-formedness constraint: PEs in Internal Subset</a> |
|
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#ExtSubset">Well-formedness constraint: External Subset</a> |
|
|
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#PE-between-Decls">Well-formedness constraint: PE Between Declarations</a> |
|
| 555 |
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#GIMatch">Well-formedness constraint: Element Type Match</a> |
<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> |
<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> |
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NoExternalRefs">Well-formedness constraint: No External Entity References</a> |
| 571 |
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#vc-PEinMarkupDecl">Validity constraint: Proper Declaration/PE Nesting</a> |
<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> |
<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> |
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#condsec-nesting">Validity constraint: Proper Conditional Section/PE Nesting</a> |
|
<li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#UniqueNotationName">Validity constraint: Unique Notation Name</a> |
|
| 574 |
</ul> |
</ul> |
| 575 |
|
|
| 576 |
<p><strong>Other creteria</strong>. For each violation to |
<p><strong>Other creteria</strong>. For each violation to |
| 588 |
text declaration.</q> |
text declaration.</q> |
| 589 |
</ul> |
</ul> |
| 590 |
|
|
|
<!-- |
|
|
<li><q>For interoperability, an XML processor <em class=rfc2119>MAY</em> at user option issue a warning when more than one attribute-list declaration is provided for a given element type, or more than one attribute definition is provided for a given attribute, but this is not an error.</q> |
|
|
|
|
|
<a href="#xml-misc-error" id=xme-attr-xml-space><code>xml-misc-error</code></a>. |
|
|
<li>It is an error for a reference to an unparsed entity to appear in the EntityValue in an entity declaration." |
|
|
--> |
|
| 591 |
|
|
| 592 |
<!-- |
<!-- |
| 593 |
|
|
|
|
|
| 594 |
@@ Need detailed review, but maybe should be in parsing phase |
@@ Need detailed review, but maybe should be in parsing phase |
| 595 |
|
|
| 596 |
#vc-check-rmd Validity constraint: Standalone Document Declaration |
#vc-check-rmd Validity constraint: Standalone Document Declaration |
| 599 |
|
|
| 600 |
#wf-entdeclared Well-formedness constraint: Entity Declared |
#wf-entdeclared Well-formedness constraint: Entity Declared |
| 601 |
#vc-entdeclared Validity constraint: Entity Declared |
#vc-entdeclared Validity constraint: Entity Declared |
|
"For interoperability, valid documents SHOULD declare the entities amp, lt, gt, apos, quot, in the form specified in 4.6 Predefined Entities." |
|
|
"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)." |
|
|
|
|
|
@@ flaged and then reported in DOM check phase |
|
| 602 |
|
|
| 603 |
"Entities encoded in UTF-16 MUST and entities encoded in UTF-8 MAY begin with the Byte Order Mark" |
--> |
|
"In the absence of external character encoding information (such as MIME headers), parsed entities which are stored in an encoding other than UTF-8 or UTF-16 MUST begin with a text declaration" |
|
|
"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." |
|
|
|
|
|
@@ in parsing phase |
|
|
|
|
|
"It is a fatal error when an XML processor encounters an entity with an encoding that it is unable to process. It is a fatal error if an XML entity is determined (via default, encoding declaration, or higher-level protocol) to be in a certain encoding but contains byte sequences that are not legal in that encoding." |
|
| 604 |
|
|
| 605 |
@@ We should phrase out what the parser should do where the XML specification |
<p>The parser <em class=rfc2119>MUST</em> act as if it is a |
| 606 |
left undefined. For example: Comment must be converted to a Comment node, |
<a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-validating">validating |
| 607 |
illegal xml:space value must be preserved, so on. |
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> |
</div> |
| 636 |
|
|
| 713 |
case combination), then raise an |
case combination), then raise an |
| 714 |
<a href="#xml-misc-warning" id=xmw-reserved-name><code>xml-misc-warning</code></a>. |
<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>, |
<span class=ed>@@ except for attribute names <code>xml:lang</code>, |
| 716 |
<code>xml:space</code>, <code>xml:base</code>, <code>xml:id</code>, |
<code>xml:space</code><!--, <code>xml:base</code>, <code>xml:id</code>, |
| 717 |
<code>xmlns</code>, <code>xmlns:<var>*</var></code>, |
<code>xmlns</code>, <code>xmlns:<var>*</var></code>, |
| 718 |
pi name <code>xml-stylesheet</code>.</span><!-- |
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.": |
"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! |
xmlns, xml-stylesheet, xml:base and xml:id specifications violate to this sentense! |
| 721 |
--></li> |
--></li> |
| 1060 |
<a href="#algorithm-to-check-a-node" title="check a node">check the |
<a href="#algorithm-to-check-a-node" title="check a node">check the |
| 1061 |
node</a> recursively.</li> |
node</a> recursively.</li> |
| 1062 |
<li class=ed>@@ externally declared?</li> |
<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> |
</ol> |
| 1070 |
</dd> |
</dd> |
| 1071 |
<dt>If <var>n</var> is an <code>Element</code> node</dt> |
<dt>If <var>n</var> is an <code>Element</code> node</dt> |
| 1253 |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
| 1254 |
any nodes, then raise an |
any nodes, then raise an |
| 1255 |
<a href="#xml-well-formedness-error" id=wfe-pi-child><code>xml-well-formedness-error</code></a>.</li> |
<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> |
</ol> |
| 1258 |
</dd> |
</dd> |
| 1259 |
<dt>If <var>n</var> is a <code>Text</code> node</dt> |
<dt>If <var>n</var> is a <code>Text</code> node</dt> |