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-12>12 November 2007</time></h2> |
<h2>Working Draft <time datetime=2007-11-14>14 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 |
|
|
123 |
<div class="section"> |
<div class=section id=parsing-xml> |
124 |
<h2 class=ed>Algorithms</h2> |
<h2>Parsing <abbr>XML</abbr> Document</h2> |
125 |
|
|
126 |
|
<ul> |
127 |
|
<li>If the replacement text of an entity declaration is |
128 |
|
<code><</code>, then raise an |
129 |
|
<a href="#xml-misc-warning" id=xmw-entity-value-lt><code>xml-misc-warning</code></a>.<!-- |
130 |
|
"strongly advised to avoid" in a Note in Section 2.3 of [XML10], [XML11]. |
131 |
|
--></li> |
132 |
|
</ul> |
133 |
|
</div> |
134 |
|
|
135 |
|
<div class="section" id=checking-dom> |
136 |
|
<h2>Checking <abbr>DOM</abbr></h2> |
137 |
|
|
138 |
<p>The following algorithms and definitions are applied to |
<p>The following algorithms and definitions are applied to |
139 |
<abbr>XML</abbr> documents; especially, they are not applied |
<abbr>XML</abbr> documents; especially, they are not applied |
140 |
to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p> |
to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p> |
141 |
|
|
142 |
|
<div class=section id=error-categories> |
143 |
|
<h3>Error Classification</h3> |
144 |
|
|
145 |
<p class=ed>If a <code>Document</code> node has no |
<p class=ed>If a <code>Document</code> node has no |
146 |
xml-well-formedness-error, entity-error, and unknown-error, |
xml-well-formedness-error, entity-error, and unknown-error, |
147 |
then it is well-formed. If a well-formed <code>Document</code> |
then it is well-formed. If a well-formed <code>Document</code> |
171 |
</dd> |
</dd> |
172 |
<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> |
173 |
<dd class=ed>@@</dd> |
<dd class=ed>@@</dd> |
174 |
|
<dt><dfn id=round-trip-warning><code>round-trip-warning</code></dfn></dt> |
175 |
|
<dd> |
176 |
|
<p>A <a href="#round-trip-warning"><code>round-trip-warning</code></a> |
177 |
|
will be raised when a construct, which might not be restored to the same |
178 |
|
construct when it is serialized and then re-parsed by a conforming |
179 |
|
processor, is encountered.</p> |
180 |
|
<div class="example memo"> |
181 |
|
<p>For a <code>Comment</code> node a |
182 |
|
<a href="#round-trip-warning"><code>round-trip-warning</code></a> will |
183 |
|
be raised, since <abbr>XML</abbr> processors are not required to |
184 |
|
report texts of comments for applications.</p> |
185 |
|
</div> |
186 |
|
</dd> |
187 |
<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> |
188 |
<dd class=ed>@@</dd> |
<dd class=ed>@@</dd> |
189 |
<dt><dfn id=xml-misc-error><code>xml-misc-error</code></dt> |
<dt><dfn id=xml-misc-error><code>xml-misc-error</code></dt> |
219 |
(MAY or MUST), #dt-compat for compatibility, |
(MAY or MUST), #dt-compat for compatibility, |
220 |
#dt-interop for interoperability</p></div> |
#dt-interop for interoperability</p></div> |
221 |
|
|
222 |
|
</div> |
223 |
|
|
224 |
|
<div class=section id=definitions> |
225 |
|
<h3>Definitions</h3> |
226 |
|
|
227 |
<p>The <dfn id=xml-version><abbr>XML</abbr> version</dfn> of a node is |
<p>The <dfn id=xml-version><abbr>XML</abbr> version</dfn> of a node is |
228 |
the <abbr>XML</abbr> version of the document to which the node belongs. |
the <abbr>XML</abbr> version of the document to which the node belongs. |
229 |
For a <code>Documemt</code> node, the <abbr>XML</abbr> version |
For a <code>Documemt</code> node, the <abbr>XML</abbr> version |
230 |
of the document is the value of the <code>xmlVersion</code> |
of the document is the value of the <code>xmlVersion</code> |
231 |
attribute. For a <code>DocumentType</code> node whose |
attribute of the node. For a <code>DocumentType</code> node whose |
232 |
<code>ownerDocument</code> is set to <code>null</code>, |
<code>ownerDocument</code> attribute is set to <code>null</code>, |
233 |
the <abbr>XML</abbr> version of the document is <code>1.0</code>. |
the <abbr>XML</abbr> version of the document is <code>1.0</code><!-- |
234 |
|
since createDocumentType [DOM3CORE] assumes XML 1.0 [XML10TE] -->. |
235 |
For any other node, the <abbr>XML</abbr> version of the document |
For any other node, the <abbr>XML</abbr> version of the document |
236 |
is that of the <code>Document</code> node contained in the |
is that of the <code>Document</code> node contained in the |
237 |
<code>ownerDocument</code> attribute of the node.</p> |
<code>ownerDocument</code> attribute of the node.</p> |
238 |
|
|
239 |
|
</div> |
240 |
|
|
241 |
|
|
242 |
|
<div class=section id=checking-components> |
243 |
|
<h3>Checking Components</h3> |
244 |
|
|
245 |
|
<p>The algorithm |
246 |
|
<dfn id=algorithm-to-validate-an-xml-character-data title-"to validate an XML character data">to |
247 |
|
validate an <abbr>XML</abbr> character data |
248 |
|
(<dfn id=var-s><var>s</var></dfn>)</dfn> is defined as following:</p> |
249 |
|
<ol> |
250 |
|
<li>If <var>s</var> contains a character that is <em>not</em> in |
251 |
|
the character class <a href="#class-Char10"><code>Char10</code></a>, |
252 |
|
then raise an |
253 |
|
<a href="#xml-well-formedness-error" id=wfe-illegal-char><code>xml-well-formedness-error</code></a>.</li> |
254 |
|
<li>If <var>s</var> contains a character that is in the character |
255 |
|
class <a href="#class-CompatChar10"><code>CompatChar10</code></a>, |
256 |
|
then raise an |
257 |
|
<a href="#xml-misc-warning" id=xmw-compat-char><code>xml-misc-warning</code></a>.</li> |
258 |
|
<li>If <var>s</var> contains a character that is in the character |
259 |
|
class <a href="#class-ControlChar10"><code>ControlChar10</code></a>, |
260 |
|
then raise an |
261 |
|
<a href="#xml-misc-warning" id=xmw-control-char><code>xml-misc-warning</code></a>.</li> |
262 |
|
<li class=ed>@@ XML 1.1 support</li> |
263 |
|
<li class=ed>@@ If U+000D, round-trip-error</li> |
264 |
|
</ol> |
265 |
|
|
266 |
|
<p>The algorithm |
267 |
|
<dfn id=algorithm-to-validate-a-name title="to validate a Name">to validate a |
268 |
|
<code>Name</code> (<dfn id=var-name-s><var>s</var></dfn>)</dfn> is defined |
269 |
|
as following:</p> |
270 |
|
<ol> |
271 |
|
<li>If <var>s</var> begins with the string <code>xml</code> (in any |
272 |
|
case combination), then raise an |
273 |
|
<a href="#xml-misc-warning" id=xmw-reserved-name><code>xml-misc-warning</code></a>. |
274 |
|
<span class=ed>@@ except for attribute names <code>xml:lang</code>, |
275 |
|
<code>xml:space</code>, <code>xml:base</code>, <code>xml:id</code>, |
276 |
|
<code>xmlns</code>, <code>xmlns:<var>*</var></code>, |
277 |
|
pi name <code>xml-stylesheet</code>.</span></li> |
278 |
|
<!-- COLON in Name is a lowercase "should not" in a Note of [XML10], |
279 |
|
[XML11]. --> |
280 |
|
<li class=ed>@@</li> |
281 |
|
</ol> |
282 |
|
|
283 |
|
<p>The algorithm |
284 |
|
<dfn id=algorithm-to-validate-a-ncname title="to validate an NCName">to |
285 |
|
validate an <code>NCName</code> (<dfn id=var-name><var>name</var></dfn>)</dfn> |
286 |
|
is defined as following:</p> |
287 |
|
<ol> |
288 |
|
<li class=ed>@@</li> |
289 |
|
</ol> |
290 |
|
|
291 |
|
<p>To <dfn id=algorithm-to-validate-a-public-identifier title="validate a public identifier">validate |
292 |
|
a public identifier (<dfn id=var-pid><var>pid</var></dfn>)</dfn>, the |
293 |
|
algorithm below <em class=rfc2119>MUST</em> be used:</p> |
294 |
|
<ol> |
295 |
|
<li>If <var>pid</var> contains any character |
296 |
|
that is outside of the range of <code>#x20 | #xD | #xA | |
297 |
|
[a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]</code><!-- @@ TODO: formal def -->, |
298 |
|
then it is an |
299 |
|
<a href="#xml-well-formedness-error" id=wfe-pubid-char><code>xml-well-formedness-error</code></a>.</li> |
300 |
|
<li>If <var>pid</var> contains one of <code class=char>U+0009</code> |
301 |
|
<code class=charname>CHARACTER TABULATION</code>, |
302 |
|
<code class=char>U+000A</code> <code class=charname>CARRIAGE RETURN</code>, |
303 |
|
and <code class=char>U+000D</code> <code class=charname>LINE FEED</code> |
304 |
|
characters, if the first character of <var>pid</var> is |
305 |
|
<code class=char>U+0020</code> <code class=charname>SPACE</code> character, |
306 |
|
if the last character of <var>pid</var> is <code class=char>U+0020</code> |
307 |
|
<code class=charname>SPACE</code> character, or if there is a |
308 |
|
<code class=char>U+0020</code> <code class=charname>SPACE</code> character |
309 |
|
immediately followed by another <code class=char>U+0020</code> |
310 |
|
<code class=charname>SPACE</code> character in <var>pid</var>, then it is a |
311 |
|
<a href="#round-trip-error" id=rte-pubid-space><code>round-trip-error</code></a>.</li> |
312 |
|
<li class=ed>@@ Should we check formal-public-identifierness?</li> |
313 |
|
</ol> |
314 |
|
|
315 |
|
</div> |
316 |
|
|
317 |
|
<div class=section id=checking-node> |
318 |
|
<h3>Checking <code>Node</code></h3> |
319 |
|
|
320 |
<p>The algorithm <dfn title="to check a node" id=algorithm-to-check-a-node>to |
<p>The algorithm <dfn title="to check a node" id=algorithm-to-check-a-node>to |
321 |
check a node (<dfn id=var-n><var>n</var></dfn>)</dfn> is defined as |
check a node (<dfn id=var-n><var>n</var></dfn>)</dfn> is defined as |
322 |
following:</p> |
following:</p> |
372 |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
373 |
data</a>.</li> |
data</a>.</li> |
374 |
<li>If the <code>data</code> attribute value contains |
<li>If the <code>data</code> attribute value contains |
375 |
a string <code>]]></code>, then it is an |
a string <code>]]></code>, then raise an |
376 |
<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> |
377 |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
378 |
any nodes, they are in |
any nodes, they are in |
379 |
<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> |
382 |
<dt>If <var>n</var> is a <code>Comment</code> node</dt> |
<dt>If <var>n</var> is a <code>Comment</code> node</dt> |
383 |
<dd> |
<dd> |
384 |
<ol> |
<ol> |
385 |
|
<li>Raise an |
386 |
|
<a href="#round-trip-warning" id=rtw-comment><code>round-trip-warning</code></a>.</li> |
387 |
<li><a href="#algorithm-to-validate-an-xml-character-data">Validate the |
<li><a href="#algorithm-to-validate-an-xml-character-data">Validate the |
388 |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
<code>data</code> attribute value as an <abbr>XML</abbr> character |
389 |
data</a>.</li> |
data</a>.</li> |
390 |
<li>If the <code>data</code> attribute value contains |
<li>If the <code>data</code> attribute value contains |
391 |
a string <code>--</code>, or if it ends with a character |
a string <code>--</code>, or if it ends with a character |
392 |
<code>-</code>, then it is an |
<code>-</code>, then raise an |
393 |
<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>.<!-- |
394 |
|
"for compatibility" --></li> |
395 |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
<li>If the <code>childNodes</code> list of <var>n</var> contains |
396 |
any nodes, they are in |
any nodes, they are in |
397 |
<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> |
616 |
<dd><span class=ed>xml-well-formedness-error? unknown-error?</span></dd> |
<dd><span class=ed>xml-well-formedness-error? unknown-error?</span></dd> |
617 |
</dl> |
</dl> |
618 |
|
|
|
<p>The algorithm |
|
|
<dfn id=algorithm-to-validate-an-xml-character-data title-"to validate an XML character data">to |
|
|
validate an <abbr>XML</abbr> character data |
|
|
(<dfn id=var-s><var>s</var></dfn>)</dfn> is defined as following:</p> |
|
|
<ol> |
|
|
<li class=ed>@@</li> |
|
|
</ol> |
|
|
|
|
|
<p>The algorithm |
|
|
<dfn id=algorithm-to-validate-a-name title="to validate a Name">to validate a |
|
|
<code>Name</code> (<dfn id=var-name><var>name</var></dfn>)</dfn> is defined |
|
|
as following:</p> |
|
|
<ol> |
|
|
<li class=ed>@@</li> |
|
|
</ol> |
|
|
|
|
|
<p>The algorithm |
|
|
<dfn id=algorithm-to-validate-a-ncname title="to validate an NCName">to |
|
|
validate an <code>NCName</code> (<dfn id=var-name><var>name</var></dfn>)</dfn> |
|
|
is defined as following:</p> |
|
|
<ol> |
|
|
<li class=ed>@@</li> |
|
|
</ol> |
|
|
|
|
|
<p>To <dfn id=algorithm-to-validate-a-public-identifier title="validate a public identifier">validate |
|
|
a public identifier (<dfn id=var-pid><var>pid</var></dfn>)</dfn>, the |
|
|
algorithm below <em class=rfc2119>MUST</em> be used:</p> |
|
|
<ol> |
|
|
<li>If <var>pid</var> contains any character |
|
|
that is outside of the range of <code>#x20 | #xD | #xA | |
|
|
[a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]</code><!-- @@ TODO: formal def -->, |
|
|
then it is an |
|
|
<a href="#xml-well-formedness-error" id=wfe-pubid-char><code>xml-well-formedness-error</code></a>.</li> |
|
|
<li>If <var>pid</var> contains one of <code class=char>U+0009</code> |
|
|
<code class=charname>CHARACTER TABULATION</code>, |
|
|
<code class=char>U+000A</code> <code class=charname>CARRIAGE RETURN</code>, |
|
|
and <code class=char>U+000D</code> <code class=charname>LINE FEED</code> |
|
|
characters, if the first character of <var>pid</var> is |
|
|
<code class=char>U+0020</code> <code class=charname>SPACE</code> character, |
|
|
if the last character of <var>pid</var> is <code class=char>U+0020</code> |
|
|
<code class=charname>SPACE</code> character, or if there is a |
|
|
<code class=char>U+0020</code> <code class=charname>SPACE</code> character |
|
|
immediately followed by another <code class=char>U+0020</code> |
|
|
<code class=charname>SPACE</code> character in <var>pid</var>, then it is a |
|
|
<a href="#round-trip-error" id=rte-pubid-space><code>round-trip-error</code></a>.</li> |
|
|
<li class=ed>@@ Should we check formal-public-identifierness?</li> |
|
|
</ol> |
|
|
|
|
619 |
</div> |
</div> |
620 |
|
|
621 |
<div class="section" id="examples"> |
</div> |
|
<h2>Examples</h2> |
|
|
|
|
|
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
|
622 |
|
|
623 |
<div class="ed issue"> |
<div id=classes class=section> |
624 |
|
<h2>Character Classes</h2> |
625 |
|
|
626 |
<div class="example figure block"> |
<p>This section defines a couple of character classes. |
627 |
<div class="caption">...</div> |
These classes are referred to by algorithms specified above.</p> |
628 |
|
|
629 |
<pre><code>...</code></pre> |
<p>Character class <dfn id=class-Char10><code>Char10</code></dfn> |
630 |
|
contains the following characters:</p> |
631 |
|
<ul> |
632 |
|
<li><code class=char>U+0009</code> <code class=charname>CHARACTER |
633 |
|
TABULATION</code></li> |
634 |
|
<li><code class=char>U+000A</code> <code class=charname>LINE FEED</code></li> |
635 |
|
<li><code class=char>U+000D</code> <code class=charname>CARRIAGE |
636 |
|
RETURN</code></li> |
637 |
|
<li><code class=char>U+0020</code> <code class=charname>SPACE</code> |
638 |
|
.. <code class=char>U+D7FF</code></li> |
639 |
|
<li><code class=char>U+E000</code> .. <code class=char>U+FFFD</code> |
640 |
|
<code class=charname>REPLACEMENT CHARACTER</code></li> |
641 |
|
<li><code class=char>U+10000</code> .. <code class=char>U+10FFFF</code></li> |
642 |
|
</ul> |
643 |
|
<div class="note memo"> |
644 |
|
<p>This character class contains all characters allowed in the production rule |
645 |
|
<a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Char"><code>Char</code></a> |
646 |
|
of <abbr>XML</abbr> 1.0 |
647 |
|
<cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p> |
648 |
</div> |
</div> |
649 |
|
|
650 |
|
<p>Character class <dfn id=class-CompatChar10><code>CompatChar10</code></dfn> |
651 |
|
contains the following characters:</p> |
652 |
|
<ul> |
653 |
|
<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> |
654 |
|
</ul> |
655 |
|
|
656 |
|
<p>Character class <dfn id=class-ControlChar10><code>ControlChar10</code></dfn> |
657 |
|
contains the following characters:</p> |
658 |
|
<ul> |
659 |
|
<li><code class=char>U+007F</code> <code class=charname>DELETE</code> .. |
660 |
|
<code class=char>U+0084</code> <code class=charname>INDEX</code></li> |
661 |
|
<li><code class=char>U+0086</code> <code class=charname>START OF SELECTED |
662 |
|
AREA</code> .. <code class=char>U+009F</code> <code class=charname>APPLICATION |
663 |
|
PROGRAM COMMAND</code></li> |
664 |
|
<li><code class=char>U+FDD0</code> .. <code class=char>U+FDEF</code></li> |
665 |
|
<li><code class=char>U+1FFFE</code> .. <code class=char>U+1FFFF</code></li> |
666 |
|
<li><code class=char>U+2FFFE</code> .. <code class=char>U+2FFFF</code></li> |
667 |
|
<li><code class=char>U+3FFFE</code> .. <code class=char>U+3FFFF</code></li> |
668 |
|
<li><code class=char>U+4FFFE</code> .. <code class=char>U+4FFFF</code></li> |
669 |
|
<li><code class=char>U+5FFFE</code> .. <code class=char>U+5FFFF</code></li> |
670 |
|
<li><code class=char>U+6FFFE</code> .. <code class=char>U+6FFFF</code></li> |
671 |
|
<li><code class=char>U+7FFFE</code> .. <code class=char>U+7FFFF</code></li> |
672 |
|
<li><code class=char>U+8FFFE</code> .. <code class=char>U+8FFFF</code></li> |
673 |
|
<li><code class=char>U+9FFFE</code> .. <code class=char>U+9FFFF</code></li> |
674 |
|
<li><code class=char>U+AFFFE</code> .. <code class=char>U+AFFFF</code></li> |
675 |
|
<li><code class=char>U+BFFFE</code> .. <code class=char>U+BFFFF</code></li> |
676 |
|
<li><code class=char>U+CFFFE</code> .. <code class=char>U+CFFFF</code></li> |
677 |
|
<li><code class=char>U+DFFFE</code> .. <code class=char>U+DFFFF</code></li> |
678 |
|
<li><code class=char>U+EFFFE</code> .. <code class=char>U+EFFFF</code></li> |
679 |
|
<li><code class=char>U+FFFFE</code> .. <code class=char>U+FFFFF</code></li> |
680 |
|
<li><code class=char>U+10FFFE</code> .. <code class=char>U+10FFFF</code></li> |
681 |
|
</ul> |
682 |
|
<div class="note memo"> |
683 |
|
<p>This character class contains the characters listed in the Note in |
684 |
|
<a href="http://www.w3.org/TR/2006/REC-xml-20060816/#charsets">Section 2.2</a> |
685 |
|
of <abbr>XML</abbr> 1.0 |
686 |
|
<cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>, |
687 |
|
as amended by |
688 |
|
<a href="http://www.w3.org/XML/xml-V10-4e-errata#E02">errata</a>.</p> |
689 |
</div> |
</div> |
690 |
|
|
691 |
</div> |
</div> |