17 |
<body class="has-abstract"> |
<body class="has-abstract"> |
18 |
|
|
19 |
<div class="header"> |
<div class="header"> |
20 |
<h1>manakai's XML Conformance Checking</h1> |
<h1>manakai's <abbr>XML</abbr> Conformance Checking</h1> |
21 |
<h2>Working Draft <time datetime=2007-11-13>13 November 2007</time></h2> |
<h2>Working Draft <time datetime=2007-11-15>15 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=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, |
153 |
</dd> |
</dd> |
154 |
<dt><dfn id=round-trip-error><code>round-trip-error</code></dfn></dt> |
<dt><dfn id=round-trip-error><code>round-trip-error</code></dfn></dt> |
155 |
<dd class=ed>@@</dd> |
<dd class=ed>@@</dd> |
156 |
|
<dt><dfn id=round-trip-warning><code>round-trip-warning</code></dfn></dt> |
157 |
|
<dd> |
158 |
|
<p>A <a href="#round-trip-warning"><code>round-trip-warning</code></a> |
159 |
|
will be raised when a construct, which might not be restored to the same |
160 |
|
construct when it is serialized and then re-parsed by a conforming |
161 |
|
processor, is encountered.</p> |
162 |
|
<div class="example memo"> |
163 |
|
<p>For a <code>Comment</code> node a |
164 |
|
<a href="#round-trip-warning"><code>round-trip-warning</code></a> will |
165 |
|
be raised, since <abbr>XML</abbr> processors are not required to |
166 |
|
report texts of comments for applications.</p> |
167 |
|
</div> |
168 |
|
</dd> |
169 |
<dt class=ed><dfn id=unknown-error><code>unknown-error</code></dfn>?</dt> |
<dt class=ed><dfn id=unknown-error><code>unknown-error</code></dfn>?</dt> |
170 |
<dd class=ed>@@</dd> |
<dd class=ed>@@</dd> |
171 |
<dt><dfn id=xml-misc-error><code>xml-misc-error</code></dt> |
<dt><dfn id=xml-misc-error><code>xml-misc-error</code></dt> |
186 |
<a href="@@/#dt-fatal">fatal error</a>) |
<a href="@@/#dt-fatal">fatal error</a>) |
187 |
that is not classified to any other <a href="#error-category">error |
that is not classified to any other <a href="#error-category">error |
188 |
category</a>. <span class=ed>@@ What errors fall into this category?</span></dd> |
category</a>. <span class=ed>@@ What errors fall into this category?</span></dd> |
189 |
|
<dt><dfn id=xml-misc-recommendation><code>xml-misc-recommendation</code></dfn></dt> |
190 |
|
<dd> |
191 |
|
<p>An |
192 |
|
<a href="#xml-misc-recommendation"><code>xml-misc-recommendation</code></a> |
193 |
|
will be raised if a <em class=rfc2119>SHOULD</em>$B!>(Blevel requirement |
194 |
|
in <abbr>XML</abbr> specification is not met.</p> |
195 |
|
</dd> |
196 |
<dt><dfn id=xml-validity-error><code>xml-validity-error</code></dfn></dt> |
<dt><dfn id=xml-validity-error><code>xml-validity-error</code></dfn></dt> |
197 |
<dd>A violation of validity constraint in XML document.</dd> |
<dd>A violation of validity constraint in XML document.</dd> |
198 |
<dt><dfn id=xml-well-formedness-error><code>xml-well-formedness-error</code></dfn></dt> |
<dt><dfn id=xml-well-formedness-error><code>xml-well-formedness-error</code></dfn></dt> |
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 attribute definition whose <code>Name</code> is |
226 |
|
<code>xml:space</code> has <span class=ed>declared type different from |
227 |
|
(default|preserve), (default), or (preserve)</span>, then raise an |
228 |
|
<a href="#xml-misc-error" id=xme-ad-xml-space><code>xml-misc-error</code></a>. |
229 |
|
<span class=ed>@@ duplication with |
230 |
|
<a href="#xml-at-xml-space">#xml-at-xml-space</a>.<!-- |
231 |
|
<!ATTLIST e xml:space CDATA #IMPLIED xml:space CDATA #IMPLIED> --></span></li> |
232 |
|
<li>If an empty-element tag is used for an element which is <em>not</em> |
233 |
|
declared <code>EMPTY</code>, then raise an |
234 |
|
<a href="#xml-misc-recommentation" id=xmr-emptyelemtag-not-empty><code>xml-misc-recommendation</code></a>.</li> |
235 |
|
<li>If an empty-element tag is <em>not</em> used for an element which is |
236 |
|
declared <code>EMPTY</code>, then raise an |
237 |
|
<a href="#xml-misc-recommentation" id=xmr-empty-not-emptyelemtag><code>xml-misc-recommendation</code></a>.</li> |
238 |
|
<!-- |
239 |
|
|
240 |
|
#vc-PEinMarkupDecl Validity constraint: Proper Declaration/PE Nesting |
241 |
|
#wfc-PEinInternalSubset Well-formedness constraint: PEs in Internal Subset |
242 |
|
#ExtSubset Well-formedness constraint: External Subset |
243 |
|
#PE-between-Decls Well-formedness constraint: PE Between Declarations |
244 |
|
#GIMatch Well-formedness constraint: Element Type Match |
245 |
|
#uniqattspec Well-formedness constraint: Unique Att Spec |
246 |
|
#NoExternalRefs Well-formedness constraint: No External Entity References |
247 |
|
#CleanAttrVals Well-formedness constraint: No < in Attribute Values |
248 |
|
|
249 |
|
@@ Need detailed review, but maybe should be in parsing phase |
250 |
|
|
251 |
|
#vc-check-rmd Validity constraint: Standalone Document Declaration |
252 |
|
|
253 |
|
--> |
254 |
|
</ul> |
255 |
|
</div> |
256 |
|
|
257 |
|
<div class="section" id=checking-dom> |
258 |
|
<h2>Checking <abbr>DOM</abbr></h2> |
259 |
|
|
260 |
|
<p>The following algorithms and definitions are applied to |
261 |
|
<abbr>XML</abbr> documents; especially, they are not applied |
262 |
|
to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p> |
263 |
|
|
264 |
<div class=section id=definitions> |
<div class=section id=definitions> |
265 |
<h3>Definitions</h3> |
<h3>Definitions</h3> |
266 |
|
|
300 |
then raise an |
then raise an |
301 |
<a href="#xml-misc-warning" id=xmw-control-char><code>xml-misc-warning</code></a>.</li> |
<a href="#xml-misc-warning" id=xmw-control-char><code>xml-misc-warning</code></a>.</li> |
302 |
<li class=ed>@@ XML 1.1 support</li> |
<li class=ed>@@ XML 1.1 support</li> |
303 |
<li class=ed>@@ If U+000D, round-trip-error</li> |
<li>If <var>s</var> contains a <code class=char>U+000D</code> |
304 |
|
<code class=charname>CARRIAGE RETURN</code> character, then |
305 |
|
raise a |
306 |
|
<a href="#round-trip-error" id=rte-cr><code>round-trip-error</code></a>. |
307 |
|
<span class=ed>@@ We should not raise duplicate errors for U+000D |
308 |
|
in attribute values. In addition, we should support a mode where |
309 |
|
U+000D will be serialized as 
 (so that no round-trip-error |
310 |
|
will be raised).</span></li> |
311 |
</ol> |
</ol> |
312 |
|
|
313 |
<p>The algorithm |
<p>The algorithm |
314 |
<dfn id=algorithm-to-validate-a-name title="to validate a Name">to validate a |
<dfn id=algorithm-to-validate-a-name title="to validate a Name">to validate a |
315 |
<code>Name</code> (<dfn id=var-name><var>name</var></dfn>)</dfn> is defined |
<code>Name</code> (<dfn id=var-name-s><var>s</var></dfn>)</dfn> is defined |
316 |
as following:</p> |
as following:</p> |
317 |
<ol> |
<ol> |
318 |
|
<li>If <var>s</var> begins with the string <code>xml</code> (in any |
319 |
|
case combination), then raise an |
320 |
|
<a href="#xml-misc-warning" id=xmw-reserved-name><code>xml-misc-warning</code></a>. |
321 |
|
<span class=ed>@@ except for attribute names <code>xml:lang</code>, |
322 |
|
<code>xml:space</code>, <code>xml:base</code>, <code>xml:id</code>, |
323 |
|
<code>xmlns</code>, <code>xmlns:<var>*</var></code>, |
324 |
|
pi name <code>xml-stylesheet</code>.</span><!-- |
325 |
|
"names beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) are reserved for standardization in this or future versions of this specification.": |
326 |
|
xml:base and xml:id specifications violate to this sentense! |
327 |
|
--></li> |
328 |
|
<!-- COLON in Name is a lowercase "should not" in a Note of [XML10], |
329 |
|
[XML11]. --> |
330 |
<li class=ed>@@</li> |
<li class=ed>@@</li> |
331 |
</ol> |
</ol> |
332 |
|
|
392 |
<a href="#algorithm-to-check-a-node" title="check a node">check |
<a href="#algorithm-to-check-a-node" title="check a node">check |
393 |
<var>n<sub><var>c</var></sub></var></a> recusrively.</li> |
<var>n<sub><var>c</var></sub></var></a> recusrively.</li> |
394 |
</ol></li> |
</ol></li> |
395 |
|
<li>If <code>nodeName</code> attribute of <var>n</var> is |
396 |
|
<code>xml:space</code> <span class=ed>@@ or {xml namespace}:space ?</span> |
397 |
|
and <code>value</code> attribute of <var>n</var> is neither |
398 |
|
<code>default</code> nor <code>preserve</code>, then it is an |
399 |
|
<a href="#xml-misc-error" id=xme-attr-xml-space><code>xml-misc-error</code></a>.<!-- |
400 |
|
Note that <!ATTLIST e xml:space (default|preserve) "a">... |
401 |
|
<e xml:space="default"/> is conforming and valid. --></li> |
402 |
|
<li class=ed>@@ xml:lang value is not a language tag [RFC 3066 or its |
403 |
|
successor] or an empty string, then xml-misc-warning |
404 |
|
(a "fact"-level error; not an XML error).</li> |
405 |
<li class=ed>@@ <code>specified</code>, |
<li class=ed>@@ <code>specified</code>, |
406 |
<code>manakaiAttributeType</code></li> |
<code>manakaiAttributeType</code> (#ValueType Validity constraint: Attribute Value Type)</li> |
407 |
|
<!-- xml:space MUST be declared to be valid. --> |
408 |
</ol> |
</ol> |
409 |
</dd> |
</dd> |
410 |
<dt>If <var>n</var> is an <code>AttributeDefinition</code> node</dt> |
<dt>If <var>n</var> is an <code>AttributeDefinition</code> node</dt> |
411 |
<dd> |
<dd> |
412 |
<ol> |
<ol> |
413 |
<li class=ed></li> |
<li class=ed></li> |
414 |
|
<li>If <code>nodeName</code> attribute of <var>n</var> is |
415 |
|
<code>xml:space</code> <span class=ed>@@ or {xml namespace}:space ?</span> |
416 |
|
and <span class=ed>its declared type is different from (default|preserve), |
417 |
|
(default), or (preserve)</span>, then raise an |
418 |
|
<a href="#xml-misc-error" id=xme-at-xml-space><code>xml-misc-error</code></a>.</li> |
419 |
<li>For each node <dfn id=var-ad-nc><var>n<sub><var>c</var></sub></var></dfn> in the |
<li>For each node <dfn id=var-ad-nc><var>n<sub><var>c</var></sub></var></dfn> in the |
420 |
<code>childNodes</code> list of <var>n</var>, |
<code>childNodes</code> list of <var>n</var>, |
421 |
<ol> |
<ol> |
438 |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
439 |
data</a>.</li> |
data</a>.</li> |
440 |
<li>If the <code>data</code> attribute value contains |
<li>If the <code>data</code> attribute value contains |
441 |
a string <code>]]></code>, then it is an |
a string <code>]]></code>, then raise an |
442 |
<a href="#xml-well-formedness-error" id=wfe-cs-mse><code>xml-well-formedness-error</code></a>.</li> |
<a href="#xml-well-formedness-error" id=wfe-cs-mse><code>xml-well-formedness-error</code></a>.<!-- "for compatibility" --></li> |
443 |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
444 |
any nodes, they are in |
any nodes, they are in |
445 |
<a href="#xml-well-formedness-error" id=wfe-cs-child><code>xml-well-formedness-error</code></a>.</li> |
<a href="#xml-well-formedness-error" id=wfe-cs-child><code>xml-well-formedness-error</code></a>.</li> |
448 |
<dt>If <var>n</var> is a <code>Comment</code> node</dt> |
<dt>If <var>n</var> is a <code>Comment</code> node</dt> |
449 |
<dd> |
<dd> |
450 |
<ol> |
<ol> |
451 |
|
<li>Raise an |
452 |
|
<a href="#round-trip-warning" id=rtw-comment><code>round-trip-warning</code></a>.</li> |
453 |
<li><a href="#algorithm-to-validate-an-xml-character-data">Validate the |
<li><a href="#algorithm-to-validate-an-xml-character-data">Validate the |
454 |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
455 |
data</a>.</li> |
data</a>.</li> |
456 |
<li>If the <code>data</code> attribute value contains |
<li>If the <code>data</code> attribute value contains |
457 |
a string <code>--</code>, or if it ends with a character |
a string <code>--</code>, or if it ends with a character |
458 |
<code>-</code>, then it is an |
<code>-</code>, then raise an |
459 |
<a href="#xml-well-formedness-error" id=wfe-comment-com><code>xml-well-formedness-error</code></a>.</li> |
<a href="#xml-well-formedness-error" id=wfe-comment-com><code>xml-well-formedness-error</code></a>.<!-- |
460 |
|
"for compatibility" --></li> |
461 |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
462 |
any nodes, they are in |
any nodes, they are in |
463 |
<a href="#xml-well-formedness-error" id=wfe-comment-child><code>xml-well-formedness-error</code></a>.</li> |
<a href="#xml-well-formedness-error" id=wfe-comment-child><code>xml-well-formedness-error</code></a>.</li> |
519 |
<ol> |
<ol> |
520 |
<li><a href="#algorithm-to-validate-a-ncname">Validate the |
<li><a href="#algorithm-to-validate-a-ncname">Validate the |
521 |
<code>nodeName</code> attribute value as an <code>NCName</code></a>.</li> |
<code>nodeName</code> attribute value as an <code>NCName</code></a>.</li> |
522 |
|
<li>Follow the following substeps: |
523 |
|
<ol> |
524 |
|
<li>If <code>ownerDocument</code> attribute of <var>n</var> is |
525 |
|
<code>null</code>, then abort these substeps.</li> |
526 |
|
<li>If <code>documentElement</code> attribute of the node |
527 |
|
set to <code>ownerDocument</code> attribute of <var>n</var> is |
528 |
|
<code>null</code>, then abort these substeps.</li> |
529 |
|
<li>If <code>nodeName</code> attribute of the node set to |
530 |
|
<code>documentElement</code> attribute of the node set to |
531 |
|
<code>ownerDocument</code> attribute of <var>n</var> is |
532 |
|
different from <code>nodeName</code> of <var>n</var>, |
533 |
|
then raise an |
534 |
|
<a href="#xml-validity-error" id=vc-roottype><code>xml-validity-error</code></a>.</li></li> |
535 |
|
</ol> |
536 |
|
</li> |
537 |
<li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate |
<li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate |
538 |
the <code>publicId</code> attribute value as a public identifier</a>.</li> |
the <code>publicId</code> attribute value as a public identifier</a>.</li> |
539 |
<li>If the <code>systemId</code> attribute value contains |
<li>If the <code>systemId</code> attribute value contains |
579 |
<a href="#algorithm-to-check-a-node" title="check a node">check |
<a href="#algorithm-to-check-a-node" title="check a node">check |
580 |
<var>n<sub><var>c</var></sub></var></a> recursively.</li> |
<var>n<sub><var>c</var></sub></var></a> recursively.</li> |
581 |
</ol></li> |
</ol></li> |
582 |
|
<li class=ed>@@ #elementvalid Validity constraint: Element Valid</li> |
583 |
|
<li class=ed>@@ #uniqattspec Well-formedness constraint: Unique Att Spec</li> |
584 |
</ol> |
</ol> |
585 |
</dd> |
</dd> |
586 |
<dt>If <var>n</var> is an <code>ElementTypeDefinition</code> node</dt> |
<dt>If <var>n</var> is an <code>ElementTypeDefinition</code> node</dt> |
665 |
<dt>If <var>n</var> is a <code>ProcessingInstruction</code> node</dt> |
<dt>If <var>n</var> is a <code>ProcessingInstruction</code> node</dt> |
666 |
<dd> |
<dd> |
667 |
<ol> |
<ol> |
668 |
<li><a href="#algorithm-to-validate-a-ncname">Validate the |
<li>If the <code>target</code> attribute value matches to the string |
669 |
<code>target</code> attribute value as an <code>NCName</code></a>.</li> |
<code>xml</code> in any case combination, then raise a |
|
<li>If the <code>target</code> attribute value matches to |
|
|
<code>XML</code> case-insensitively, then it is a |
|
670 |
<a href="#xml-well-formedness-error" id=wfe-pi-xml><code>xml-well-formedness-error</code></a>.</li> |
<a href="#xml-well-formedness-error" id=wfe-pi-xml><code>xml-well-formedness-error</code></a>.</li> |
671 |
<li><a href="#algorithm-to-validate-an-xml-character-data">Validate the |
<li>Otherwise, <a href="#algorithm-to-validate-a-ncname">validate the |
672 |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
<code>target</code> attribute value as an <code>NCName</code></a>.</li> |
673 |
|
<li>Then, |
674 |
|
<a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML character data">validate |
675 |
|
the <code>data</code> attribute value as an <abbr>XML</abbr> character |
676 |
data</a>.</li> |
data</a>.</li> |
677 |
<li>If the <code>data</code> attribute value contains |
<li>If the <code>data</code> attribute value contains a string |
678 |
a string <code>?></code>, or starts with either |
<code>?></code>, then raise a |
679 |
<code class=char>U+0009</code>, <code class=char>U+000A</code>, |
<a href="#xml-well-formedness-error" id=wfe-pi-pic><code>xml-well-formedness-error</code></a>.</li> |
680 |
<code class=char>U+000D</code>, or <code class=char>U+0020</code> |
<li>If the <code>data</code> attribute value starts with either |
681 |
character, then it is a |
<code class=char>U+0009</code> <code class=charname>CHARACTER |
682 |
<a href="#round-trip-error" id=rte-pi-data><code>round-trip-error</code></a>.</li> |
TABULATION</code>, <code class=char>U+000A</code> <code class=charname>LINE |
683 |
|
FEED</code>, <code class=char>U+000D</code> <code class=charname>CARRIAGE |
684 |
|
RETURN</code>, or <code class=char>U+0020</code> |
685 |
|
<code class=charname>SPACE</code> character, then raise a |
686 |
|
<a href="#round-trip-error" id=rte-pi-s><code>round-trip-error</code></a>.</li> |
687 |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
688 |
any nodes, they are in |
any nodes, then raise an |
689 |
<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> |
690 |
</ol> |
</ol> |
691 |
</dd> |
</dd> |