/[suikacvs]/markup/xml/xmlcc/xmlcc-work.en.html
Suika

Contents of /markup/xml/xmlcc/xmlcc-work.en.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.28 - (hide annotations) (download) (as text)
Sat Mar 29 11:46:02 2008 UTC (16 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.27: +54 -26 lines
File MIME type: text/html
Entity Declared and standalone=no VCs incorporated

1 wakaba 1.1 <!DOCTYPE html>
2     <html lang="en" class="formal-specification status-work-in-progress">
3     <head>
4 wakaba 1.2 <title>manakai's XML Conformance Checking</title>
5 wakaba 1.1 <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 wakaba 1.6 <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 wakaba 1.1 </head>
17     <body class="has-abstract">
18    
19     <div class="header">
20 wakaba 1.12 <h1>manakai's <abbr>XML</abbr> Conformance Checking</h1>
21 wakaba 1.24 <h2>Working Draft <time datetime=2008-03-29>29 March 2008</time></h2>
22 wakaba 1.1
23 wakaba 1.2 <dl class="versions-uri">
24 wakaba 1.1 <dt>This Version</dt>
25 wakaba 1.2 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work"
26     >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work</a>&gt;</code></dd>
27 wakaba 1.1 <dt>Latest Version</dt>
28 wakaba 1.2 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc"
29     >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc</a>&gt;</code></dd>
30 wakaba 1.1 <dt>Latest Working Draft</dt>
31 wakaba 1.2 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work"
32     >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work</a>&gt;</code></dd>
33 wakaba 1.1 <!-- <dt>Previous Version</dt> -->
34     <dt>Version History</dt>
35 wakaba 1.2 <dd><code class=URI>&lt;<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>&gt;</code></dd>
36 wakaba 1.1 </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">&lt;<a href="mailto:w@suika.fam.cx" rel="author"
42     >w@suika.fam.cx</a>&gt;</code></dd>
43     </dl>
44    
45 wakaba 1.22 <p class="copyright" lang="en">&#xA9; <time>2007</time>$B!>(B<time>2008</time> <a
46 wakaba 1.1 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">&lt;<a
56     href="http://www.gnu.org/copyleft/fdl.html"
57     rel="license">http://www.gnu.org/copyleft/fdl.html</a>&gt;</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 wakaba 1.27 <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 wakaba 1.1
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 wakaba 1.22
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 wakaba 1.1 </div>
132    
133    
134 wakaba 1.9 <div class=section id=error-categories>
135 wakaba 1.14 <h2>Error Classification</h2>
136 wakaba 1.9
137 wakaba 1.1 <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 wakaba 1.17 <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 wakaba 1.1 <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 wakaba 1.4 <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 wakaba 1.1 <dt><dfn id=round-trip-error><code>round-trip-error</code></dfn></dt>
168     <dd class=ed>@@</dd>
169 wakaba 1.12 <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 wakaba 1.1 <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 wakaba 1.13 <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 wakaba 1.1 <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 wakaba 1.26 <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 wakaba 1.1 </dl>
224    
225     <div class=ed><p>@@ TODO: #dt-atuseroption at user option
226     (MAY or MUST), #dt-compat for compatibility,
227 wakaba 1.23 #dt-interop for interoperability</p>
228    
229     <p>TODO: XML 1.1, XML Namespace 1.0/1.1, xml:base, xml:id
230 wakaba 1.27
231     <p>TODO: XML "error"/"fatal error" is not always non-conforming (only
232     when MUST or SHOULD).
233 wakaba 1.23 </div>
234 wakaba 1.1
235 wakaba 1.27 <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 wakaba 1.9 </div>
247 wakaba 1.14
248     <div class=section id=parsing-xml>
249     <h2>Parsing <abbr>XML</abbr> Document</h2>
250    
251 wakaba 1.22 <p>When an <abbr>XML</abbr> document is parsed, the following clauses
252     are applied:</p>
253 wakaba 1.25 <dl class=switch>
254 wakaba 1.27 <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 wakaba 1.25 <dt>For the document
299 wakaba 1.22 <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 wakaba 1.27 <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 wakaba 1.25 <dt>For the document type declaration
315     <dd class=ed>@@ read external entity
316 wakaba 1.26 <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>&amp;</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>&lt;</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 wakaba 1.25 <dt>For each internal general entity declaration being processed by the parser
337 wakaba 1.22 <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>&lt;</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 wakaba 1.14 "strongly advised to avoid" in a Note in Section 2.3 of [XML10], [XML11].
344 wakaba 1.22 -->
345 wakaba 1.25 <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 wakaba 1.22 <a href="#xml-validity-error" id=vc-edunique><code>xml-validity-error</code></a>.
350 wakaba 1.25 <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 wakaba 1.22 <!--
370     NOTE: <!ATTLIST a xml:space (default) #IMPLIED xml:space CDATA #IMPLIED>
371     will not be warned.
372     -->
373 wakaba 1.25
374     <dt>For each entity declaration being processed by the parser
375 wakaba 1.26 <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>&lt;</code> (if <code>lt</code>) or <code>&amp;</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 wakaba 1.25
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 wakaba 1.22 <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 wakaba 1.27 <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 wakaba 1.25
496     <dt>For each parameter entity reference
497 wakaba 1.28 <dd><p>Process as follows:
498     <ol>
499     <li>If the declaration for the entity is <em>not</em> processed,
500     then:
501     <dl class=switch>
502     <dt>If the document contains no external entity or if the document
503     contains the <code>standalone</code> pseudo-attribute set to
504     <code>yes</code><!-- or the document contains no DTD -->
505     <dd>The parser <em class=rfc2119>MUST</em> raise an
506     <a href="#xml-well-formedness-error" id=wf-entdeclared-pe><code>xml-well-formedness-error</code></a>.
507     <dt>Otherwise
508     <dd>The parser <em class=rfc2119>MUST</em> raise an
509     <a href="#xml-validity-error" id=vc-entdeclared-pe><code>xml-validity-error</code></a>.
510     </dl>
511     <li>If the declaration for the entity <em>is</em> processed but the
512     referenced entity cannot be retrieved, then the parser
513     <em class=rfc2119>MUST</em> raise an
514     <span class=ed>@@ ??-error</span>.
515     </ol>
516    
517     <p>In any of two cases above, process as follows:
518 wakaba 1.25 <ul>
519 wakaba 1.28 <li>If the parameter entity reference is contained in a declaration, then
520     the declaration <em class=rfc2119>MUST</em> be ignored <em>except</em> that
521 wakaba 1.25 any error before the parameter entity <em class=rfc2119>MUST</em> be
522     raised as usual.
523 wakaba 1.28 <li>If the parameter entity reference is contained in the status portion of
524     a conditional section, then the conditional section
525 wakaba 1.25 <em class=rfc2119>MUST</em> be processed as if it were an
526     <code>IGNORE</code>d section.
527     <li>The parser <em class=rfc2119>MUST NOT</em> process any entity or
528     attribute-list declaration after the parameter entity reference in the DTD
529     <em>except</em> when the <code>standalone</code> pseudo-attribute of the
530     XML declaration (if any) is set to <code>yes</code>.
531     <!-- This requirement is enforced for internal DTD subset case in
532     XML 1.0/1.1 specification (section 5.1) but not for any other cases. -->
533     <!-- According to this definition, element type declarations, notation
534     declarations, and PIs ARE processed. -->
535     <li>If the parameter entity reference is the first reference to an entity
536     that is not read, then the parser <em class=rfc2119>MUST</em> raise an
537     <a href="#entity-error" id=ee-unread-pe><code>entity-error</code></a>.
538     <li>The <code>allDeclarationsProcessed</code> <span class=ed>@@ ref</span>
539     attribute of the <code>Document</code> node <em class=rfc2119>MUST</em> be
540     set to <code>false</code>.
541     </ul>
542     <dt>For each general entity reference in an attribute value or in the content
543     of an element
544 wakaba 1.28 <dd><p>Process as follows:
545     <ol>
546     <li>If the <code>Name</code> of the entity reference is either
547     <code>amp</code>, <code>lt</code>, <code>gt</code>, <code>quot</code>,
548     or <code>apos</code>, then abort these steps.
549     <li>If the declaration for the entity is <em>not</em> processed,
550     then:
551     <dl class=switch>
552     <dt>If the document contains no external entity or if the document
553     contains the <code>standalone</code> pseudo-attribute set to
554     <code>yes</code><!-- or the document contains no DTD -->
555     <dd>The parser <em class=rfc2119>MUST</em> raise an
556     <a href="#xml-well-formedness-error" id=wf-entdeclared-ge><code>xml-well-formedness-error</code></a>.
557     <dt>Otherwise
558     <dd>The parser <em class=rfc2119>MUST</em> raise an
559     <a href="#xml-validity-error" id=vc-entdeclared-ge><code>xml-validity-error</code></a>.
560     </dl>
561     <li>If the declaration for the entity <em>is</em> processed but the
562     referenced entity cannot be retrieved, then the parser
563     <em class=rfc2119>MUST</em> raise an
564     <span class=ed>@@ ??-error</span>.
565     </ol>
566    
567     <p>In any of two cases above, process as follows:
568 wakaba 1.25 <ul>
569     <li>If the general entity reference is the first reference to an entity
570     that is not read, then the parser <em class=rfc2119>MUST</em> raise an
571     <a href="#entity-error" id=ee-unread-ge><code>entity-error</code></a>.
572     <span class=ed>@@ entity declared WFC?</span>
573     <li class=ed>An unexpended entity reference node <em class=rfc2119>MUST</em> be inserted to the current node.
574     </ul>
575 wakaba 1.27
576     <dt>For each comment <em>outside</em> of document type declaration
577     <dd>A <code>Comment</code> node <em class=rfc2119>MUST</em> be created
578     and inserted appropriately.
579     <!-- In XML 1.0/1.1 spec, this is optional. -->
580 wakaba 1.24 </dl>
581    
582 wakaba 1.28 <p>The parser <em class=rfc2119>MUST</em> try to read any entity referenced
583     by general or parameter entity references, the external subset entity, if any,
584     and any general entity declared in the document type definition.
585 wakaba 1.25
586     <p>In addition, the parser has to check whether the
587 wakaba 1.24 following constraints are met.
588    
589     <p><strong>Well-formedness constraints</strong>. For each violation to
590     one of constraints below, an
591     <a href="#xml-well-formedness-error"><code>xml-well-formedness-error</code></a>
592     <em class=rfc2119>MUST</em> be raised. The list of well-formedness
593     constraints is below:
594     <ul>
595     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#wfc-PEinInternalSubset">Well-formedness constraint: PEs in Internal Subset</a>
596     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#GIMatch">Well-formedness constraint: Element Type Match</a>
597     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#uniqattspec">Well-formedness constraint: Unique Att Spec</a>
598     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NoExternalRefs">Well-formedness constraint: No External Entity References</a>
599     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#CleanAttrVals">Well-formedness constraint: No &lt; in Attribute Values</a>
600     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#wf-Legalchar">Well-formedness constraint: Legal Character</a>
601     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#textent">Well-formedness constraint: Parsed Entity</a>
602     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#norecursion">Well-formedness constraint: No Recursion</a>
603     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#indtd">Well-formedness constraint: In DTD</a>
604     </ul>
605    
606     <p><strong>Validity constraints</strong>. For each violation to
607     one of constraints below, an
608     <a href="#xml-validity-error"><code>xml-validity-error</code></a>.
609     <em class=rfc2119>MUST</em> be raised. The list of validity
610     constraints is below:
611     <ul>
612     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#vc-PEinMarkupDecl">Validity constraint: Proper Declaration/PE Nesting</a>
613     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#vc-PEinGroup">Validity constraint: Proper Group/PE Nesting</a>
614     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#condsec-nesting">Validity constraint: Proper Conditional Section/PE Nesting</a>
615 wakaba 1.28 <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#vc-check-rmd">Validity constraint: Standalone Document Declaration</a>
616 wakaba 1.24 </ul>
617    
618     <p><strong>Other creteria</strong>. For each violation to
619     one of constraints below, an
620     <a href="#xml-misc-recommendation"><code>xml-misc-recommendation</code></a>
621     <em class=rfc2119>MUST</em> be raised. The list of constraints is below:
622     <ul>
623     <li><q>For interoperability, if a parameter-entity reference appears in a
624     <code>choice</code>, <code>seq</code>, or <code>Mixed</code> construct, its
625     replacement text <em class=rfc2119>SHOULD</em> contain at least one non-blank
626     character, and neither the first nor last non-blank character of the
627     replacement text <em class=rfc2119>SHOULD</em> be a connector (<code>|</code>
628     or <code>,</code>).</q>
629     <li><q>External parsed entities <em class=rfc2119>SHOULD</em> each begin with a
630     text declaration.</q>
631     </ul>
632    
633 wakaba 1.27 <p>The parser <em class=rfc2119>MUST</em> act as if it is a
634     <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-validating">validating
635     XML processor</a> for the informing of white space appearing in
636     <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-elemcontent">element
637     content</a> (See
638     <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#sec-white-space">Section
639     2.10</a> of the XML specification).
640    
641     <div class="note memo informative">
642     <p>In other word, the <code>isElementContentWhitespace</code> attribute
643     of <code>Text</code> nodes has to be set appropriately. Note that the
644     value of the attribute will be set to <code>false</code> for any
645     <code>Text</code> node in the content of an element whose declaration
646     is not processed.
647     </div>
648 wakaba 1.25
649     <p>The parser <em class=rfc2119>MUST</em> raise an
650     <a href="#xml-well-formedness-error" id=wfe-syntax><code>xml-well-formedness-error</code></a>
651 wakaba 1.28 for any failure for matching to a production rule in the XML specification.
652 wakaba 1.25 <!--
653     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#ExtSubset">Well-formedness constraint: External Subset</a>
654     <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#PE-between-Decls">Well-formedness constraint: PE Between Declarations</a>
655 wakaba 1.14 -->
656 wakaba 1.27
657     <!--
658     Inpossible to test:
659     "In the absence of external character encoding information (such as MIME
660     headers), parsed entities which are stored in an encoding other than UTF-8
661     or UTF-16 MUST begin with a text declaration"
662     -->
663 wakaba 1.14 </div>
664    
665     <div class="section" id=checking-dom>
666     <h2>Checking <abbr>DOM</abbr></h2>
667    
668     <p>The following algorithms and definitions are applied to
669     <abbr>XML</abbr> documents; especially, they are not applied
670     to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p>
671 wakaba 1.9
672     <div class=section id=definitions>
673     <h3>Definitions</h3>
674    
675 wakaba 1.1 <p>The <dfn id=xml-version><abbr>XML</abbr> version</dfn> of a node is
676     the <abbr>XML</abbr> version of the document to which the node belongs.
677     For a <code>Documemt</code> node, the <abbr>XML</abbr> version
678     of the document is the value of the <code>xmlVersion</code>
679 wakaba 1.9 attribute of the node. For a <code>DocumentType</code> node whose
680     <code>ownerDocument</code> attribute is set to <code>null</code>,
681     the <abbr>XML</abbr> version of the document is <code>1.0</code><!--
682     since createDocumentType [DOM3CORE] assumes XML 1.0 [XML10TE] -->.
683 wakaba 1.1 For any other node, the <abbr>XML</abbr> version of the document
684     is that of the <code>Document</code> node contained in the
685     <code>ownerDocument</code> attribute of the node.</p>
686    
687 wakaba 1.9 </div>
688    
689 wakaba 1.10
690     <div class=section id=checking-components>
691 wakaba 1.19 <h3>Conformance Checking Algorithms for Components</h3>
692 wakaba 1.10
693 wakaba 1.19 <p>To
694     <dfn id=algorithm-to-validate-an-xml-character-data title="validate an XML string">to
695     validate an <abbr>XML</abbr> string (<dfn id=var-s><var>s</var></dfn>)</dfn>,
696     the following algorithm <em class=rfc2119>MUST</em> be used:</p>
697 wakaba 1.10 <ol>
698 wakaba 1.11 <li>If <var>s</var> contains a character that is <em>not</em> in
699     the character class <a href="#class-Char10"><code>Char10</code></a>,
700     then raise an
701     <a href="#xml-well-formedness-error" id=wfe-illegal-char><code>xml-well-formedness-error</code></a>.</li>
702     <li>If <var>s</var> contains a character that is in the character
703     class <a href="#class-CompatChar10"><code>CompatChar10</code></a>,
704     then raise an
705     <a href="#xml-misc-warning" id=xmw-compat-char><code>xml-misc-warning</code></a>.</li>
706     <li>If <var>s</var> contains a character that is in the character
707     class <a href="#class-ControlChar10"><code>ControlChar10</code></a>,
708     then raise an
709     <a href="#xml-misc-warning" id=xmw-control-char><code>xml-misc-warning</code></a>.</li>
710     <li class=ed>@@ XML 1.1 support</li>
711 wakaba 1.13 <li>If <var>s</var> contains a <code class=char>U+000D</code>
712     <code class=charname>CARRIAGE RETURN</code> character, then
713     raise a
714     <a href="#round-trip-error" id=rte-cr><code>round-trip-error</code></a>.
715     <span class=ed>@@ We should not raise duplicate errors for U+000D
716     in attribute values. In addition, we should support a mode where
717     U+000D will be serialized as &#x000D; (so that no round-trip-error
718     will be raised).</span></li>
719 wakaba 1.10 </ol>
720    
721 wakaba 1.19 <p>To
722     <dfn id=algorithm-to-validate-a-name title="validate a Name">validate a
723     <code>Name</code> (<dfn id=var-name-s><var>s</var></dfn>)</dfn>, the following
724     algorithm <em class=rfc2119>MUST</em> be used:</p>
725 wakaba 1.10 <ol>
726 wakaba 1.19 <li>If <var>s</var> is an empty string, then raise an
727     <a href="#xml-well-formedness-error" id=wfe-name-empty><code>xml-well-formedness-error</code></a>.
728     Abort these steps.</li>
729     <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate
730     <var>s</var> as an <abbr>XML</abbr> string</a>.</li>
731     <li>If the first character in <var>s</var> is a character that is
732     <em>not</em> in the character class
733     <a href="#class-NameStartChar10"><code>NameStartChar10</code></a>, then raise
734     an
735     <a href="#xml-well-formedness-error" id=wfe-name-startchar><code>xml-well-formedness-error</code></a>.</li>
736     <li>If a character other than the first character in <var>s</var> is a
737     character that is <em>not</em> in the character class
738     <a href="#class-NameChar10"><code>NameChar10</code></a>, then raise an
739     <a href="#xml-well-formedness-error" id=wfe-name-char><code>xml-well-formedness-error</code></a>.</li>
740 wakaba 1.12 <li>If <var>s</var> begins with the string <code>xml</code> (in any
741     case combination), then raise an
742     <a href="#xml-misc-warning" id=xmw-reserved-name><code>xml-misc-warning</code></a>.
743     <span class=ed>@@ except for attribute names <code>xml:lang</code>,
744 wakaba 1.25 <code>xml:space</code><!--, <code>xml:base</code>, <code>xml:id</code>,
745 wakaba 1.12 <code>xmlns</code>, <code>xmlns:<var>*</var></code>,
746 wakaba 1.25 pi name <code>xml-stylesheet</code>-->.</span><!--
747 wakaba 1.15 "names beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) are reserved for standardization in this or future versions of this specification.":
748 wakaba 1.19 xmlns, xml-stylesheet, xml:base and xml:id specifications violate to this sentense!
749 wakaba 1.15 --></li>
750 wakaba 1.12 <!-- COLON in Name is a lowercase "should not" in a Note of [XML10],
751     [XML11]. -->
752 wakaba 1.19 <li class=ed>@@ XML 1.1 support</li>
753 wakaba 1.10 </ol>
754    
755 wakaba 1.19 <p>To
756     <dfn id=algorithm-to-validate-an-ncname title="validate an NCName">validate
757     an <code>NCName</code> (<dfn id=var-ncname-s><var>s</var></dfn>)</dfn>, the
758     following algorithm <em class=rfc2119>MUST</em> be used:</p>
759 wakaba 1.10 <ol>
760 wakaba 1.19 <li><a href="#algorithm-to-validate-a-name" title="validate a Name">Validate
761     <var>s</var> as a <code>Name</code></a>.</li>
762 wakaba 1.10 <li class=ed>@@</li>
763     </ol>
764    
765 wakaba 1.18 <p>To
766     <dfn id=algorithm-to-validate-a-public-identifier title="validate a public identifier">validate
767 wakaba 1.10 a public identifier (<dfn id=var-pid><var>pid</var></dfn>)</dfn>, the
768 wakaba 1.18 following algorithm <em class=rfc2119>MUST</em> be used:</p>
769 wakaba 1.10 <ol>
770 wakaba 1.20 <li>If <var>pid</var> is <code>null</code>, abort these steps.</li>
771     <li>If <var>pid</var> contains a character that is <em>not</em> in the
772     character class <a href="#class-PubidChar"><code>PubidChar</code></a>, then
773     raise an
774     <a href="#xml-well-formedness-error" id=wfe-pubid-char><code>xml-well-formedness-error</code></a>.</li>
775 wakaba 1.10 <li>If <var>pid</var> contains one of <code class=char>U+0009</code>
776     <code class=charname>CHARACTER TABULATION</code>,
777     <code class=char>U+000A</code> <code class=charname>CARRIAGE RETURN</code>,
778     and <code class=char>U+000D</code> <code class=charname>LINE FEED</code>
779     characters, if the first character of <var>pid</var> is
780     <code class=char>U+0020</code> <code class=charname>SPACE</code> character,
781     if the last character of <var>pid</var> is <code class=char>U+0020</code>
782     <code class=charname>SPACE</code> character, or if there is a
783     <code class=char>U+0020</code> <code class=charname>SPACE</code> character
784     immediately followed by another <code class=char>U+0020</code>
785     <code class=charname>SPACE</code> character in <var>pid</var>, then it is a
786 wakaba 1.18 <a href="#round-trip-error" id=rte-pubid-space><code>round-trip-error</code></a>.
787     <span class=ed>Is this really a roundtripness problem? XML spec
788     does only define the way to match public identifiers in fact, no
789     canonical form.</span></li>
790 wakaba 1.10 </ol>
791    
792 wakaba 1.18 <p>To
793     <dfn id=algorithm-to-validate-a-system-identifier title="validate a system identifier">validate
794     a system identifier (<dfn id=var-sid><var>sid</var></dfn>)</dfn>, the
795     following algorithm <em class=rfc2119>MUST</em> be used:</p>
796     <ol>
797     <li>If <var>sid</var> is <code>null</code>, abort these steps.</li>
798 wakaba 1.19 <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate
799     <var>sid</var> as an <abbr>XML</abbr> string</a>.</li>
800 wakaba 1.18 <li>If <var>sid</var> contains both <code class=char>U+0022</code>
801     <code class=charname>QUOTATION MARK</code> (<code class=char>"</code>) and
802     <code class=char>U+0027</code> <code class=charname>APOSTROPHE</code>
803     (<code class=char>'</code>) characters, raise an
804     <a href="#xml-well-formedness-error" id=wfe-sid-lit><code>xml-well-formedness-error</code></a>.</li>
805     <li>If <var>sid</var> contains at least one <code class=char>U+0023</code>
806     <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>)
807     character, then raise an
808     <a href="#xml-misc-error" id=xme-sid-fragment><code>xml-misc-error</code></a>.</li>
809     <li class=ed>@@ If <var>sid</var> cannot be converted to a URI
810     reference, then raise a fact-level error (xml-misc-warning?).<!--
811     XML 1.0 has no conformance language for system identifier being
812     a URI reference. --></li>
813     </ol>
814    
815 wakaba 1.10 </div>
816    
817 wakaba 1.9 <div class=section id=checking-node>
818     <h3>Checking <code>Node</code></h3>
819    
820 wakaba 1.1 <p>The algorithm <dfn title="to check a node" id=algorithm-to-check-a-node>to
821     check a node (<dfn id=var-n><var>n</var></dfn>)</dfn> is defined as
822     following:</p>
823     <dl class=switch>
824     <dt>If <var>n</var> is an <code>Attr</code> node</dt>
825     <dd>
826     <ol>
827 wakaba 1.18 <li><a href="#algorithm-to-validate-an-ncname">Validate the
828 wakaba 1.1 <code>localName</code> attribute value as an <code>NCName</code></a>.</li>
829     <li>If the <code>prefix</code> attribute value is different from
830 wakaba 1.18 <code>null</code>, then <a href="#algorithm-to-validate-an-ncname">validate
831 wakaba 1.1 the <code>prefix</code> attribute value as an <code>NCName</code></a>.</li>
832 wakaba 1.8 <li>For each node <dfn id=var-attr-nc><var>n<sub><var>c</var></sub></var></dfn> in the
833 wakaba 1.4 <code>childNodes</code> list of <var>n</var>,
834 wakaba 1.8 <ol>
835     <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a
836     <code>Text</code> or <code>EntityReference</code> node, then it is an
837     <a href="#xml-well-formedness-error" id=wfe-attr-child><code>xml-well-formedness-error</code></a>.</li>
838     <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
839     <code>EntityReference</code> node, then it is an
840     <a href="#entity-error" id=ee-attr-er><code>entity-error</code></a>.</li>
841     <li>Otherwise,
842     <a href="#algorithm-to-check-a-node" title="check a node">check
843     <var>n<sub><var>c</var></sub></var></a> recusrively.</li>
844     </ol></li>
845 wakaba 1.13 <li>If <code>nodeName</code> attribute of <var>n</var> is
846     <code>xml:space</code> <span class=ed>@@ or {xml namespace}:space ?</span>
847     and <code>value</code> attribute of <var>n</var> is neither
848     <code>default</code> nor <code>preserve</code>, then it is an
849     <a href="#xml-misc-error" id=xme-attr-xml-space><code>xml-misc-error</code></a>.<!--
850     Note that <!ATTLIST e xml:space (default|preserve) "a">...
851     <e xml:space="default"/> is conforming and valid. --></li>
852     <li class=ed>@@ xml:lang value is not a language tag [RFC 3066 or its
853     successor] or an empty string, then xml-misc-warning
854     (a "fact"-level error; not an XML error).</li>
855 wakaba 1.1 <li class=ed>@@ <code>specified</code>,
856 wakaba 1.15 <code>manakaiAttributeType</code> (#ValueType Validity constraint: Attribute Value Type)</li>
857 wakaba 1.13 <!-- xml:space MUST be declared to be valid. -->
858 wakaba 1.16 <li>Let <dfn id=var-v><var>v</var></dfn> be the value of the
859     attribute <code>value</code> of <var>n</var>.</li>
860     <li>Validate the <var>n</var> against the <span class=ed>declared
861     type</span> as following:
862     <dl class=switch>
863     <dt class=ed><code>ID_ATTR</code></dt>
864     <dd>
865     <ol>
866     <li><span class=ed>Validate <var>v</var> as an
867     <code>Name</code>.</span> If it fails, then raise an
868     <a href="#xml-validity-error" id=vc-id-name><code>xml-validity-error</code></a>.</li>
869     <li><span class=ed>If <code>ID</code> <var>v</var> is defined,</span>
870     then raise an
871     <a href="#xml-validity-error" id=vc-id-duplication><code>xml-validity-error</code></a>.</li>
872     </ol>
873     </dd>
874     <dt class=ed>IDREF_ATTR</dt>
875     <dd>
876     <ol>
877     <li><span class=ed>Validate <var>v</var> as an
878     <code>Name</code>.</span> If it fails, then raise an
879     <a href="#xml-validity-error" id=vc-idref-name><code>xml-validity-error</code></a>.</li>
880     <li><span class=ed>If <code>ID</code> <var>v</var> is NOT
881     defined,</span> then raise an
882     <a href="#xml-validity-error" id=vc-idref-match><code>xml-validity-error</code></a>.</li>
883     </ol>
884     </dd>
885     <dt class=ed>IDREFS_ATTR</dt>
886     <dd class=ed>@@</dd>
887     <dt class=ed>ENTITY_ATTR</dt>
888     <dd>
889     <ol>
890     <li><span class=ed>Validate <var>v</var> as an
891     <code>Name</code>.</span> If it fails, then raise an
892     <a href="#xml-validity-error" id=vc-entname-name><code>xml-validity-error</code></a>.</li>
893     <li><span class=ed>If <code>Entity</code> <var>v</var> is NOT
894     defined,</span> then raise an
895     <a href="#xml-validity-error" id=vc-entname-match><code>xml-validity-error</code></a>.</li>
896     </ol>
897     </dd>
898     <dt class=ed>ENTITIES_ATTR</dt>
899     <dd class=ed>@@</dd>
900     <dt class=ed>NMTOKEN_ATTR</dt>
901     <dd>
902     <ol>
903     <li><span class=ed>Validate <var>v</var> as an
904     <code>Nmtoken</code>.</span> If it fails, then raise an
905     <a href="#xml-validity-error" id=vc-nmtok-name><code>xml-validity-error</code></a>.</li>
906     </ol>
907     </dd>
908     <dt class=ed>NMTOKENS_ATTR</dt>
909     <dd class=ed>@@</dd>
910     <dt class=ed>NOTATION_ATTR</dt>
911     <dd class=ed><var>v</var> must be one of enumerated values.
912     If not, then raise an
913     <a href="#xml-validity-error" id=vc-notatn-match><code>xml-validity-error</code></a>.</dd>
914     <dt class=ed>ENUMERATED_ATTR</dt>
915     <dd class=ed><var>v</var> must be one of enumerated values.
916     If not, then raise an
917     <a href="#xml-validity-error" id=vc-enum><code>xml-validity-error</code></a>.</dd>
918     <dt class=ed>@@</dt>
919     </dl>
920     </li>
921 wakaba 1.17 <li>If <span class=ed>type ID and default is NOT #IMPLIED or #REQUIRED</span>, then
922 wakaba 1.16 raise an
923     <a href="#xml-validity-error" id=vc-id-default><code>xml-validity-error</code></a>.</li>
924 wakaba 1.17 <li class=ed>@@ #FixedAttr Validity constraint: Fixed Attribute Default</li>
925     <li class=ed>@@ strict serialization error for U+000D, U+000A, and
926     U+0009 characters, leading/trailing U+0020, and U+0020{2,} string?</li>
927 wakaba 1.1 </ol>
928     </dd>
929     <dt>If <var>n</var> is an <code>AttributeDefinition</code> node</dt>
930 wakaba 1.8 <dd>
931     <ol>
932     <li class=ed></li>
933 wakaba 1.13 <li>If <code>nodeName</code> attribute of <var>n</var> is
934     <code>xml:space</code> <span class=ed>@@ or {xml namespace}:space ?</span>
935     and <span class=ed>its declared type is different from (default|preserve),
936 wakaba 1.22 (preserve|default), (default), or (preserve)</span>, then raise an
937 wakaba 1.13 <a href="#xml-misc-error" id=xme-at-xml-space><code>xml-misc-error</code></a>.</li>
938 wakaba 1.8 <li>For each node <dfn id=var-ad-nc><var>n<sub><var>c</var></sub></var></dfn> in the
939     <code>childNodes</code> list of <var>n</var>,
940     <ol>
941     <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a
942     <code>Text</code> or <code>EntityReference</code> node, then it is an
943     <a href="#xml-well-formedness-error" id=wfe-at-child><code>xml-well-formedness-error</code></a>.</li>
944     <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
945     <code>EntityReference</code> node, then it is an
946     <a href="#entity-error" id=ee-at-er><code>entity-error</code></a>.</li>
947     <li>Otherwise,
948     <a href="#algorithm-to-check-a-node" title="check a node">check
949     <var>n<sub><var>c</var></sub></var></a> recusrively.</li>
950     </ol></li>
951 wakaba 1.16 <li class=ed>If <code>NOTATION_ATTR</code>, enumerated values MUST
952     be declared. If not, then raise an
953     <a href="#xml-validity-error" id=vc-notatn-declared><code>xml-validity-error</code></a>.</li>
954     <li class=ed>If <code>NOTATION_ATTR</code> or <code>ENUMERATED_ATTR</code>,
955     values MUST all be distinct. If not, then raise an
956     <a href="#xml-validity-error" id=vc-no-duplicate-tokens><code>xml-validity-error</code></a>.</li>
957     <li class=ed>If <code>NOTATION_ATTR</code> on an <code>EMPTY</code>
958     element, then raise an
959     <a href="#xml-validity-error" id=vc-no-notation-empty><code>xml-validity-error</code></a>.</li>
960 wakaba 1.17 <li class=ed>@@ #defattrvalid Validity constraint: Attribute Default Value Syntactically Correct</li>
961 wakaba 1.8 </ol>
962     </dd>
963 wakaba 1.1 <dt>If <var>n</var> is a <code>CDATASection</code> node</dt>
964     <dd>
965     <ol>
966 wakaba 1.19 <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the
967 wakaba 1.1 <code>data</code> attribute value as an <abbr>XML</abbr> character
968     data</a>.</li>
969     <li>If the <code>data</code> attribute value contains
970 wakaba 1.12 a string <code>]]></code>, then raise an
971     <a href="#xml-well-formedness-error" id=wfe-cs-mse><code>xml-well-formedness-error</code></a>.<!-- "for compatibility" --></li>
972 wakaba 1.1 <li>If the <code>childNodes</code> list of <var>n</var> contains
973     any nodes, they are in
974 wakaba 1.8 <a href="#xml-well-formedness-error" id=wfe-cs-child><code>xml-well-formedness-error</code></a>.</li>
975 wakaba 1.1 </ol>
976     </dd>
977     <dt>If <var>n</var> is a <code>Comment</code> node</dt>
978     <dd>
979     <ol>
980 wakaba 1.12 <li>Raise an
981     <a href="#round-trip-warning" id=rtw-comment><code>round-trip-warning</code></a>.</li>
982 wakaba 1.19 <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the
983 wakaba 1.1 <code>data</code> attribute value as an <abbr>XML</abbr> character
984     data</a>.</li>
985     <li>If the <code>data</code> attribute value contains
986     a string <code>--</code>, or if it ends with a character
987 wakaba 1.12 <code>-</code>, then raise an
988     <a href="#xml-well-formedness-error" id=wfe-comment-com><code>xml-well-formedness-error</code></a>.<!--
989     "for compatibility" --></li>
990 wakaba 1.1 <li>If the <code>childNodes</code> list of <var>n</var> contains
991     any nodes, they are in
992 wakaba 1.8 <a href="#xml-well-formedness-error" id=wfe-comment-child><code>xml-well-formedness-error</code></a>.</li>
993 wakaba 1.1 </ol>
994     </dd>
995     <dt>If <var>n</var> is a <code>Document</code> node</dt>
996     <dd>
997     <ol>
998     <li>If <a href="#xml-version"><abbr>XML</abbr> version</a> of <var>n</var>
999     is different from <code>1.0</code> or <code>1.1</code>,
1000     then it is an <code class=ed>unknown-error?</code>.</li>
1001     <li>If the <code>xmlEncoding</code> attribute value does <em>not</em>
1002     match to <code>[A-Za-z] ([A-Za-z0-9._] | '-')*</code>
1003 wakaba 1.8 <span class=ed>@@ formal def</span>, then it is an
1004 wakaba 1.1 <a href="#xml-well-formedness-error" id=wfe-encoding><code>xml-well-formedness-error</code></a>.</li>
1005     <li>The <code>childNodes</code> list of <var>n</var> have to
1006     consist of zero or more <code>Comment</code> and/or
1007     <code>ProcessingInstruction</code> nodes, followed by
1008     an optional <code>DocumentType</code> node, followed
1009     by zero or more <code>Comment</code> and/or
1010     <code>ProcessingInstruction</code> nodes, followed by
1011     an <code>Element</code> node, followed
1012     by zero or more <code>Comment</code> and/or
1013 wakaba 1.8 <code>ProcessingInstruction</code> nodes. Any violation to this is an
1014 wakaba 1.1 <a href="#xml-well-formedness-error" id=wfe-document-child><code>xml-well-formedness-error</code></a>.</li>
1015 wakaba 1.8 <li>For each node <dfn id=var-document-nc><var>n<sub><var>c</var></sub></var></dfn>
1016     in the <code>childNodes</code> list of <var>n</var>,
1017     <ol>
1018     <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1019     <code>EntityReference</code> node, then
1020     <a href="#algorithm-to-check-a-node" title="check a node">check
1021     <var>n<sub><var>c</var></sub></var></a> recursively.</li>
1022     </ol></li>
1023 wakaba 1.1 <li class=ed>@@ <code>allDeclarationsProcessed</code></li>
1024     </ol>
1025     </dd>
1026     <dt>If <var>n</var> is a <code>DocumentFragment</code> node</dt>
1027     <dd>
1028     <ol>
1029 wakaba 1.8 <li>For each node <dfn id=var-df-nc><var>n<sub><var>c</var></sub></var></dfn>
1030     in the <code>childNodes</code> list of <var>n</var>,
1031     <ol>
1032     <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1033     <code>Element</code>, <code>Text</code>, <code>CDATASection</code>,
1034     <code>Comment</code>, <code>ProcessingInstruction</code>, or
1035     <code>EntityReference</code> node, then it is an
1036     <a href="#xml-well-formedness-error" id=wfe-df-child><code>xml-well-formedness-error</code></a>.</li>
1037     <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
1038     <code>EntityReference</code> node, then it is an
1039     <a href="#entity-error" id=ee-df-er><code>entity-error</code></a>.</li>
1040     <li>Otherwise,
1041     <a href="#algorithm-to-check-a-node" title="check a node">check
1042     <var>n<sub><var>c</var></sub></var></a> recursively.</li>
1043     </ol></li>
1044 wakaba 1.1 </ol>
1045     </dd>
1046     <dt>If <var>n</var> is a <code>DocumentType</code> node</dt>
1047     <dd>
1048     <ol>
1049 wakaba 1.18 <li><a href="#algorithm-to-validate-an-ncname">Validate the
1050 wakaba 1.1 <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1051 wakaba 1.13 <li>Follow the following substeps:
1052     <ol>
1053     <li>If <code>ownerDocument</code> attribute of <var>n</var> is
1054     <code>null</code>, then abort these substeps.</li>
1055     <li>If <code>documentElement</code> attribute of the node
1056     set to <code>ownerDocument</code> attribute of <var>n</var> is
1057     <code>null</code>, then abort these substeps.</li>
1058     <li>If <code>nodeName</code> attribute of the node set to
1059     <code>documentElement</code> attribute of the node set to
1060     <code>ownerDocument</code> attribute of <var>n</var> is
1061     different from <code>nodeName</code> of <var>n</var>,
1062     then raise an
1063     <a href="#xml-validity-error" id=vc-roottype><code>xml-validity-error</code></a>.</li></li>
1064     </ol>
1065     </li>
1066 wakaba 1.5 <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate
1067     the <code>publicId</code> attribute value as a public identifier</a>.</li>
1068 wakaba 1.18 <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate
1069     the <code>systemId</code> attribute value as a system identifier</a>.</li>
1070     <li>If the <code>publicId</code> attribute value of <var>n</var> is
1071     <em>not</em> <code>null</code> and the <code>systemId</code> attribute
1072     value of <var>n</var> is <code>null</code>, then raise an
1073     <a href="#xml-well-formedness-error" id=wfe-dt-sid><code>xml-well-formedness-error</code></a>.
1074     <span class=ed>@@ publicId == null? Or, publicId == ""</span></li>
1075 wakaba 1.8 <li>For each node <dfn id=var-dt-nc><var>n<sub><var>c</var></sub></var></dfn>
1076     in the <code>childNodes</code> list of <var>n</var>,
1077     <ol>
1078     <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a
1079     <code>ProcessingInstruction</code> node, then it is an
1080     <a href="#xml-well-formedness-error" id=wfe-dt-child><code>xml-well-formedness-error</code></a>.
1081     <span class=ed>@@ ref to manakai's extensions</span></li>
1082     <li>Otherwise, <!-- if n_c is not an EntityReference node, -->
1083     <a href="#algorithm-to-check-a-node" title="check a node">check
1084     <var>n<sub><var>c</var></sub></var></a> recusrively.</li>
1085     </ol></li>
1086 wakaba 1.18 <li>For each node in the <code>entities</code>, <code>notations</code>,
1087     and <code>elementTypes</code> lists of <var>n</var>,
1088     <a href="#algorithm-to-check-a-node" title="check a node">check the
1089     node</a> recursively.</li>
1090     <li class=ed>@@ externally declared?</li>
1091 wakaba 1.26 <li>If the <code>NamedNodeMap</code> object in the <code>entities</code>
1092     attribute of <var>n</var> does not contain <code>Entity</code> nodes
1093     whose <code>nodeName</code> attribute are <code>amp</code>,
1094     <code>lt</code>, <code>gt</code>, <code>apos</code>, and <code>quot</code>
1095     then raise
1096     <a href="#xml-misc-recommentation" id=xmr-predefined><code>xml-misc-recommendation</code></a>(s).
1097 wakaba 1.1 </ol>
1098     </dd>
1099     <dt>If <var>n</var> is an <code>Element</code> node</dt>
1100     <dd>
1101     <ol>
1102 wakaba 1.18 <li><a href="#algorithm-to-validate-an-ncname">Validate the
1103 wakaba 1.1 <code>localName</code> attribute value as an <code>NCName</code></a>.</li>
1104     <li>If the <code>prefix</code> attribute value is different from
1105 wakaba 1.18 <code>null</code>, then <a href="#algorithm-to-validate-an-ncname">validate
1106 wakaba 1.1 the <code>prefix</code> attribute value as an <code>NCName</code></a>.</li>
1107 wakaba 1.8 <li>For each node <dfn id=var-element-nc><var>n<sub><var>c</var></sub></var></dfn>
1108     in the <code>childNodes</code> list of <var>n</var>,
1109     <ol>
1110     <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1111     <code>Element</code>,
1112     <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,
1113     <code>ProcessingInstruction</code>, or
1114     <code>EntityReference</code> node, then it is an
1115     <a href="#xml-well-formedness-error" id=wfe-element-child><code>xml-well-formedness-error</code></a>.</li>
1116     <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
1117     <code>EntityReference</code> node, then it is an
1118     <a href="#entity-error" id=ee-element-er><code>entity-error</code></a>.</li>
1119     <li>Otherwise,
1120     <a href="#algorithm-to-check-a-node" title="check a node">check
1121     <var>n<sub><var>c</var></sub></var></a> recursively.</li>
1122     </ol></li>
1123 wakaba 1.15 <li class=ed>@@ #elementvalid Validity constraint: Element Valid</li>
1124 wakaba 1.18 <li>Let <var>attrs</var> be the value of the <code>attribute</code>
1125     attribute of <var>n</var>. Check conformance of <var>attrs</var>
1126     as following:
1127     <ol>
1128     <li>If <var>attrs</var> contains an <code>Attr</code> node whose
1129     <code>nodeName</code> attribute value is equal to that of another
1130     <code>Attr</code> node in <var>attrs</var>, then raise an
1131     <a href="#xml-well-formedness-error" id=wfe-uniqattspec><code>xml-well-formedness-error</code></a>.<!--
1132     #uniqattspec Well-formedness constraint: Unique Att Spec --></li>
1133     <li class=ed>@@ #RequiredAttr Validity constraint: Required Attribute</li>
1134     </ol>
1135     </li>
1136 wakaba 1.8 </ol>
1137     </dd>
1138     <dt>If <var>n</var> is an <code>ElementTypeDefinition</code> node</dt>
1139     <dd>
1140     <ol>
1141     <li class=ed></li>
1142 wakaba 1.1 <li>If the <code>childNodes</code> list of <var>n</var> contains
1143 wakaba 1.8 any nodes, they are in
1144     <a href="#xml-well-formedness-error" id=wfe-et-child><code>xml-well-formedness-error</code></a>.</li>
1145 wakaba 1.16 <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>
1146     <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>
1147     <li class=ed>@@ #vc-MixedChildrenUnique
1148     Validity constraint: No Duplicate Types</li>
1149     <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>
1150     <li>If there is more than one <code>AttributeDefinition</code> node
1151     with <span class=ed>attribute type <code>ID</code></span> in the
1152     <code>NamedNodeMap</code> list contained in the
1153     <code>attributeDefinitions</code> attribute of <var>n</var>, then raise an
1154     <a href="#xml-validity-error" id=vc-one-id-per-el><code>xml-validity-error</code></a>.</li>
1155     <li>If there is more than one <code>AttributeDefinition</code> node
1156     with <span class=ed>attribute type <code>NOTATION</code></span> in the
1157     <code>NamedNodeMap</code> list contained in the
1158     <code>attributeDefinitions</code> attribute of <var>n</var>, then raise an
1159     <a href="#xml-validity-error" id=vc-one-notation-per><code>xml-validity-error</code></a>.</li>
1160     <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>
1161 wakaba 1.1 </ol>
1162     </dd>
1163 wakaba 1.18 <dt>If <var>n</var> is an <code>Entity</code> node whose
1164     <code>notationName</code> attribute value is <code>null</code> (i.e. a
1165     parsed entity)</dt>
1166 wakaba 1.1 <dd>
1167     <ol>
1168 wakaba 1.18 <li>Raise an
1169     <a href="#entity-error" id=ee-entity-node><code>entity-error</code></a>.</li>
1170     <li><a href="#algorithm-to-validate-an-ncname">Validate the
1171 wakaba 1.1 <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1172 wakaba 1.5 <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate
1173     the <code>publicId</code> attribute value as a public identifier</a>.</li>
1174 wakaba 1.18 <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate
1175     the <code>systemId</code> attribute value as a system identifier</a>.</li>
1176     <li>If the <code>publicId</code> attribute value of <var>n</var> is
1177     <em>not</em> <code>null</code> and the <code>systemId</code> attribute
1178     value of <var>n</var> is <code>null</code>, then raise an
1179     <a href="#xml-well-formedness-error" id=wfe-entity-sid><code>xml-well-formedness-error</code></a>.</li>
1180 wakaba 1.8 <li>For each node <dfn id=var-entity-nc><var>n<sub><var>c</var></sub></var></dfn>
1181     in the <code>childNodes</code> list of <var>n</var>,
1182     <ol>
1183     <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1184     <code>Element</code>,
1185     <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,
1186     <code>ProcessingInstruction</code>, or <code>EntityReference</code>
1187     node, then it is an
1188     <a href="#xml-well-formedness-error" id=wfe-entity-child><code>xml-well-formedness-error</code></a>.</li>
1189     <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
1190     <code>EntityReference</code> node, then it is an
1191     <a href="#entity-error" id=ee-er-er><code>entity-error</code></a>.</li>
1192     <li>Otherwise,
1193     <a href="#algorithm-to-check-a-node" title="check a node">check
1194     <var>n<sub><var>c</var></sub></var></a> recursively.</li>
1195     </ol></li>
1196 wakaba 1.1 </ol>
1197     </dd>
1198 wakaba 1.18 <dt>If <var>n</var> is an <code>Entity</code> node whose
1199     <code>notationName</code> attribute value is <em>not</em> <code>null</code>
1200     (i.e. an unparsed entity)</dt>
1201     <dd>
1202     <ol>
1203     <li><a href="#algorithm-to-validate-an-ncname">Validate the
1204     <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1205     <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate
1206     the <code>publicId</code> attribute value as a public identifier</a>.</li>
1207     <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate
1208     the <code>systemId</code> attribute value as a system identifier</a>.</li>
1209     <li>If the <code>systemId</code> attribute value of <var>n</var> is
1210     <code>null</code>, then raise an
1211     <a href="#xml-well-formedness-error" id=wfe-uentity-sid><code>xml-well-formedness-error</code></a>.</li>
1212     <li><a href="#algorithm-to-validate-an-ncname">Validate the
1213     <code>notationName</code> attribute value of <var>n</var> as an
1214     <code>NCName</code></a>.</li>
1215     <li class=ed>@@ #not-declared Validity constraint: Notation Declared</li>
1216     <li>If the <code>childNodes</code> list of <var>n</var> contains
1217     any nodes, they are in
1218     <a href="#xml-well-formedness-error" id=wfe-uentity-child><code>xml-well-formedness-error</code></a>.</li>
1219     </ol>
1220     </dd>
1221 wakaba 1.1 <dt>If <var>n</var> is an <code>EntityReference</code> node</dt>
1222     <dd>
1223     <ol>
1224     <li>An <a href="#entity-error" id=ee-er-node><code>entity-error</code></a>.</li>
1225 wakaba 1.18 <li><a href="#algorithm-to-validate-an-ncname">Validate the
1226 wakaba 1.1 <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1227 wakaba 1.8 <li>For each node <dfn id=var-er-nc><var>n<sub><var>c</var></sub></var></dfn>
1228     in the <code>childNodes</code> list of <var>n</var>,
1229     <ol>
1230     <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1231     <code>Element</code>,
1232     <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,
1233     <code>ProcessingInstruction</code>, or <code>EntityReference</code>
1234     node, then it is an
1235     <a href="#xml-well-formedness-error" id=wfe-er-child><code>xml-well-formedness-error</code></a>.</li>
1236     <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1237     <code>EntityReference</code> node, then it is an
1238     <a href="#entity-error" id=ee-entity-er><code>entity-error</code></a>.</li>
1239     <li>Otherwise,
1240     <a href="#algorithm-to-check-a-node" title="check a node">check
1241     <var>n<sub><var>c</var></sub></var></a> recursively.</li>
1242     </ol></li>
1243 wakaba 1.1 </ol>
1244     </dd>
1245     <dt>If <var>n</var> is a <code>Notation</code> node</dt>
1246     <dd>
1247     <ol>
1248 wakaba 1.18 <li><a href="#algorithm-to-validate-an-ncname">Validate the
1249 wakaba 1.1 <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1250 wakaba 1.5 <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate
1251     the <code>publicId</code> attribute value as a public identifier</a>.</li>
1252 wakaba 1.18 <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate
1253     the <code>systemId</code> attribute value as a system identifier</a>.</li>
1254 wakaba 1.1 <li>If the <code>childNodes</code> list of <var>n</var> contains
1255     any nodes, they are in
1256 wakaba 1.8 <a href="#xml-well-formedness-error" id=wfe-notation-child><code>xml-well-formedness-error</code></a>.</li>
1257 wakaba 1.1 </ol>
1258     </dd>
1259     <dt>If <var>n</var> is a <code>ProcessingInstruction</code> node</dt>
1260     <dd>
1261     <ol>
1262 wakaba 1.13 <li>If the <code>target</code> attribute value matches to the string
1263     <code>xml</code> in any case combination, then raise a
1264     <a href="#xml-well-formedness-error" id=wfe-pi-xml><code>xml-well-formedness-error</code></a>.</li>
1265 wakaba 1.18 <li>Otherwise, <a href="#algorithm-to-validate-an-ncname">validate the
1266 wakaba 1.1 <code>target</code> attribute value as an <code>NCName</code></a>.</li>
1267 wakaba 1.13 <li>Then,
1268 wakaba 1.19 <a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">validate
1269 wakaba 1.13 the <code>data</code> attribute value as an <abbr>XML</abbr> character
1270 wakaba 1.1 data</a>.</li>
1271 wakaba 1.13 <li>If the <code>data</code> attribute value contains a string
1272     <code>?></code>, then raise a
1273     <a href="#xml-well-formedness-error" id=wfe-pi-pic><code>xml-well-formedness-error</code></a>.</li>
1274     <li>If the <code>data</code> attribute value starts with either
1275     <code class=char>U+0009</code> <code class=charname>CHARACTER
1276     TABULATION</code>, <code class=char>U+000A</code> <code class=charname>LINE
1277     FEED</code>, <code class=char>U+000D</code> <code class=charname>CARRIAGE
1278     RETURN</code>, or <code class=char>U+0020</code>
1279     <code class=charname>SPACE</code> character, then raise a
1280     <a href="#round-trip-error" id=rte-pi-s><code>round-trip-error</code></a>.</li>
1281 wakaba 1.1 <li>If the <code>childNodes</code> list of <var>n</var> contains
1282 wakaba 1.13 any nodes, then raise an
1283 wakaba 1.8 <a href="#xml-well-formedness-error" id=wfe-pi-child><code>xml-well-formedness-error</code></a>.</li>
1284 wakaba 1.27 <li class=ed>@@ Warn if not declared
1285 wakaba 1.1 </ol>
1286     </dd>
1287     <dt>If <var>n</var> is a <code>Text</code> node</dt>
1288     <dd>
1289     <ol>
1290 wakaba 1.19 <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the
1291 wakaba 1.1 <code>data</code> attribute value as an <abbr>XML</abbr> character
1292     data</a>.</li>
1293     <li>If the <code>childNodes</code> list of <var>n</var> contains
1294     any nodes, they are in
1295 wakaba 1.8 <a href="#xml-well-formedness-error" id=wfe-text-child><code>xml-well-formedness-error</code></a>.</li>
1296 wakaba 1.1 </ol>
1297     </dd>
1298     <dt>Otherwise</dt>
1299     <dd><span class=ed>xml-well-formedness-error? unknown-error?</span></dd>
1300     </dl>
1301    
1302 wakaba 1.11 </div>
1303    
1304     </div>
1305    
1306     <div id=classes class=section>
1307     <h2>Character Classes</h2>
1308    
1309     <p>This section defines a couple of character classes.
1310     These classes are referred to by algorithms specified above.</p>
1311    
1312     <p>Character class <dfn id=class-Char10><code>Char10</code></dfn>
1313     contains the following characters:</p>
1314     <ul>
1315     <li><code class=char>U+0009</code> <code class=charname>CHARACTER
1316     TABULATION</code></li>
1317     <li><code class=char>U+000A</code> <code class=charname>LINE FEED</code></li>
1318     <li><code class=char>U+000D</code> <code class=charname>CARRIAGE
1319     RETURN</code></li>
1320     <li><code class=char>U+0020</code> <code class=charname>SPACE</code>
1321     .. <code class=char>U+D7FF</code></li>
1322     <li><code class=char>U+E000</code> .. <code class=char>U+FFFD</code>
1323     <code class=charname>REPLACEMENT CHARACTER</code></li>
1324     <li><code class=char>U+10000</code> .. <code class=char>U+10FFFF</code></li>
1325     </ul>
1326     <div class="note memo">
1327     <p>This character class contains all characters allowed in the production rule
1328     <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Char"><code>Char</code></a>
1329     of <abbr>XML</abbr> 1.0
1330     <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p>
1331     </div>
1332    
1333     <p>Character class <dfn id=class-CompatChar10><code>CompatChar10</code></dfn>
1334     contains the following characters:</p>
1335     <ul>
1336     <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>
1337     </ul>
1338    
1339     <p>Character class <dfn id=class-ControlChar10><code>ControlChar10</code></dfn>
1340     contains the following characters:</p>
1341     <ul>
1342     <li><code class=char>U+007F</code> <code class=charname>DELETE</code> ..
1343     <code class=char>U+0084</code> <code class=charname>INDEX</code></li>
1344     <li><code class=char>U+0086</code> <code class=charname>START OF SELECTED
1345     AREA</code> .. <code class=char>U+009F</code> <code class=charname>APPLICATION
1346     PROGRAM COMMAND</code></li>
1347     <li><code class=char>U+FDD0</code> .. <code class=char>U+FDEF</code></li>
1348     <li><code class=char>U+1FFFE</code> .. <code class=char>U+1FFFF</code></li>
1349     <li><code class=char>U+2FFFE</code> .. <code class=char>U+2FFFF</code></li>
1350     <li><code class=char>U+3FFFE</code> .. <code class=char>U+3FFFF</code></li>
1351     <li><code class=char>U+4FFFE</code> .. <code class=char>U+4FFFF</code></li>
1352     <li><code class=char>U+5FFFE</code> .. <code class=char>U+5FFFF</code></li>
1353     <li><code class=char>U+6FFFE</code> .. <code class=char>U+6FFFF</code></li>
1354     <li><code class=char>U+7FFFE</code> .. <code class=char>U+7FFFF</code></li>
1355     <li><code class=char>U+8FFFE</code> .. <code class=char>U+8FFFF</code></li>
1356     <li><code class=char>U+9FFFE</code> .. <code class=char>U+9FFFF</code></li>
1357     <li><code class=char>U+AFFFE</code> .. <code class=char>U+AFFFF</code></li>
1358     <li><code class=char>U+BFFFE</code> .. <code class=char>U+BFFFF</code></li>
1359     <li><code class=char>U+CFFFE</code> .. <code class=char>U+CFFFF</code></li>
1360     <li><code class=char>U+DFFFE</code> .. <code class=char>U+DFFFF</code></li>
1361     <li><code class=char>U+EFFFE</code> .. <code class=char>U+EFFFF</code></li>
1362     <li><code class=char>U+FFFFE</code> .. <code class=char>U+FFFFF</code></li>
1363     <li><code class=char>U+10FFFE</code> .. <code class=char>U+10FFFF</code></li>
1364     </ul>
1365     <div class="note memo">
1366     <p>This character class contains the characters listed in the Note in
1367     <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#charsets">Section 2.2</a>
1368     of <abbr>XML</abbr> 1.0
1369     <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>,
1370     as amended by
1371     <a href="http://www.w3.org/XML/xml-V10-4e-errata#E02">errata</a>.</p>
1372 wakaba 1.1 </div>
1373 wakaba 1.19
1374     <p>The character class <dfn id=class-NameStartChar10><code>NameStartChar10</code></dfn>
1375     contains the following characters:</p>
1376     <ul class=ed>
1377     </ul>
1378 wakaba 1.20 <div class="note memo">
1379     <p>This character class contains all characters allowed as the first character
1380     of a string matching to the production rule
1381     <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Name"><code>Name</code></a>
1382     of <abbr>XML</abbr> 1.0
1383     <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p>
1384     </div>
1385 wakaba 1.19
1386     <p>The character class <dfn id=class-NameChar10><code>NameChar10</code></dfn>
1387     contains the following characters:</p>
1388     <ul>
1389     <li>The characters in the character class
1390     <a href="#class-NameStartChar10">NameStartChar10</a>.</li>
1391     <li class=ed></li>
1392     </ul>
1393 wakaba 1.20 <div class="note memo">
1394     <p>This character class contains all characters allowed as the second
1395     character of a string matching to the production rule
1396     <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Name"><code>Name</code></a>
1397     of <abbr>XML</abbr> 1.0
1398     <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p>
1399     </div>
1400    
1401     <p>The character class <dfn id=class-PubidChar><code>PubidChar</code></dfn>
1402     contains the following characters:</p>
1403     <ul>
1404     <li><code class=char>U+0009</code> <code class=charname>CHARACTER
1405     TABULATION</code></li>
1406     <li><code class=char>U+000A</code> <code class=charname>LINE FEED</code></li>
1407     <li><code class=char>U+000D</code> <code class=charname>CARRIAGE
1408     RETURN</code></li>
1409     <li><code class=char>U+0020</code> <code class=charname>SPACE</code></li>
1410     <li><code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>
1411     (<code class=char>!</code>)</li>
1412     <li><code class=char>U+0023</code> <code class=charname>DOLLAR SIGN</code>
1413     (<code class=char>$</code>)</li>
1414     <li><code class=char>U+0024</code> <code class=charname>NUMBER SIGN</code>
1415     (<code class=char>#</code>)</li>
1416     <li><code class=char>U+0025</code> <code class=charname>PERCENT SIGN</code>
1417     (<code class=char>%</code>)</li>
1418     <li><code class=char>U+0027</code> <code class=charname>APOSTROPHE</code>
1419     (<code class=char>'</code>)</li>
1420     <li><code class=char>U+0028</code> <code class=charname>LEFT PARENTHESIS</code>
1421     (<code class=char>(</code>)</li>
1422     <li><code class=char>U+0029</code> <code class=charname>RIGHT
1423     PARENTHESIS</code> (<code class=char>)</code>)</li>
1424     <li><code class=char>U+002A</code> <code class=charname>ASTERISK</code>
1425     (<code class=char>*</code>)</li>
1426     <li><code class=char>U+002B</code> <code class=charname>PLUS SIGN</code>
1427     (<code class=char>+</code>)</li>
1428     <li><code class=char>U+002C</code> <code class=charname>COMMA</code>
1429     (<code class=char>,</code>)</li>
1430     <li><code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
1431     (<code class=char>-</code>)</li>
1432     <li><code class=char>U+002E</code> <code class=charname>FULL STOP</code>
1433     (<code class=char>.</code>)</li>
1434     <li><code class=char>U+002F</code> <code class=charname>SOLIDUS</code>
1435     (<code class=char>/</code>)</li>
1436 wakaba 1.21 <li><code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code>
1437     (<code class=char>0</code>) .. <code class=char>U+0039</code>
1438     <code class=charname>DIGIT NINE</code> (<code class=char>9</code>)</li>
1439 wakaba 1.20 <li><code class=char>U+003A</code> <code class=charname>COLON</code>
1440     (<code class=char>:</code>)</li>
1441     <li><code class=char>U+003B</code> <code class=charname>SEMICOLON</code>
1442     (<code class=char>;</code>)</li>
1443     <li><code class=char>U+003D</code> <code class=charname>EQUAL SIGN</code>
1444     (<code class=char>=</code>)</li>
1445     <li><code class=char>U+003F</code> <code class=charname>QUESTION MARK</code>
1446     (<code class=char>?</code>)</li>
1447     <li><code class=char>U+0040</code> <code class=charname>COMMERCIAL AT</code>
1448     (<code class=char>@</code>)</li>
1449 wakaba 1.21 <li><code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
1450     A</code> (<code class=char>A</code>) .. <code class=char>U+005A</code>
1451     <code class=charname>LATIN CAPITAL LETTER Z</code>
1452     (<code class=char>Z</code>)</li>
1453 wakaba 1.20 <li><code class=char>U+005F</code> <code class=charname>LOW LINE</code>
1454     (<code class=char>_</code>)</li>
1455 wakaba 1.21 <li><code class=char>U+0061</code> <code class=charname>LATIN CAPITAL LETTER
1456     A</code> (<code class=char>A</code>) .. <code class=char>U+007A</code>
1457     <code class=charname>LATIN CAPITAL LETTER Z</code>
1458     (<code class=char>Z</code>)</li>
1459 wakaba 1.20 </ul>
1460     <div class="note memo">
1461     <p>This character class contains all characters allowed in the production rule
1462     <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-PubidChar"><code>PubidChar</code></a>
1463     of <abbr>XML</abbr> 1.0
1464     <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p>
1465     </div>
1466 wakaba 1.1
1467     </div>
1468    
1469     <div id="references" class="section reference">
1470     <h2>References</h2>
1471    
1472     <div id="normative-references" class="section normative reference">
1473     <h3>Normative References</h3>
1474    
1475     <dl>
1476 wakaba 1.3 <dt id=ref-DOM3CORE>DOM3CORE</dt>
1477     <dd class=ed>@@ W3C DOM Level 3 Core</dd>
1478     <dt id=ref-DOMDTDEF>DOMDTDEF</dt>
1479     <dd class=ed>@@ manakai's extension to DOM for document type definitions</dd>
1480 wakaba 1.1 <dt id="ref-KEYWORDS">KEYWORDS</dt>
1481     <dd><cite><a href="urn:ietf:rfc:2119">Key words for use in
1482     <abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>,
1483     <abbr title="Internet Engineering Task Force">IETF</abbr>
1484     <a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr>
1485     14</a>, <abbr title="Request for Comments">RFC</abbr> 2119,
1486     <time datetime=1997-03>March 1997</time>.
1487     <em>This</em> version of the specification is referenced.</dd>
1488     <dt id=ref-INFOSET>INFOSET</dt>
1489     <dd class=ed>@@</dd>
1490     <dt id=ref-XML10">XML10</dt>
1491     <dd><cite><a href="http://www.w3.org/TR/2006/REC-xml-20060816">Extensible
1492     Markup Language (<abbr>XML</abbr>) 1.0 (Fourth Edition)</a></cite>,
1493     <abbr>W3C</abbr> Recommendation, <time datetime=2006-08-16>16 August
1494     2006</time>, edited in place <time datetime=2006-09-29>29 September
1495     2006</time>. Tje latest version of the specification is available at
1496     <code class=uri>&lt;<a href="http://www.w3.org/TR/xml">http://www.w3.org/TR/xml</a>&gt;</code>.
1497     <em>This</em> version of the specification is referenced.</dd>
1498     <dt id=ref-XML11>XML11</dt>
1499     <dd class=ed>@@</dd>
1500     </dl>
1501     </div>
1502    
1503     <div id="informative-references" class="section informative reference">
1504     <h3>Non$B!>(Bnormative References</h3>
1505    
1506     <dl class=ed>
1507     <dt id=ref-CSS>CSS</dt>
1508     <dd><cite><a href="http://www.w3.org/TR/2007/CR-CSS21-20070719">Cascading
1509     Style Sheets Level 2 Revision 1 (<abbr>CSS</abbr> 2.1)
1510     Specification</a></cite>,
1511     <abbr title="World Wide Web Consortium">W3C</abbr> Candidate
1512     Recommendation, <time datetime=2007-07-19>19 July 2007</time>.
1513     Work in progress. The latest version of the specification is
1514     available at
1515     <code class=URI>&lt;<a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a>></code>.</dd>
1516     <dt id=ref-CSSOM>CSSOM</dt>
1517     <dd><cite><a href="http://dev.w3.org/cvsweb/~checkout~/csswg/cssom/Overview.html?rev=1.55&amp;content-type=text/html;%20charset=utf-8">Cascading
1518     Style Sheets Object Model (<abbr>CSSOM</abbr>)</a></cite>,
1519     <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
1520     <time datetime=2007-06-18>18 June 2007</time>. Work in progress.
1521     The latest Editor's Draft of the specification is available at
1522     <code class=URI>&lt;<a href="http://dev.w3.org/csswg/cssom/Overview.html">http://dev.w3.org/csswg/cssom/Overview.html</a>></code>.</dd>
1523     <dt id=ref-HTML5>HTML5</dt>
1524     <dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>,
1525     <abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr>
1526     Working Draft. Work in progress.</dd>
1527     <dt id=ref-SAPI>SAPI</dt>
1528     <dd><cite><a href="http://dev.w3.org/cvsweb/~checkout~/2006/webapi/selectors-api/Overview.html?rev=1.28&amp;content-type=text/html;%20charset=utf-8">Selectors <abbr>API</abbr></a></cite>,
1529     <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
1530     <time datetime=2007-08-29>29 August 2007</time>. Work in progress.
1531     The latest Editor's Draft of the specification is available at
1532     <code class=URI>&lt;<a href="http://dev.w3.org/2006/webapi/selectors-api/Overview.html">http://dev.w3.org/2006/webapi/selectors-api/Overview.html</a>></code>.
1533     The latest published version of the specification is available at
1534     <code class=URI>&lt;<a href="http://www.w3.org/TR/selectors-api/">http://www.w3.org/TR/selectors-api/</a>></code>.</dd>
1535     <dt id=XBL2>XBL2</dt>
1536     <dd><cite><a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr>XBL</abbr>
1537     2.0</a></cite>, Mozilla.org, <time datetime=2007-03-15>15 Mar 2007</time>.
1538     Work in progress. The latest
1539     <abbr title="World Wide Web Consortium">W3C</abbr>$B!>(Bpublished
1540     version of the specification is available at
1541     <code class=URI>&lt;<a href="http://www.w3.org/TR/xbl/">http://www.w3.org/TR/xbl/</a>></code>.</dd>
1542 wakaba 1.3 <dt id=ref-XML5>XML5</dt>
1543     <dd class=ed>@@</dd>
1544 wakaba 1.1 </dl>
1545     </div>
1546    
1547     </div>
1548    
1549     </body>
1550     </html>

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24