18 |
|
|
19 |
<div class="header"> |
<div class="header"> |
20 |
<h1>manakai's <abbr>XML</abbr> Conformance Checking</h1> |
<h1>manakai's <abbr>XML</abbr> Conformance Checking</h1> |
21 |
<h2>Working Draft <time datetime=2007-11-14>14 November 2007</time></h2> |
<h2>Working Draft <time datetime=2007-11-26>26 November 2007</time></h2> |
22 |
|
|
23 |
<dl class="versions-uri"> |
<dl class="versions-uri"> |
24 |
<dt>This Version</dt> |
<dt>This Version</dt> |
120 |
raised is undefined.</p> |
raised is undefined.</p> |
121 |
</div> |
</div> |
122 |
|
|
|
<div class=section id=parsing-xml> |
|
|
<h2>Parsing <abbr>XML</abbr> Document</h2> |
|
|
|
|
|
<ul> |
|
|
<li>If the <abbr>XML</abbr> document does not begin with an |
|
|
<abbr>XML</abbr> declaration, then raise an |
|
|
<a href="#xml-misc-recommentation" id=xmr-xml-decl><code>xml-misc-recommendation</code></a>.</li> |
|
|
<li>If the replacement text of an entity declaration is |
|
|
<code><</code>, then raise an |
|
|
<a href="#xml-misc-warning" id=xmw-entity-value-lt><code>xml-misc-warning</code></a>.<!-- |
|
|
"strongly advised to avoid" in a Note in Section 2.3 of [XML10], [XML11]. |
|
|
--></li> |
|
|
<li>If attribute definition whose <code>Name</code> is |
|
|
<code>xml:space</code> has <span class=ed>declared type different from |
|
|
(default|preserve), (default), or (preserve)</span>, then raise an |
|
|
<a href="#xml-misc-error" id=xme-ad-xml-space><code>xml-misc-error</code></a>. |
|
|
<span class=ed>@@ duplication with |
|
|
<a href="#xml-at-xml-space">#xml-at-xml-space</a>.<!-- |
|
|
<!ATTLIST e xml:space CDATA #IMPLIED xml:space CDATA #IMPLIED> --></span></li> |
|
|
<!-- |
|
|
|
|
|
#vc-PEinMarkupDecl Validity constraint: Proper Declaration/PE Nesting |
|
|
#wfc-PEinInternalSubset Well-formedness constraint: PEs in Internal Subset |
|
|
#ExtSubset Well-formedness constraint: External Subset |
|
|
#PE-between-Decls Well-formedness constraint: PE Between Declarations |
|
|
|
|
|
@@ Need detailed review, but maybe should be in parsing phase |
|
|
|
|
|
#vc-check-rmd Validity constraint: Standalone Document Declaration |
|
|
|
|
|
--> |
|
|
</ul> |
|
|
</div> |
|
|
|
|
|
<div class="section" id=checking-dom> |
|
|
<h2>Checking <abbr>DOM</abbr></h2> |
|
|
|
|
|
<p>The following algorithms and definitions are applied to |
|
|
<abbr>XML</abbr> documents; especially, they are not applied |
|
|
to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p> |
|
123 |
|
|
124 |
<div class=section id=error-categories> |
<div class=section id=error-categories> |
125 |
<h3>Error Classification</h3> |
<h2>Error Classification</h2> |
126 |
|
|
127 |
<p class=ed>If a <code>Document</code> node has no |
<p class=ed>If a <code>Document</code> node has no |
128 |
xml-well-formedness-error, entity-error, and unknown-error, |
xml-well-formedness-error, entity-error, and unknown-error, |
210 |
|
|
211 |
</div> |
</div> |
212 |
|
|
213 |
|
<div class=section id=parsing-xml> |
214 |
|
<h2>Parsing <abbr>XML</abbr> Document</h2> |
215 |
|
|
216 |
|
<ul> |
217 |
|
<li>If the <abbr>XML</abbr> document does not begin with an |
218 |
|
<abbr>XML</abbr> declaration, then raise an |
219 |
|
<a href="#xml-misc-recommentation" id=xmr-xml-decl><code>xml-misc-recommendation</code></a>.</li> |
220 |
|
<li>If the replacement text of an entity declaration is |
221 |
|
<code><</code>, then raise an |
222 |
|
<a href="#xml-misc-warning" id=xmw-entity-value-lt><code>xml-misc-warning</code></a>.<!-- |
223 |
|
"strongly advised to avoid" in a Note in Section 2.3 of [XML10], [XML11]. |
224 |
|
--></li> |
225 |
|
<li>If there is an element type declaration whose <code>Name</code> |
226 |
|
value is already declared, then raise an |
227 |
|
<a href="#xml-validity-error" id=vc-edunique><code>xml-validity-error</code></a>.</li> |
228 |
|
<li>If attribute definition whose <code>Name</code> is |
229 |
|
<code>xml:space</code> has <span class=ed>declared type different from |
230 |
|
(default|preserve), (default), or (preserve)</span>, then raise an |
231 |
|
<a href="#xml-misc-error" id=xme-ad-xml-space><code>xml-misc-error</code></a>. |
232 |
|
<span class=ed>@@ duplication with |
233 |
|
<a href="#xml-at-xml-space">#xml-at-xml-space</a>.<!-- |
234 |
|
<!ATTLIST e xml:space CDATA #IMPLIED xml:space CDATA #IMPLIED> --></span></li> |
235 |
|
<li>If an empty-element tag is used for an element which is <em>not</em> |
236 |
|
declared <code>EMPTY</code>, then raise an |
237 |
|
<a href="#xml-misc-recommentation" id=xmr-emptyelemtag-not-empty><code>xml-misc-recommendation</code></a>.</li> |
238 |
|
<li>If an empty-element tag is <em>not</em> used for an element which is |
239 |
|
declared <code>EMPTY</code>, then raise an |
240 |
|
<a href="#xml-misc-recommentation" id=xmr-empty-not-emptyelemtag><code>xml-misc-recommendation</code></a>.</li> |
241 |
|
<!-- |
242 |
|
|
243 |
|
#vc-PEinMarkupDecl Validity constraint: Proper Declaration/PE Nesting |
244 |
|
#wfc-PEinInternalSubset Well-formedness constraint: PEs in Internal Subset |
245 |
|
#ExtSubset Well-formedness constraint: External Subset |
246 |
|
#PE-between-Decls Well-formedness constraint: PE Between Declarations |
247 |
|
#GIMatch Well-formedness constraint: Element Type Match |
248 |
|
#uniqattspec Well-formedness constraint: Unique Att Spec |
249 |
|
#NoExternalRefs Well-formedness constraint: No External Entity References |
250 |
|
#CleanAttrVals Well-formedness constraint: No < in Attribute Values |
251 |
|
#vc-PEinGroup Validity constraint: Proper Group/PE Nesting |
252 |
|
"For interoperability, if a parameter-entity reference appears in a choice, seq, or Mixed construct, its replacement text SHOULD contain at least one non-blank character, and neither the first nor last non-blank character of the replacement text SHOULD be a connector (| or ,)." |
253 |
|
"For interoperability, an XML processor MAY 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." |
254 |
|
|
255 |
|
@@ Need detailed review, but maybe should be in parsing phase |
256 |
|
|
257 |
|
#vc-check-rmd Validity constraint: Standalone Document Declaration |
258 |
|
|
259 |
|
--> |
260 |
|
</ul> |
261 |
|
</div> |
262 |
|
|
263 |
|
<div class="section" id=checking-dom> |
264 |
|
<h2>Checking <abbr>DOM</abbr></h2> |
265 |
|
|
266 |
|
<p>The following algorithms and definitions are applied to |
267 |
|
<abbr>XML</abbr> documents; especially, they are not applied |
268 |
|
to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p> |
269 |
|
|
270 |
<div class=section id=definitions> |
<div class=section id=definitions> |
271 |
<h3>Definitions</h3> |
<h3>Definitions</h3> |
272 |
|
|
327 |
<span class=ed>@@ except for attribute names <code>xml:lang</code>, |
<span class=ed>@@ except for attribute names <code>xml:lang</code>, |
328 |
<code>xml:space</code>, <code>xml:base</code>, <code>xml:id</code>, |
<code>xml:space</code>, <code>xml:base</code>, <code>xml:id</code>, |
329 |
<code>xmlns</code>, <code>xmlns:<var>*</var></code>, |
<code>xmlns</code>, <code>xmlns:<var>*</var></code>, |
330 |
pi name <code>xml-stylesheet</code>.</span></li> |
pi name <code>xml-stylesheet</code>.</span><!-- |
331 |
|
"names beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) are reserved for standardization in this or future versions of this specification.": |
332 |
|
xml:base and xml:id specifications violate to this sentense! |
333 |
|
--></li> |
334 |
<!-- COLON in Name is a lowercase "should not" in a Note of [XML10], |
<!-- COLON in Name is a lowercase "should not" in a Note of [XML10], |
335 |
[XML11]. --> |
[XML11]. --> |
336 |
<li class=ed>@@</li> |
<li class=ed>@@</li> |
409 |
successor] or an empty string, then xml-misc-warning |
successor] or an empty string, then xml-misc-warning |
410 |
(a "fact"-level error; not an XML error).</li> |
(a "fact"-level error; not an XML error).</li> |
411 |
<li class=ed>@@ <code>specified</code>, |
<li class=ed>@@ <code>specified</code>, |
412 |
<code>manakaiAttributeType</code></li> |
<code>manakaiAttributeType</code> (#ValueType Validity constraint: Attribute Value Type)</li> |
413 |
<!-- xml:space MUST be declared to be valid. --> |
<!-- xml:space MUST be declared to be valid. --> |
414 |
|
<li>Let <dfn id=var-v><var>v</var></dfn> be the value of the |
415 |
|
attribute <code>value</code> of <var>n</var>.</li> |
416 |
|
<li>Validate the <var>n</var> against the <span class=ed>declared |
417 |
|
type</span> as following: |
418 |
|
<dl class=switch> |
419 |
|
<dt class=ed><code>ID_ATTR</code></dt> |
420 |
|
<dd> |
421 |
|
<ol> |
422 |
|
<li><span class=ed>Validate <var>v</var> as an |
423 |
|
<code>Name</code>.</span> If it fails, then raise an |
424 |
|
<a href="#xml-validity-error" id=vc-id-name><code>xml-validity-error</code></a>.</li> |
425 |
|
<li><span class=ed>If <code>ID</code> <var>v</var> is defined,</span> |
426 |
|
then raise an |
427 |
|
<a href="#xml-validity-error" id=vc-id-duplication><code>xml-validity-error</code></a>.</li> |
428 |
|
</ol> |
429 |
|
</dd> |
430 |
|
<dt class=ed>IDREF_ATTR</dt> |
431 |
|
<dd> |
432 |
|
<ol> |
433 |
|
<li><span class=ed>Validate <var>v</var> as an |
434 |
|
<code>Name</code>.</span> If it fails, then raise an |
435 |
|
<a href="#xml-validity-error" id=vc-idref-name><code>xml-validity-error</code></a>.</li> |
436 |
|
<li><span class=ed>If <code>ID</code> <var>v</var> is NOT |
437 |
|
defined,</span> then raise an |
438 |
|
<a href="#xml-validity-error" id=vc-idref-match><code>xml-validity-error</code></a>.</li> |
439 |
|
</ol> |
440 |
|
</dd> |
441 |
|
<dt class=ed>IDREFS_ATTR</dt> |
442 |
|
<dd class=ed>@@</dd> |
443 |
|
<dt class=ed>ENTITY_ATTR</dt> |
444 |
|
<dd> |
445 |
|
<ol> |
446 |
|
<li><span class=ed>Validate <var>v</var> as an |
447 |
|
<code>Name</code>.</span> If it fails, then raise an |
448 |
|
<a href="#xml-validity-error" id=vc-entname-name><code>xml-validity-error</code></a>.</li> |
449 |
|
<li><span class=ed>If <code>Entity</code> <var>v</var> is NOT |
450 |
|
defined,</span> then raise an |
451 |
|
<a href="#xml-validity-error" id=vc-entname-match><code>xml-validity-error</code></a>.</li> |
452 |
|
</ol> |
453 |
|
</dd> |
454 |
|
<dt class=ed>ENTITIES_ATTR</dt> |
455 |
|
<dd class=ed>@@</dd> |
456 |
|
<dt class=ed>NMTOKEN_ATTR</dt> |
457 |
|
<dd> |
458 |
|
<ol> |
459 |
|
<li><span class=ed>Validate <var>v</var> as an |
460 |
|
<code>Nmtoken</code>.</span> If it fails, then raise an |
461 |
|
<a href="#xml-validity-error" id=vc-nmtok-name><code>xml-validity-error</code></a>.</li> |
462 |
|
</ol> |
463 |
|
</dd> |
464 |
|
<dt class=ed>NMTOKENS_ATTR</dt> |
465 |
|
<dd class=ed>@@</dd> |
466 |
|
<dt class=ed>NOTATION_ATTR</dt> |
467 |
|
<dd class=ed><var>v</var> must be one of enumerated values. |
468 |
|
If not, then raise an |
469 |
|
<a href="#xml-validity-error" id=vc-notatn-match><code>xml-validity-error</code></a>.</dd> |
470 |
|
<dt class=ed>ENUMERATED_ATTR</dt> |
471 |
|
<dd class=ed><var>v</var> must be one of enumerated values. |
472 |
|
If not, then raise an |
473 |
|
<a href="#xml-validity-error" id=vc-enum><code>xml-validity-error</code></a>.</dd> |
474 |
|
<dt class=ed>@@</dt> |
475 |
|
</dl> |
476 |
|
</li> |
477 |
|
<li>If <span class=ed>default is NOT #IMPLIED or #REQUIRED</span>, then |
478 |
|
raise an |
479 |
|
<a href="#xml-validity-error" id=vc-id-default><code>xml-validity-error</code></a>.</li> |
480 |
</ol> |
</ol> |
481 |
</dd> |
</dd> |
482 |
<dt>If <var>n</var> is an <code>AttributeDefinition</code> node</dt> |
<dt>If <var>n</var> is an <code>AttributeDefinition</code> node</dt> |
501 |
<a href="#algorithm-to-check-a-node" title="check a node">check |
<a href="#algorithm-to-check-a-node" title="check a node">check |
502 |
<var>n<sub><var>c</var></sub></var></a> recusrively.</li> |
<var>n<sub><var>c</var></sub></var></a> recusrively.</li> |
503 |
</ol></li> |
</ol></li> |
504 |
|
<li class=ed>If <code>NOTATION_ATTR</code>, enumerated values MUST |
505 |
|
be declared. If not, then raise an |
506 |
|
<a href="#xml-validity-error" id=vc-notatn-declared><code>xml-validity-error</code></a>.</li> |
507 |
|
<li class=ed>If <code>NOTATION_ATTR</code> or <code>ENUMERATED_ATTR</code>, |
508 |
|
values MUST all be distinct. If not, then raise an |
509 |
|
<a href="#xml-validity-error" id=vc-no-duplicate-tokens><code>xml-validity-error</code></a>.</li> |
510 |
|
<li class=ed>If <code>NOTATION_ATTR</code> on an <code>EMPTY</code> |
511 |
|
element, then raise an |
512 |
|
<a href="#xml-validity-error" id=vc-no-notation-empty><code>xml-validity-error</code></a>.</li> |
513 |
</ol> |
</ol> |
514 |
</dd> |
</dd> |
515 |
<dt>If <var>n</var> is a <code>CDATASection</code> node</dt> |
<dt>If <var>n</var> is a <code>CDATASection</code> node</dt> |
660 |
<a href="#algorithm-to-check-a-node" title="check a node">check |
<a href="#algorithm-to-check-a-node" title="check a node">check |
661 |
<var>n<sub><var>c</var></sub></var></a> recursively.</li> |
<var>n<sub><var>c</var></sub></var></a> recursively.</li> |
662 |
</ol></li> |
</ol></li> |
663 |
|
<li class=ed>@@ #elementvalid Validity constraint: Element Valid</li> |
664 |
|
<li class=ed>@@ #uniqattspec Well-formedness constraint: Unique Att Spec</li> |
665 |
</ol> |
</ol> |
666 |
</dd> |
</dd> |
667 |
<dt>If <var>n</var> is an <code>ElementTypeDefinition</code> node</dt> |
<dt>If <var>n</var> is an <code>ElementTypeDefinition</code> node</dt> |
671 |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
672 |
any nodes, they are in |
any nodes, they are in |
673 |
<a href="#xml-well-formedness-error" id=wfe-et-child><code>xml-well-formedness-error</code></a>.</li> |
<a href="#xml-well-formedness-error" id=wfe-et-child><code>xml-well-formedness-error</code></a>.</li> |
674 |
|
<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> |
675 |
|
<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> |
676 |
|
<li class=ed>@@ #vc-MixedChildrenUnique |
677 |
|
Validity constraint: No Duplicate Types</li> |
678 |
|
<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> |
679 |
|
<li>If there is more than one <code>AttributeDefinition</code> node |
680 |
|
with <span class=ed>attribute type <code>ID</code></span> in the |
681 |
|
<code>NamedNodeMap</code> list contained in the |
682 |
|
<code>attributeDefinitions</code> attribute of <var>n</var>, then raise an |
683 |
|
<a href="#xml-validity-error" id=vc-one-id-per-el><code>xml-validity-error</code></a>.</li> |
684 |
|
<li>If there is more than one <code>AttributeDefinition</code> node |
685 |
|
with <span class=ed>attribute type <code>NOTATION</code></span> in the |
686 |
|
<code>NamedNodeMap</code> list contained in the |
687 |
|
<code>attributeDefinitions</code> attribute of <var>n</var>, then raise an |
688 |
|
<a href="#xml-validity-error" id=vc-one-notation-per><code>xml-validity-error</code></a>.</li> |
689 |
|
<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> |
690 |
</ol> |
</ol> |
691 |
</dd> |
</dd> |
692 |
<dt>If <var>n</var> is an <code>Entity</code> node</dt> |
<dt>If <var>n</var> is an <code>Entity</code> node</dt> |