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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Mon Nov 12 12:22:48 2007 UTC revision 1.26 by wakaba, Sat Mar 29 06:35:16 2008 UTC
# Line 1  Line 1 
1  <!DOCTYPE html>  <!DOCTYPE html>
2  <html lang="en" class="formal-specification status-work-in-progress">  <html lang="en" class="formal-specification status-work-in-progress">
3  <head>  <head>
4  <title class=ed>DOM XML Checking</title>  <title>manakai's XML Conformance Checking</title>
5  <link rel="stylesheet" href="http://suika.fam.cx/www/style/html/spec">  <link rel="stylesheet" href="http://suika.fam.cx/www/style/html/spec">
6  <link rel="license" href="http://suika.fam.cx/c/gnu/fdl">  <link rel="license" href="http://suika.fam.cx/c/gnu/fdl">
7    <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  </head>  </head>
17  <body class="has-abstract">  <body class="has-abstract">
18    
19  <div class="header">  <div class="header">
20  <h1 class=ed>DOM XML Checking</h1>  <h1>manakai's <abbr>XML</abbr> Conformance Checking</h1>
21  <h2>Working Draft <time datetime=2007-10-27>27 October 2007</time></h2>  <h2>Working Draft <time datetime=2008-03-29>29 March 2008</time></h2>
22    
23  <dl class="versions-uri ed">  <dl class="versions-uri">
24  <dt>This Version</dt>  <dt>This Version</dt>
25    <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft"    <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work"
26        >http://suika.fam.cx/www/markup/selectors/ssft/ssft</a>&gt;</code></dd>        >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work</a>&gt;</code></dd>
27  <dt>Latest Version</dt>  <dt>Latest Version</dt>
28    <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft"    <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc"
29        >http://suika.fam.cx/www/markup/selectors/ssft/ssft</a>&gt;</code></dd>        >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc</a>&gt;</code></dd>
 <!--  
30  <dt>Latest Working Draft</dt>  <dt>Latest Working Draft</dt>
31  -->    <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  <!-- <dt>Previous Version</dt> -->  <!-- <dt>Previous Version</dt> -->
34  <dt>Version History</dt>  <dt>Version History</dt>
35    <dd><code class=URI>&lt;<a href="http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft.en.html">http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft.en.html</a>&gt;</code></dd>    <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  </dl>  </dl>
37  <dl class="authors" id="author">  <dl class="authors" id="author">
38  <dt>Author</dt>  <dt>Author</dt>
# Line 33  Line 42 
42        >w@suika.fam.cx</a>&gt;</code></dd>        >w@suika.fam.cx</a>&gt;</code></dd>
43  </dl>  </dl>
44    
45  <p class="copyright" lang="en">&#xA9; <time>2007</time> <a  <p class="copyright" lang="en">&#xA9; <time>2007</time>$B!>(B<time>2008</time> <a
46      href="http://suika.fam.cx/~wakaba/who?" rel="author">Wakaba</a>.      href="http://suika.fam.cx/~wakaba/who?" rel="author">Wakaba</a>.
47  Permission is granted to copy, distribute and/or modify this document  Permission is granted to copy, distribute and/or modify this document
48  under the terms of the <a rel="license"  under the terms of the <a rel="license"
# Line 109  else in this specification is normative. Line 118  else in this specification is normative.
118  <p><span class=ed>Algorithm is normative but non-normative</span>.  <p><span class=ed>Algorithm is normative but non-normative</span>.
119  In addition, the order in which <a href="#errors">errors</a> are  In addition, the order in which <a href="#errors">errors</a> are
120  raised is undefined.</p>  raised is undefined.</p>
121    
122    <p>This document sometimes cites parts of <abbr>XML</abbr> 1.0 specification
123    by hyperlinks.  When the document being processed is an <abbr>XML</abbr> 1.1
124    document, however, corresponding parts of the <abbr>XML</abbr> 1.1
125    specification should be consulted instead.</p>
126  </div>  </div>
127    
 <div class="section">  
 <h2 class=ed>Algorithms</h2>  
128    
129  <p>The following algorithms and definitions are applied to  <div class=section id=error-categories>
130  <abbr>XML</abbr> documents; especially, they are not applied  <h2>Error Classification</h2>
 to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p>  
131    
132  <p class=ed>If a <code>Document</code> node has no  <p class=ed>If a <code>Document</code> node has no
133  xml-well-formedness-error, entity-error, and unknown-error,  xml-well-formedness-error, entity-error, and unknown-error,
# Line 129  into a well$B!>(Bformed XML document. Line 140  into a well$B!>(Bformed XML document.
140  can be easily serialized into a valid XML document.</p>  can be easily serialized into a valid XML document.</p>
141  </div>  </div>
142    
143    <p class=ed>To be a conforming <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-validating">validating XML processor</a>,
144    ...</p>
145    
146  <p>Errors are classified into these  <p>Errors are classified into these
147  <dfn id=error-category title="error category">error categories</dfn>:</p>  <dfn id=error-category title="error category">error categories</dfn>:</p>
148    
149  <dl id=errors>  <dl id=errors>
150  <dt><dfn id=entity-error><code>entity-error</code></dfn></dt>  <dt><dfn id=entity-error><code>entity-error</code></dfn></dt>
151    <dd class=ed>@@</dd>    <dd>
152        <p class=ed>@@</p>
153        <div class="note memo">
154          <p>This <span class=ed>algorithm</span> does not support
155          <abbr>DOM</abbr> tree with one or more <code>EntityReference</code>
156          nodes.  It is expected that any entity references are expanded
157          at the parse time and any unexpandable entity references
158          make parse time errors raised so that never result in
159          <abbr>DOM</abbr> tree with <code>EntityReference</code> nodes.</p>
160        </div>
161      </dd>
162  <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>
163    <dd class=ed>@@</dd>    <dd class=ed>@@</dd>
164    <dt><dfn id=round-trip-warning><code>round-trip-warning</code></dfn></dt>
165      <dd>
166        <p>A <a href="#round-trip-warning"><code>round-trip-warning</code></a>
167        will be raised when a construct, which might not be restored to the same
168        construct when it is serialized and then re-parsed by a conforming
169        processor, is encountered.</p>
170        <div class="example memo">
171          <p>For a <code>Comment</code> node a
172          <a href="#round-trip-warning"><code>round-trip-warning</code></a> will
173          be raised, since <abbr>XML</abbr> processors are not required to
174          report texts of comments for applications.</p>
175        </div>
176      </dd>
177  <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>
178    <dd class=ed>@@</dd>    <dd class=ed>@@</dd>
179  <dt><dfn id=xml-misc-error><code>xml-misc-error</code></dt>  <dt><dfn id=xml-misc-error><code>xml-misc-error</code></dt>
# Line 157  can be easily serialized into a valid XM Line 194  can be easily serialized into a valid XM
194    <a href="@@/#dt-fatal">fatal error</a>)    <a href="@@/#dt-fatal">fatal error</a>)
195    that is not classified to any other <a href="#error-category">error    that is not classified to any other <a href="#error-category">error
196    category</a>. <span class=ed>@@ What errors fall into this category?</span></dd>    category</a>. <span class=ed>@@ What errors fall into this category?</span></dd>
197    <dt><dfn id=xml-misc-recommendation><code>xml-misc-recommendation</code></dfn></dt>
198      <dd>
199        <p>An
200        <a href="#xml-misc-recommendation"><code>xml-misc-recommendation</code></a>
201        will be raised if a <em class=rfc2119>SHOULD</em>$B!>(Blevel requirement
202        in <abbr>XML</abbr> specification is not met.</p>
203      </dd>
204  <dt><dfn id=xml-validity-error><code>xml-validity-error</code></dfn></dt>  <dt><dfn id=xml-validity-error><code>xml-validity-error</code></dfn></dt>
205    <dd>A violation of validity constraint in XML document.</dd>    <dd>A violation of validity constraint in XML document.</dd>
206  <dt><dfn id=xml-well-formedness-error><code>xml-well-formedness-error</code></dfn></dt>  <dt><dfn id=xml-well-formedness-error><code>xml-well-formedness-error</code></dfn></dt>
# Line 166  can be easily serialized into a valid XM Line 210  can be easily serialized into a valid XM
210    violate to any well$B!>(Bformedness constraint in XML    violate to any well$B!>(Bformedness constraint in XML
211    specification <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>,    specification <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>,
212    <a href="#ref-XML11">XML11</a>]</cite>.</p></dd>    <a href="#ref-XML11">XML11</a>]</cite>.</p></dd>
213    <dt><dfn id=misc-info><code>misc-info</code></dfn>
214      <dd><p>A <code>misc-info</code> is raised when some status information
215      on parsing or checking process that are considered useful for debugging
216      and so on is available.  It by no means implies the non-conformance of
217      the document.
218  </dl>  </dl>
219    
220  <div class=ed><p>@@ TODO: #dt-atuseroption at user option  <div class=ed><p>@@ TODO: #dt-atuseroption at user option
221  (MAY or MUST), #dt-compat for compatibility,  (MAY or MUST), #dt-compat for compatibility,
222  #dt-interop for interoperability</p></div>  #dt-interop for interoperability</p>
223    
224    <p>TODO: XML 1.1, XML Namespace 1.0/1.1, xml:base, xml:id
225    </div>
226    
227    </div>
228    
229    <div class=section id=parsing-xml>
230    <h2>Parsing <abbr>XML</abbr> Document</h2>
231    
232    <p>When an <abbr>XML</abbr> document is parsed, the following clauses
233    are applied:</p>
234    <dl class=switch>
235    <dt>For the document
236      <dd>If the <abbr>XML</abbr> document does not begin with an
237      <abbr>XML</abbr> declaration, then the parser <em class=rfc2119>MUST</em>
238      raise an
239      <a href="#xml-misc-recommentation" id=xmr-xml-decl><code>xml-misc-recommendation</code></a>.
240    <dt>For the document type declaration
241      <dd class=ed>@@ read external entity
242      <dd>The <code>entities</code> attribute of the <code>DocumentType</code>
243      node <em class=rfc2119>MUST</em> contain a <code>NamedNodeMap</code> object
244      whose first five items are as follows:
245        <ol start=0>
246        <li>An <code>Entity</code> node whose <code>nodeName</code> attribute
247        is <code>amp</code>.  It contains a <code>Text</code> node whose
248        <code>data</code> attribute is set to <code>&amp;</code>.
249        <li>An <code>Entity</code> node whose <code>nodeName</code> attribute
250        is <code>lt</code>.  It contains a <code>Text</code> node whose
251        <code>data</code> attribute is set to <code>&lt;</code>.
252        <li>An <code>Entity</code> node whose <code>nodeName</code> attribute
253        is <code>gt</code>.  It contains a <code>Text</code> node whose
254        <code>data</code> attribute is set to <code>></code>.
255        <li>An <code>Entity</code> node whose <code>nodeName</code> attribute
256        is <code>quot</code>.  It contains a <code>Text</code> node whose
257        <code>data</code> attribute is set to <code>"</code>.
258        <li>An <code>Entity</code> node whose <code>nodeName</code> attribute
259        is <code>apos</code>.  It contains a <code>Text</code> node whose
260        <code>data</code> attribute is set to <code>'</code>.
261        </ol>
262    <dt>For each internal general entity declaration being processed by the parser
263      <dd>If the
264      <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-EntityValue"><code>EntityValue</code></a>
265      part of the general entity declaration contains a bare <code>U+003C</code>
266      <code>LESS-THAN SIGN</code> (<code>&lt;</code>) character, then the parser
267      <em class=rfc2119>MUST</em> raise an
268      <a href="#xml-misc-warning" id=xmw-entity-value-lt><code>xml-misc-warning</code></a>.<!--
269    "strongly advised to avoid" in a Note in Section 2.3 of [XML10], [XML11].
270    -->
271    <dt>For each element type declaration being processed by the parser
272      <dd>If there is another processed element type declaration whose
273      <code>Name</code> is equal to the <code>Name</code> of the element type
274      declaration, then the parser <em class=rfc2119>MUST</em> raise an
275      <a href="#xml-validity-error" id=vc-edunique><code>xml-validity-error</code></a>.
276    <dt>For each attribute definition list declaration being processed by the
277    parser
278      <dd>If there is another processed attribute defintion list declaration whose
279      <code>Name</code> is equal to the <code>Name</code> of the attribute
280      definition list declaration, then the parser <em class=rfc2119>MUST</em>
281      raise an
282      <a href="#xml-misc-warning" id=xme-attlist-unique><code>xml-misc-warning</code></a>.
283      <dd>For each attribute definition in the attribute definition list
284      declaration, if there is another processed attribute definition whose
285      <code>Name</code> is equal to the <code>Name</code> of the attribute
286      definition (whether or not in the same attribute definition list
287      declaration), then the parser <em class=rfc2119>MUST</em> raise an
288      <a href="#xml-misc-warning" id=xme-attrdef-unique><code>xml-misc-warning</code></a>.
289      <!--
290        <q>For interoperability, an XML processor <em class=rfc2119>MAY</em> at
291        user option issue a warning when more than one attribute-list declaration
292        is provided for a given element type, or more than one attribute definition
293        is provided for a given attribute, but this is not an error.</q>
294      -->
295    <!--
296      NOTE: <!ATTLIST a xml:space (default) #IMPLIED xml:space CDATA #IMPLIED>
297      will not be warned.
298    -->
299    
300    <dt>For each entity declaration being processed by the parser
301      <dd>Handle as follows:
302        <ol>
303        <li><p>If the entity declaration declares a general entity, the following
304        is applied:
305          <dl>
306          <dt>If the <code>Name</code> is <code>lt</code> or <code>amp</code>
307            <dd><p>If the entity declaration does not declare an internal entity,
308            or if the replacement text of the entity is not the escaped form of
309            <code>&lt;</code> (if <code>lt</code>) or <code>&amp;</code> (if
310            <code>amp</code>), then the parser <em class=rfc2119>MUST</em> raise an
311            <a href="#xml-misc-error" id=xme-double-escape><code>xml-misc-error</code></a>.
312    
313              <div class="note memo informative">
314              <p>In other word, the character in the <code>EntityValue</code>
315              has to be double-escaped.
316              </div>
317          <dt>If the <code>Name</code> is <code>gt</code>, <code>quot</code>, or
318          <code>apos</code>
319            <dd><p>If the entity declaration does not declare an internal entity,
320            or if the replacement text of the entity is not equal to or not the
321            escaped form of <code>></code> (if <code>gt</code>), <code>"</code> (if
322            <code>quot</code>), or <code>'</code> (if <code>apos</code>), then the
323            parser <em class=rfc2119>MUST</em> raise an
324            <a href="#xml-misc-error" id=xme-single-escape><code>xml-misc-error</code></a>.
325    
326              <div class="note memo informative">
327              <p>In other word, the character in the <code>EntityValue</code>
328              has to be single- or double-escaped.
329              </div>
330          </dl>
331          <!--
332            <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>
333          -->
334    
335        <li><p>If the entity declaration has to be ignored since there has already
336        been declared an entity with the same <code>Name</code> as the declaration,
337        then the parser <em class=rfc2119>MUST</em> raise a
338        <a href="#misc-info" id=mi-ent-unique><code>misc-info</code></a>
339        and abort these steps.
340    
341        <div class="informative note memo">
342        <p>Five predefined entities, i.e. <code>amp</code>, <code>lt</code>,
343        <code>gt</code>, <code>quot</code>, and <code>apos</code>, are always
344        declared implicitly and therefore any declaration for such an entity
345        always raises an
346        <a href="#misc-info" id=mi-ent-unique><code>misc-info</code></a>.
347        </div>  
348    
349        <li><p>If the entity declaration declares a parameter entity and the
350        <code>Name</code> of the entity begins with the string <code>xml</code>
351        (in any combination of upper- and lowercase letters), then the parser
352        <em class=rfc2119>MUST</em> raise an
353        <a href="#xml-misc-warning" id=xmw-reserved-pe-name><code>xml-misc-warning</code></a>.
354    
355        <li><p>If the entity declaration contains the <code>EntityValue</code>,
356        then for each occurence of any references to unparsed entities in the
357        <code>EntityValue</code>, the parser <em class=rfc2119>MUST</em> raise an
358        <a href="#xml-misc-error" id=xme-unparsed-in-ev><code>xml-misc-error</code></a>.
359        <!--
360          <q>It is an error for a reference to an unparsed entity to appear in the
361          EntityValue in an entity declaration.</q>
362        -->
363        <li><p>If the entity declaration declares a general entity, then an
364        <code>Entity</code> node <em class=rfc2119>MUST</em> be created and
365        appended to the <code>NamedNodeMap</code> object in the
366        <code>entities</code> attribute of the <code>DocumentType</code> node.
367        
368        <p class=ed>Read the external entity
369    
370        <p>If the replacement text of the entity is read, then parse the
371        replacement text as if it were referenced from the content of an
372        element (with no namespace bindings).  If no <span class=ed>@@ parse error</span>
373        is raised by the parsing process, then the nodes generated by the
374        parsing <em class=rfc2119>MUST</em> be appended to the <code>Entity</code>
375        node.  The parse error <em class=rfc2119>MUST NOT</em> be propagated to
376        the entire parsing process.  Other kinds of errors
377        <em class=rfc2119>MUST</em> be propagated.  The first parse error
378        <em class=rfc2119>MUST</em> abort the internal parsing process.
379        <span class=ed>@@ better wording</span>
380    
381        <p class=ed>@@ prop
382        
383        <p>Then, the <code>Entity</code> node and its descendant
384        <em class=rfc2119>MUST</em> be marked as read-only.
385      </ol>
386    
387    <dt>For each notation declaration being processed by the parser
388      <dd>If there is another processed notation declaration whose
389      <code>Name</code> is equal to the <code>Name</code> of the notation
390      declaration, then the parser <em class=rfc2119>MUST</em> raise an
391      <a href="#xml-validity-error" id=vc-uniquenotationname><code>xml-validity-error</code></a>.
392      <!-- <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#UniqueNotationName">Validity constraint: Unique Notation Name</a> -->
393    
394    <dt>For each empty-element tag
395      <dd>If the <code>Name</code> of the tag is not declared by a processed
396      element type declaration as <code>EMPTY</code> content, then the parser
397      <em class=rfc2119>MUST</em> raise an
398      <a href="#xml-misc-recommentation" id=xmr-emptyelemtag-not-empty><code>xml-misc-recommendation</code></a>.
399    <dt>For each start-tag
400      <dd>If the <code>Name</code> of the tag is declared by a processed element
401      type declaration as <code>EMPTY</code> content, then the parser
402      <em class=rfc2119>MUST</em> raise an
403      <a href="#xml-misc-recommentation" id=xmr-empty-not-emptyelemtag><code>xml-misc-recommendation</code></a>.
404    
405    <dt>For each parameter entity reference
406      <dd>If the declaration for the entity is not read (i.e. no declaration
407      for the entity is processed or the external entity referenced by the
408      declaration cannot be retrieved), then:
409        <ul>
410        <li>If the parameter entity is contained in a declaration, then the
411        declaration <em class=rfc2119>MUST</em> be ignored <em>except</em> that
412        any error before the parameter entity <em class=rfc2119>MUST</em> be
413        raised as usual.
414        <li>If the parameter entity is contained in the status portion of a
415        conditional section, then the conditional section
416        <em class=rfc2119>MUST</em> be processed as if it were an
417        <code>IGNORE</code>d section.
418        <li>The parser <em class=rfc2119>MUST NOT</em> process any entity or
419        attribute-list declaration after the parameter entity reference in the DTD
420        <em>except</em> when the <code>standalone</code> pseudo-attribute of the
421        XML declaration (if any) is set to <code>yes</code>.
422        <!-- This requirement is enforced for internal DTD subset case in
423        XML 1.0/1.1 specification (section 5.1) but not for any other cases. -->
424        <!-- According to this definition, element type declarations, notation
425        declarations, and PIs ARE processed. -->
426        <li>If the parameter entity reference is the first reference to an entity
427        that is not read, then the parser <em class=rfc2119>MUST</em> raise an
428        <a href="#entity-error" id=ee-unread-pe><code>entity-error</code></a>.
429        <li>The <code>allDeclarationsProcessed</code> <span class=ed>@@ ref</span>
430        attribute of the <code>Document</code> node <em class=rfc2119>MUST</em> be
431        set to <code>false</code>.
432        </ul>
433    <dt>For each general entity reference in an attribute value or in the content
434    of an element
435      <dd>If the declaration for the entity is not read (i.e. no declaration for
436      the entity is processed or the external entity referenced by the declaration
437      cannot be retrieved), then:
438        <ul>
439        <li>If the general entity reference is the first reference to an entity
440        that is not read, then the parser <em class=rfc2119>MUST</em> raise an
441        <a href="#entity-error" id=ee-unread-ge><code>entity-error</code></a>.
442        <span class=ed>@@ entity declared WFC?</span>
443        <li class=ed>An unexpended entity reference node <em class=rfc2119>MUST</em> be inserted to the current node.
444        </ul>
445    </dl>
446    
447    <p class=ed>@@ MUST try to read external entity
448    
449    <p>In addition, the parser has to check whether the
450    following constraints are met.
451    
452    <p><strong>Well-formedness constraints</strong>.  For each violation to
453    one of constraints below, an
454    <a href="#xml-well-formedness-error"><code>xml-well-formedness-error</code></a>
455    <em class=rfc2119>MUST</em> be raised.  The list of well-formedness
456    constraints is below:
457    <ul>
458    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#wfc-PEinInternalSubset">Well-formedness constraint: PEs in Internal Subset</a>
459    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#GIMatch">Well-formedness constraint: Element Type Match</a>
460    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#uniqattspec">Well-formedness constraint: Unique Att Spec</a>
461    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NoExternalRefs">Well-formedness constraint: No External Entity References</a>
462    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#CleanAttrVals">Well-formedness constraint: No &lt; in Attribute Values</a>
463    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#wf-Legalchar">Well-formedness constraint: Legal Character</a>
464    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#textent">Well-formedness constraint: Parsed Entity</a>
465    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#norecursion">Well-formedness constraint: No Recursion</a>
466    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#indtd">Well-formedness constraint: In DTD</a>
467    </ul>
468    
469    <p><strong>Validity constraints</strong>.  For each violation to
470    one of constraints below, an
471    <a href="#xml-validity-error"><code>xml-validity-error</code></a>.
472    <em class=rfc2119>MUST</em> be raised.  The list of validity
473    constraints is below:
474    <ul>
475    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#vc-PEinMarkupDecl">Validity constraint: Proper Declaration/PE Nesting</a>
476    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#vc-PEinGroup">Validity constraint: Proper Group/PE Nesting</a>
477    <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#condsec-nesting">Validity constraint: Proper Conditional Section/PE Nesting</a>
478    </ul>
479    
480    <p><strong>Other creteria</strong>.  For each violation to
481    one of constraints below, an
482    <a href="#xml-misc-recommendation"><code>xml-misc-recommendation</code></a>
483    <em class=rfc2119>MUST</em> be raised.  The list of constraints is below:
484    <ul>
485    <li><q>For interoperability, if a parameter-entity reference appears in a
486    <code>choice</code>, <code>seq</code>, or <code>Mixed</code> construct, its
487    replacement text <em class=rfc2119>SHOULD</em> contain at least one non-blank
488    character, and neither the first nor last non-blank character of the
489    replacement text <em class=rfc2119>SHOULD</em> be a connector (<code>|</code>
490    or <code>,</code>).</q>
491    <li><q>External parsed entities <em class=rfc2119>SHOULD</em> each begin with a
492    text declaration.</q>
493    </ul>
494    
495    
496    <!--
497    
498    @@ Need detailed review, but maybe should be in parsing phase
499    
500    #vc-check-rmd Validity constraint: Standalone Document Declaration
501    
502    @@ Need dtailed review
503    
504    #wf-entdeclared Well-formedness constraint: Entity Declared
505    #vc-entdeclared Validity constraint: Entity Declared
506    "For interoperability, valid documents SHOULD declare the entities amp, lt, gt, apos, quot, in the form specified in 4.6 Predefined Entities."
507    
508    @@ flaged and then reported in DOM check phase
509    
510    "Entities encoded in UTF-16 MUST and entities encoded in UTF-8 MAY begin with the Byte Order Mark"
511    "In the absence of external character encoding information (such as MIME headers), parsed entities which are stored in an encoding other than UTF-8 or UTF-16 MUST begin with a text declaration"
512    "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."
513    
514    @@ in parsing phase
515    
516    "It is a fatal error when an XML processor encounters an entity with an encoding that it is unable to process. It is a fatal error if an XML entity is determined (via default, encoding declaration, or higher-level protocol) to be in a certain encoding but contains byte sequences that are not legal in that encoding."
517    
518    @@ We should phrase out what the parser should do where the XML specification
519    left undefined.  For example: Comment must be converted to a Comment node,
520    illegal xml:space value must be preserved, so on.
521    
522    Warn <!ENTITY % xml... ...>
523    
524    -->
525    
526    <p>The parser <em class=rfc2119>MUST</em> raise an
527    <a href="#xml-well-formedness-error" id=wfe-syntax><code>xml-well-formedness-error</code></a>
528    for any failure to match to a production rule in the XML specification.
529    <!--
530      <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#ExtSubset">Well-formedness constraint: External Subset</a>
531      <li><a href="http://www.w3.org/TR/2006/REC-xml-20060816/#PE-between-Decls">Well-formedness constraint: PE Between Declarations</a>
532    -->
533    </div>
534    
535    <div class="section" id=checking-dom>
536    <h2>Checking <abbr>DOM</abbr></h2>
537    
538    <p>The following algorithms and definitions are applied to
539    <abbr>XML</abbr> documents; especially, they are not applied
540    to <abbr>HTML</abbr> documents.<!-- TODO: ref to HTML5 --></p>
541    
542    <div class=section id=definitions>
543    <h3>Definitions</h3>
544    
545  <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
546  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.
547  For a <code>Documemt</code> node, the <abbr>XML</abbr> version  For a <code>Documemt</code> node, the <abbr>XML</abbr> version
548  of the document is the value of the <code>xmlVersion</code>  of the document is the value of the <code>xmlVersion</code>
549  attribute.  For a <code>DocumentType</code> node whose  attribute of the node.  For a <code>DocumentType</code> node whose
550  <code>ownerDocument</code> is set to <code>null</code>,  <code>ownerDocument</code> attribute is set to <code>null</code>,
551  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><!--
552    since createDocumentType [DOM3CORE] assumes XML 1.0 [XML10TE] -->.
553  For any other node, the <abbr>XML</abbr> version of the document  For any other node, the <abbr>XML</abbr> version of the document
554  is that of the <code>Document</code> node contained in the  is that of the <code>Document</code> node contained in the
555  <code>ownerDocument</code> attribute of the node.</p>  <code>ownerDocument</code> attribute of the node.</p>
556    
557    </div>
558    
559    
560    <div class=section id=checking-components>
561    <h3>Conformance Checking Algorithms for Components</h3>
562    
563    <p>To
564    <dfn id=algorithm-to-validate-an-xml-character-data title="validate an XML string">to
565    validate an <abbr>XML</abbr> string (<dfn id=var-s><var>s</var></dfn>)</dfn>,
566    the following algorithm <em class=rfc2119>MUST</em> be used:</p>
567    <ol>
568    <li>If <var>s</var> contains a character that is <em>not</em> in
569    the character class <a href="#class-Char10"><code>Char10</code></a>,
570    then raise an
571    <a href="#xml-well-formedness-error" id=wfe-illegal-char><code>xml-well-formedness-error</code></a>.</li>
572    <li>If <var>s</var> contains a character that is in the character
573    class <a href="#class-CompatChar10"><code>CompatChar10</code></a>,
574    then raise an
575    <a href="#xml-misc-warning" id=xmw-compat-char><code>xml-misc-warning</code></a>.</li>
576    <li>If <var>s</var> contains a character that is in the character
577    class <a href="#class-ControlChar10"><code>ControlChar10</code></a>,
578    then raise an
579    <a href="#xml-misc-warning" id=xmw-control-char><code>xml-misc-warning</code></a>.</li>
580    <li class=ed>@@ XML 1.1 support</li>
581    <li>If <var>s</var> contains a <code class=char>U+000D</code>
582    <code class=charname>CARRIAGE RETURN</code> character, then
583    raise a
584    <a href="#round-trip-error" id=rte-cr><code>round-trip-error</code></a>.
585    <span class=ed>@@ We should not raise duplicate errors for U+000D
586    in attribute values.  In addition, we should support a mode where
587    U+000D will be serialized as &#x000D; (so that no round-trip-error
588    will be raised).</span></li>
589    </ol>
590    
591    <p>To
592    <dfn id=algorithm-to-validate-a-name title="validate a Name">validate a
593    <code>Name</code> (<dfn id=var-name-s><var>s</var></dfn>)</dfn>, the following
594    algorithm <em class=rfc2119>MUST</em> be used:</p>
595    <ol>
596    <li>If <var>s</var> is an empty string, then raise an
597    <a href="#xml-well-formedness-error" id=wfe-name-empty><code>xml-well-formedness-error</code></a>.
598    Abort these steps.</li>
599    <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate
600    <var>s</var> as an <abbr>XML</abbr> string</a>.</li>
601    <li>If the first character in <var>s</var> is a character that is
602    <em>not</em> in the character class
603    <a href="#class-NameStartChar10"><code>NameStartChar10</code></a>, then raise
604    an
605    <a href="#xml-well-formedness-error" id=wfe-name-startchar><code>xml-well-formedness-error</code></a>.</li>
606    <li>If a character other than the first character in <var>s</var> is a
607    character that is <em>not</em> in the character class
608    <a href="#class-NameChar10"><code>NameChar10</code></a>, then raise an
609    <a href="#xml-well-formedness-error" id=wfe-name-char><code>xml-well-formedness-error</code></a>.</li>
610    <li>If <var>s</var> begins with the string <code>xml</code> (in any
611    case combination), then raise an
612    <a href="#xml-misc-warning" id=xmw-reserved-name><code>xml-misc-warning</code></a>.
613    <span class=ed>@@ except for attribute names <code>xml:lang</code>,
614    <code>xml:space</code><!--, <code>xml:base</code>, <code>xml:id</code>,
615    <code>xmlns</code>, <code>xmlns:<var>*</var></code>,
616    pi name <code>xml-stylesheet</code>-->.</span><!--
617    "names beginning with a match to (('X'|'x')('M'|'m')('L'|'l')) are reserved for standardization in this or future versions of this specification.":
618    xmlns, xml-stylesheet, xml:base and xml:id specifications violate to this sentense!
619    --></li>
620    <!-- COLON in Name is a lowercase "should not" in a Note of [XML10],
621    [XML11]. -->
622    <li class=ed>@@ XML 1.1 support</li>
623    </ol>
624    
625    <p>To
626    <dfn id=algorithm-to-validate-an-ncname title="validate an NCName">validate
627    an <code>NCName</code> (<dfn id=var-ncname-s><var>s</var></dfn>)</dfn>, the
628    following algorithm <em class=rfc2119>MUST</em> be used:</p>
629    <ol>
630    <li><a href="#algorithm-to-validate-a-name" title="validate a Name">Validate
631    <var>s</var> as a <code>Name</code></a>.</li>
632    <li class=ed>@@</li>
633    </ol>
634    
635    <p>To
636    <dfn id=algorithm-to-validate-a-public-identifier title="validate a public identifier">validate
637    a public identifier (<dfn id=var-pid><var>pid</var></dfn>)</dfn>, the
638    following algorithm <em class=rfc2119>MUST</em> be used:</p>
639    <ol>
640    <li>If <var>pid</var> is <code>null</code>, abort these steps.</li>
641    <li>If <var>pid</var> contains a character that is <em>not</em> in the
642    character class <a href="#class-PubidChar"><code>PubidChar</code></a>, then
643    raise an
644    <a href="#xml-well-formedness-error" id=wfe-pubid-char><code>xml-well-formedness-error</code></a>.</li>
645      <li>If <var>pid</var> contains one of <code class=char>U+0009</code>
646      <code class=charname>CHARACTER TABULATION</code>,
647      <code class=char>U+000A</code> <code class=charname>CARRIAGE RETURN</code>,
648      and <code class=char>U+000D</code> <code class=charname>LINE FEED</code>
649      characters, if the first character of <var>pid</var> is
650      <code class=char>U+0020</code> <code class=charname>SPACE</code> character,
651      if the last character of <var>pid</var> is <code class=char>U+0020</code>
652      <code class=charname>SPACE</code> character, or if there is a
653      <code class=char>U+0020</code> <code class=charname>SPACE</code> character
654      immediately followed by another <code class=char>U+0020</code>
655      <code class=charname>SPACE</code> character in <var>pid</var>, then it is a
656      <a href="#round-trip-error" id=rte-pubid-space><code>round-trip-error</code></a>.
657      <span class=ed>Is this really a roundtripness problem?  XML spec
658      does only define the way to match public identifiers in fact, no
659      canonical form.</span></li>
660    </ol>
661    
662    <p>To
663    <dfn id=algorithm-to-validate-a-system-identifier title="validate a system identifier">validate
664    a system identifier (<dfn id=var-sid><var>sid</var></dfn>)</dfn>, the
665    following algorithm <em class=rfc2119>MUST</em> be used:</p>
666    <ol>
667      <li>If <var>sid</var> is <code>null</code>, abort these steps.</li>
668    <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate
669    <var>sid</var> as an <abbr>XML</abbr> string</a>.</li>
670      <li>If <var>sid</var> contains both <code class=char>U+0022</code>
671      <code class=charname>QUOTATION MARK</code> (<code class=char>"</code>) and
672      <code class=char>U+0027</code> <code class=charname>APOSTROPHE</code>
673      (<code class=char>'</code>) characters, raise an
674      <a href="#xml-well-formedness-error" id=wfe-sid-lit><code>xml-well-formedness-error</code></a>.</li>
675      <li>If <var>sid</var> contains at least one <code class=char>U+0023</code>
676      <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>)
677      character, then raise an
678      <a href="#xml-misc-error" id=xme-sid-fragment><code>xml-misc-error</code></a>.</li>
679      <li class=ed>@@ If <var>sid</var> cannot be converted to a URI
680      reference, then raise a fact-level error (xml-misc-warning?).<!--
681      XML 1.0 has no conformance language for system identifier being
682      a URI reference. --></li>
683    </ol>
684    
685    </div>
686    
687    <div class=section id=checking-node>
688    <h3>Checking <code>Node</code></h3>
689    
690  <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
691  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
692  following:</p>  following:</p>
# Line 190  following:</p> Line 694  following:</p>
694  <dt>If <var>n</var> is an <code>Attr</code> node</dt>  <dt>If <var>n</var> is an <code>Attr</code> node</dt>
695    <dd>    <dd>
696      <ol>      <ol>
697      <li><a href="#algorithm-to-validate-a-ncname">Validate the      <li><a href="#algorithm-to-validate-an-ncname">Validate the
698      <code>localName</code> attribute value as an <code>NCName</code></a>.</li>      <code>localName</code> attribute value as an <code>NCName</code></a>.</li>
699      <li>If the <code>prefix</code> attribute value is different from      <li>If the <code>prefix</code> attribute value is different from
700      <code>null</code>, then <a href="#algorithm-to-validate-a-ncname">validate      <code>null</code>, then <a href="#algorithm-to-validate-an-ncname">validate
701      the <code>prefix</code> attribute value as an <code>NCName</code></a>.</li>      the <code>prefix</code> attribute value as an <code>NCName</code></a>.</li>
702      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>For each node <dfn id=var-attr-nc><var>n<sub><var>c</var></sub></var></dfn> in the
703      a node which is <em>not</em> <code>Text</code> or      <code>childNodes</code> list of <var>n</var>,
704      <code>EntityReference</code> node, then it is a        <ol>
705      <a href="#xml-well-formedness-error" id=wfe-attr-child><code>xml-well-formedness-error</code></a>.</li>        <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a
706      <li>If the <code>childNodes</code> list of <var>n</var> contains        <code>Text</code> or <code>EntityReference</code> node, then it is an
707      an <code>EntityReference</code> node, it is an        <a href="#xml-well-formedness-error" id=wfe-attr-child><code>xml-well-formedness-error</code></a>.</li>
708      <a href="#entity-error" id=ee-er-in-attr><code>entity-error</code></a>.</li>        <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
709      <li><a href="#algorithm-to-check-a-node">Check each node</a>        <code>EntityReference</code> node, then it is an
710      which is different from <code>EntityReference</code> in        <a href="#entity-error" id=ee-attr-er><code>entity-error</code></a>.</li>
711      <code>childNodes</code> list of <var>n</var> recursively.</li>        <li>Otherwise,
712          <a href="#algorithm-to-check-a-node" title="check a node">check
713          <var>n<sub><var>c</var></sub></var></a> recusrively.</li>
714          </ol></li>
715        <li>If <code>nodeName</code> attribute of <var>n</var> is
716        <code>xml:space</code> <span class=ed>@@ or {xml namespace}:space ?</span>
717        and <code>value</code> attribute of <var>n</var> is neither
718        <code>default</code> nor <code>preserve</code>, then it is an
719        <a href="#xml-misc-error" id=xme-attr-xml-space><code>xml-misc-error</code></a>.<!--
720        Note that <!ATTLIST e xml:space (default|preserve) "a">...
721        <e xml:space="default"/> is conforming and valid. --></li>
722        <li class=ed>@@ xml:lang value is not a language tag [RFC 3066 or its
723        successor] or an empty string, then xml-misc-warning
724        (a "fact"-level error; not an XML error).</li>
725      <li class=ed>@@ <code>specified</code>,      <li class=ed>@@ <code>specified</code>,
726      <code>manakaiAttributeType</code></li>      <code>manakaiAttributeType</code> (#ValueType Validity constraint: Attribute Value Type)</li>
727        <!-- xml:space MUST be declared to be valid. -->
728        <li>Let <dfn id=var-v><var>v</var></dfn> be the value of the
729        attribute <code>value</code> of <var>n</var>.</li>
730        <li>Validate the <var>n</var> against the <span class=ed>declared
731        type</span> as following:
732          <dl class=switch>
733          <dt class=ed><code>ID_ATTR</code></dt>
734            <dd>
735              <ol>
736              <li><span class=ed>Validate <var>v</var> as an
737              <code>Name</code>.</span>  If it fails, then raise an
738              <a href="#xml-validity-error" id=vc-id-name><code>xml-validity-error</code></a>.</li>
739              <li><span class=ed>If <code>ID</code> <var>v</var> is defined,</span>
740              then raise an  
741              <a href="#xml-validity-error" id=vc-id-duplication><code>xml-validity-error</code></a>.</li>
742              </ol>
743            </dd>
744          <dt class=ed>IDREF_ATTR</dt>
745            <dd>
746              <ol>
747              <li><span class=ed>Validate <var>v</var> as an
748              <code>Name</code>.</span>  If it fails, then raise an
749              <a href="#xml-validity-error" id=vc-idref-name><code>xml-validity-error</code></a>.</li>
750              <li><span class=ed>If <code>ID</code> <var>v</var> is NOT
751              defined,</span> then raise an  
752              <a href="#xml-validity-error" id=vc-idref-match><code>xml-validity-error</code></a>.</li>
753              </ol>
754            </dd>
755          <dt class=ed>IDREFS_ATTR</dt>
756            <dd class=ed>@@</dd>
757          <dt class=ed>ENTITY_ATTR</dt>
758            <dd>
759              <ol>
760              <li><span class=ed>Validate <var>v</var> as an
761              <code>Name</code>.</span>  If it fails, then raise an
762              <a href="#xml-validity-error" id=vc-entname-name><code>xml-validity-error</code></a>.</li>
763              <li><span class=ed>If <code>Entity</code> <var>v</var> is NOT
764              defined,</span> then raise an  
765              <a href="#xml-validity-error" id=vc-entname-match><code>xml-validity-error</code></a>.</li>
766              </ol>
767            </dd>
768          <dt class=ed>ENTITIES_ATTR</dt>
769            <dd class=ed>@@</dd>
770          <dt class=ed>NMTOKEN_ATTR</dt>
771            <dd>
772              <ol>
773              <li><span class=ed>Validate <var>v</var> as an
774              <code>Nmtoken</code>.</span>  If it fails, then raise an
775              <a href="#xml-validity-error" id=vc-nmtok-name><code>xml-validity-error</code></a>.</li>
776              </ol>
777            </dd>
778          <dt class=ed>NMTOKENS_ATTR</dt>
779            <dd class=ed>@@</dd>
780          <dt class=ed>NOTATION_ATTR</dt>
781            <dd class=ed><var>v</var> must be one of enumerated values.
782            If not, then raise an
783            <a href="#xml-validity-error" id=vc-notatn-match><code>xml-validity-error</code></a>.</dd>
784          <dt class=ed>ENUMERATED_ATTR</dt>
785            <dd class=ed><var>v</var> must be one of enumerated values.
786            If not, then raise an
787            <a href="#xml-validity-error" id=vc-enum><code>xml-validity-error</code></a>.</dd>
788          <dt class=ed>@@</dt>
789          </dl>
790        </li>
791        <li>If <span class=ed>type ID and default is NOT #IMPLIED or #REQUIRED</span>, then
792        raise an
793        <a href="#xml-validity-error" id=vc-id-default><code>xml-validity-error</code></a>.</li>
794        <li class=ed>@@ #FixedAttr Validity constraint: Fixed Attribute Default</li>
795        <li class=ed>@@ strict serialization error for U+000D, U+000A, and
796        U+0009 characters, leading/trailing U+0020, and U+0020{2,} string?</li>
797      </ol>      </ol>
798    </dd>    </dd>
799  <dt>If <var>n</var> is an <code>AttributeDefinition</code> node</dt>  <dt>If <var>n</var> is an <code>AttributeDefinition</code> node</dt>
800    <dd class=ed></dd>    <dd>
801        <ol>
802        <li class=ed></li>
803        <li>If <code>nodeName</code> attribute of <var>n</var> is
804        <code>xml:space</code> <span class=ed>@@ or {xml namespace}:space ?</span>
805        and <span class=ed>its declared type is different from (default|preserve),
806        (preserve|default), (default), or (preserve)</span>, then raise an
807        <a href="#xml-misc-error" id=xme-at-xml-space><code>xml-misc-error</code></a>.</li>
808        <li>For each node <dfn id=var-ad-nc><var>n<sub><var>c</var></sub></var></dfn> in the
809        <code>childNodes</code> list of <var>n</var>,
810          <ol>
811          <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a
812          <code>Text</code> or <code>EntityReference</code> node, then it is an
813          <a href="#xml-well-formedness-error" id=wfe-at-child><code>xml-well-formedness-error</code></a>.</li>
814          <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
815          <code>EntityReference</code> node, then it is an
816          <a href="#entity-error" id=ee-at-er><code>entity-error</code></a>.</li>
817          <li>Otherwise,
818          <a href="#algorithm-to-check-a-node" title="check a node">check
819          <var>n<sub><var>c</var></sub></var></a> recusrively.</li>
820          </ol></li>
821        <li class=ed>If <code>NOTATION_ATTR</code>, enumerated values MUST
822        be declared.  If not, then raise an
823        <a href="#xml-validity-error" id=vc-notatn-declared><code>xml-validity-error</code></a>.</li>
824        <li class=ed>If <code>NOTATION_ATTR</code> or <code>ENUMERATED_ATTR</code>,
825        values MUST all be distinct.  If not, then raise an
826        <a href="#xml-validity-error" id=vc-no-duplicate-tokens><code>xml-validity-error</code></a>.</li>
827        <li class=ed>If <code>NOTATION_ATTR</code> on an <code>EMPTY</code>
828        element, then raise an
829        <a href="#xml-validity-error" id=vc-no-notation-empty><code>xml-validity-error</code></a>.</li>
830        <li class=ed>@@ #defattrvalid Validity constraint: Attribute Default Value Syntactically Correct</li>
831        </ol>
832      </dd>
833  <dt>If <var>n</var> is a <code>CDATASection</code> node</dt>  <dt>If <var>n</var> is a <code>CDATASection</code> node</dt>
834    <dd>    <dd>
835      <ol>      <ol>
836      <li><a href="#algorithm-to-validate-an-xml-character-data">Validate the      <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the
837      <code>data</code> attribute value as an <abbr>XML</abbr> character      <code>data</code> attribute value as an <abbr>XML</abbr> character
838      data</a>.</li>      data</a>.</li>
839      <li>If the <code>data</code> attribute value contains      <li>If the <code>data</code> attribute value contains
840      a string <code>]]></code>, then it is a      a string <code>]]></code>, then raise an
841      <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>
842      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>If the <code>childNodes</code> list of <var>n</var> contains
843      any nodes, they are in      any nodes, they are in
844      <a href="#xml-well-formedness-error" id=wfe-cs-child><code>xml-well-formedness-error</code></a>s.</li>      <a href="#xml-well-formedness-error" id=wfe-cs-child><code>xml-well-formedness-error</code></a>.</li>
845      </ol>      </ol>
846    </dd>    </dd>
847  <dt>If <var>n</var> is a <code>Comment</code> node</dt>  <dt>If <var>n</var> is a <code>Comment</code> node</dt>
848    <dd>    <dd>
849      <ol>      <ol>
850      <li><a href="#algorithm-to-validate-an-xml-character-data">Validate the      <li>Raise an
851        <a href="#round-trip-warning" id=rtw-comment><code>round-trip-warning</code></a>.</li>
852        <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the
853      <code>data</code> attribute value as an <abbr>XML</abbr> character      <code>data</code> attribute value as an <abbr>XML</abbr> character
854      data</a>.</li>      data</a>.</li>
855      <li>If the <code>data</code> attribute value contains      <li>If the <code>data</code> attribute value contains
856      a string <code>--</code>, or if it ends with a character      a string <code>--</code>, or if it ends with a character
857      <code>-</code>, then it is a      <code>-</code>, then raise an
858      <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>.<!--
859        "for compatibility" --></li>
860      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>If the <code>childNodes</code> list of <var>n</var> contains
861      any nodes, they are in      any nodes, they are in
862      <a href="#xml-well-formedness-error" id=wfe-comment-child><code>xml-well-formedness-error</code></a>s.</li>      <a href="#xml-well-formedness-error" id=wfe-comment-child><code>xml-well-formedness-error</code></a>.</li>
863      </ol>      </ol>
864    </dd>    </dd>
865  <dt>If <var>n</var> is a <code>Document</code> node</dt>  <dt>If <var>n</var> is a <code>Document</code> node</dt>
# Line 248  following:</p> Line 870  following:</p>
870      then it is an <code class=ed>unknown-error?</code>.</li>      then it is an <code class=ed>unknown-error?</code>.</li>
871      <li>If the <code>xmlEncoding</code> attribute value does <em>not</em>      <li>If the <code>xmlEncoding</code> attribute value does <em>not</em>
872      match to <code>[A-Za-z] ([A-Za-z0-9._] | '-')*</code>      match to <code>[A-Za-z] ([A-Za-z0-9._] | '-')*</code>
873      <span class=ed>@@ formal def</span>, then it is a      <span class=ed>@@ formal def</span>, then it is an
874      <a href="#xml-well-formedness-error" id=wfe-encoding><code>xml-well-formedness-error</code></a>.</li>      <a href="#xml-well-formedness-error" id=wfe-encoding><code>xml-well-formedness-error</code></a>.</li>
875      <li>The <code>childNodes</code> list of <var>n</var> have to      <li>The <code>childNodes</code> list of <var>n</var> have to
876      consist of zero or more <code>Comment</code> and/or      consist of zero or more <code>Comment</code> and/or
# Line 258  following:</p> Line 880  following:</p>
880      <code>ProcessingInstruction</code> nodes, followed by      <code>ProcessingInstruction</code> nodes, followed by
881      an <code>Element</code> node, followed      an <code>Element</code> node, followed
882      by zero or more <code>Comment</code> and/or      by zero or more <code>Comment</code> and/or
883      <code>ProcessingInstruction</code> nodes.  Any violation to this is a      <code>ProcessingInstruction</code> nodes.  Any violation to this is an
884      <a href="#xml-well-formedness-error" id=wfe-document-child><code>xml-well-formedness-error</code></a>.</li>      <a href="#xml-well-formedness-error" id=wfe-document-child><code>xml-well-formedness-error</code></a>.</li>
885      <li><a href="#algorithm-to-check-a-node">Check each node</a>      <li>For each node <dfn id=var-document-nc><var>n<sub><var>c</var></sub></var></dfn>
886      which is different from <code>EntityReference</code> in      in the <code>childNodes</code> list of <var>n</var>,
887      <code>childNodes</code> list of <var>n</var> recursively.</li>        <ol>
888          <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
889          <code>EntityReference</code> node, then
890          <a href="#algorithm-to-check-a-node" title="check a node">check
891          <var>n<sub><var>c</var></sub></var></a> recursively.</li>
892          </ol></li>
893      <li class=ed>@@ <code>allDeclarationsProcessed</code></li>      <li class=ed>@@ <code>allDeclarationsProcessed</code></li>
894      </ol>      </ol>
895    </dd>    </dd>
896  <dt>If <var>n</var> is a <code>DocumentFragment</code> node</dt>  <dt>If <var>n</var> is a <code>DocumentFragment</code> node</dt>
897    <dd>    <dd>
898      <ol>      <ol>
899      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>For each node <dfn id=var-df-nc><var>n<sub><var>c</var></sub></var></dfn>
900      a node which is <em>not</em> <code>Element</code>,      in the <code>childNodes</code> list of <var>n</var>,
901      <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,        <ol>
902      <code>ProcessingInstruction</code>, or        <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
903      <code>EntityReference</code> node, then it is a        <code>Element</code>, <code>Text</code>, <code>CDATASection</code>,
904      <a href="#xml-well-formedness-error" id=wfe-df-child><code>xml-well-formedness-error</code></a>.</li>        <code>Comment</code>, <code>ProcessingInstruction</code>, or
905      <li>If the <code>childNodes</code> list of <var>n</var> contains        <code>EntityReference</code> node, then it is an
906      an <code>EntityReference</code> node, it is an        <a href="#xml-well-formedness-error" id=wfe-df-child><code>xml-well-formedness-error</code></a>.</li>
907      <a href="#entity-error" id=ee-er-in-df><code>entity-error</code></a>.</li>        <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
908      <li><a href="#algorithm-to-check-a-node">Check each node</a>        <code>EntityReference</code> node, then it is an
909      which is different from <code>EntityReference</code> in        <a href="#entity-error" id=ee-df-er><code>entity-error</code></a>.</li>
910      <code>childNodes</code> list of <var>n</var> recursively.</li>        <li>Otherwise,
911          <a href="#algorithm-to-check-a-node" title="check a node">check
912          <var>n<sub><var>c</var></sub></var></a> recursively.</li>
913          </ol></li>
914      </ol>      </ol>
915    </dd>    </dd>
916  <dt>If <var>n</var> is a <code>DocumentType</code> node</dt>  <dt>If <var>n</var> is a <code>DocumentType</code> node</dt>
917    <dd>    <dd>
918      <ol>      <ol>
919      <li><a href="#algorithm-to-validate-a-ncname">Validate the      <li><a href="#algorithm-to-validate-an-ncname">Validate the
920      <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>      <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
921      <li>If the <code>publicId</code> attribute value contains any character      <li>Follow the following substeps:
922      that is outside of the range of <code>#x20 | <!--#xD | #xA |-->        <ol>
923      [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]</code><!-- @@ TODO: formal def -->,        <li>If <code>ownerDocument</code> attribute of <var>n</var> is
924      or contains a leading <code class=char>U+0020</code> character,        <code>null</code>, then abort these substeps.</li>
925      a trailing <code class=char>U+0020</code> character, or a        <li>If <code>documentElement</code> attribute of the node
926      sequence of two or more <code class=char>U+0020</code> characters,        set to <code>ownerDocument</code> attribute of <var>n</var> is
927      then it is a        <code>null</code>, then abort these substeps.</li>
928      <a href="#xml-well-formedness-error" id=wfe-dt-public-id><code>xml-well-formedness-error</code></a>.</li>        <li>If <code>nodeName</code> attribute of the node set to
929      <li>If the <code>systemId</code> attribute value contains        <code>documentElement</code> attribute of the node set to
930      both <code>"</code> and <code>'</code> characters, it is a        <code>ownerDocument</code> attribute of <var>n</var> is
931      <a href="#xml-well-formedness-error" id=wfe-dt-system-id><code>xml-well-formedness-error</code></a>.</li>        different from <code>nodeName</code> of <var>n</var>,
932      <!-- publicId = non-null and systemId = null -->        then raise an
933      <li>If the <code>childNodes</code> list of <var>n</var> contains        <a href="#xml-validity-error" id=vc-roottype><code>xml-validity-error</code></a>.</li></li>
934      a node which is <em>not</em> <code>ProcessingInstruction</code> node,        </ol>
935      then it is a      </li>
936      <a href="#xml-well-formedness-error" id=wfe-dt-child><code>xml-well-formedness-error</code></a>.      <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate
937      <span class=ed>@@ ref to manakai's extensions</span></li>      the <code>publicId</code> attribute value as a public identifier</a>.</li>
938      <li><a href="#algorithm-to-check-a-node">Check each node</a>      <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate
939      which is different from <code>EntityReference</code> in      the <code>systemId</code> attribute value as a system identifier</a>.</li>
940      <code>childNodes</code> list of <var>n</var> recursively.</li>      <li>If the <code>publicId</code> attribute value of <var>n</var> is
941      <li class=ed>@@ <code>entities</code>, <code>notations</code>,      <em>not</em> <code>null</code> and the <code>systemId</code> attribute
942      <code>elementTypes</code>, externally declared?</li>      value of <var>n</var> is <code>null</code>, then raise an
943        <a href="#xml-well-formedness-error" id=wfe-dt-sid><code>xml-well-formedness-error</code></a>.
944        <span class=ed>@@ publicId == null?  Or, publicId == ""</span></li>
945        <li>For each node <dfn id=var-dt-nc><var>n<sub><var>c</var></sub></var></dfn>
946        in the <code>childNodes</code> list of <var>n</var>,
947          <ol>
948          <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> a
949          <code>ProcessingInstruction</code> node, then it is an
950          <a href="#xml-well-formedness-error" id=wfe-dt-child><code>xml-well-formedness-error</code></a>.
951          <span class=ed>@@ ref to manakai's extensions</span></li>
952          <li>Otherwise, <!-- if n_c is not an EntityReference node, -->
953          <a href="#algorithm-to-check-a-node" title="check a node">check
954          <var>n<sub><var>c</var></sub></var></a> recusrively.</li>
955          </ol></li>
956        <li>For each node in the <code>entities</code>, <code>notations</code>,
957        and <code>elementTypes</code> lists of <var>n</var>,
958        <a href="#algorithm-to-check-a-node" title="check a node">check the
959        node</a> recursively.</li>
960        <li class=ed>@@ externally declared?</li>
961        <li>If the <code>NamedNodeMap</code> object in the <code>entities</code>
962        attribute of <var>n</var> does not contain <code>Entity</code> nodes
963        whose <code>nodeName</code> attribute are <code>amp</code>,
964        <code>lt</code>, <code>gt</code>, <code>apos</code>, and <code>quot</code>
965        then raise
966        <a href="#xml-misc-recommentation" id=xmr-predefined><code>xml-misc-recommendation</code></a>(s).
967      </ol>      </ol>
968    </dd>    </dd>
969  <dt>If <var>n</var> is an <code>Element</code> node</dt>  <dt>If <var>n</var> is an <code>Element</code> node</dt>
970    <dd>    <dd>
971      <ol>      <ol>
972      <li><a href="#algorithm-to-validate-a-ncname">Validate the      <li><a href="#algorithm-to-validate-an-ncname">Validate the
973      <code>localName</code> attribute value as an <code>NCName</code></a>.</li>      <code>localName</code> attribute value as an <code>NCName</code></a>.</li>
974      <li>If the <code>prefix</code> attribute value is different from      <li>If the <code>prefix</code> attribute value is different from
975      <code>null</code>, then <a href="#algorithm-to-validate-a-ncname">validate      <code>null</code>, then <a href="#algorithm-to-validate-an-ncname">validate
976      the <code>prefix</code> attribute value as an <code>NCName</code></a>.</li>      the <code>prefix</code> attribute value as an <code>NCName</code></a>.</li>
977      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>For each node <dfn id=var-element-nc><var>n<sub><var>c</var></sub></var></dfn>
978      a node which is <em>not</em> <code>Element</code>,      in the <code>childNodes</code> list of <var>n</var>,
979      <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,        <ol>
980      <code>ProcessingInstruction</code>, or        <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
981      <code>EntityReference</code> node, then it is a        <code>Element</code>,
982      <a href="#xml-well-formedness-error" id=wfe-element-child><code>xml-well-formedness-error</code></a>.</li>        <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,
983      <li>If the <code>childNodes</code> list of <var>n</var> contains        <code>ProcessingInstruction</code>, or
984      an <code>EntityReference</code> node, it is an        <code>EntityReference</code> node, then it is an
985      <a href="#entity-error" id=ee-er-in-element><code>entity-error</code></a>.</li>        <a href="#xml-well-formedness-error" id=wfe-element-child><code>xml-well-formedness-error</code></a>.</li>
986      <li><a href="#algorithm-to-check-a-node">Check each node</a>        <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
987      which is different from <code>EntityReference</code> in        <code>EntityReference</code> node, then it is an
988      <code>childNodes</code> list of <var>n</var> recursively.</li>        <a href="#entity-error" id=ee-element-er><code>entity-error</code></a>.</li>
989          <li>Otherwise,
990          <a href="#algorithm-to-check-a-node" title="check a node">check
991          <var>n<sub><var>c</var></sub></var></a> recursively.</li>
992          </ol></li>
993        <li class=ed>@@ #elementvalid Validity constraint: Element Valid</li>
994        <li>Let <var>attrs</var> be the value of the <code>attribute</code>
995        attribute of <var>n</var>.  Check conformance of <var>attrs</var>
996        as following:
997          <ol>
998          <li>If <var>attrs</var> contains an <code>Attr</code> node whose
999          <code>nodeName</code> attribute value is equal to that of another
1000          <code>Attr</code> node in <var>attrs</var>, then raise an
1001          <a href="#xml-well-formedness-error" id=wfe-uniqattspec><code>xml-well-formedness-error</code></a>.<!--
1002          #uniqattspec Well-formedness constraint: Unique Att Spec --></li>
1003          <li class=ed>@@ #RequiredAttr Validity constraint: Required Attribute</li>
1004          </ol>
1005        </li>
1006      </ol>      </ol>
1007    </dd>    </dd>
1008  <dt>If <var>n</var> is an <code>ElementTypeDefinition</code> node</dt>  <dt>If <var>n</var> is an <code>ElementTypeDefinition</code> node</dt>
   <dd class=ed></dd>  
 <dt>If <var>n</var> is an <code>Entity</code> node</dt>  
1009    <dd>    <dd>
1010      <ol>      <ol>
1011      <li>An <a href="#entity-error" id=ee-entity-node><code>entity-error</code></a> <span class=ed>@@ if !notationName</span>.</li>      <li class=ed></li>
     <li><a href="#algorithm-to-validate-a-ncname">Validate the  
     <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>  
     <li>If the <code>publicId</code> attribute value contains any character  
     that is outside of the range of <code>#x20 | <!--#xD | #xA |-->  
     [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]</code><!-- @@ TODO: formal def -->,  
     or contains a leading <code class=char>U+0020</code> character,  
     a trailing <code class=char>U+0020</code> character, or a  
     sequence of two or more <code class=char>U+0020</code> characters,  
     then it is a  
     <a href="#xml-well-formedness-error" id=wfe-dt-public-id><code>xml-well-formedness-error</code></a>.</li>  
     <li>If the <code>systemId</code> attribute value contains  
     both <code>"</code> and <code>'</code> characters, it is a  
     <a href="#xml-well-formedness-error" id=wfe-dt-system-id><code>xml-well-formedness-error</code></a>.</li>  
     <!-- publicId = non-null and systemId = null -->  
     <li class=ed>@@ <code>notationName</code></li>  
1012      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>If the <code>childNodes</code> list of <var>n</var> contains
1013      a node which is <em>not</em> <code>Element</code>,      any nodes, they are in
1014      <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,      <a href="#xml-well-formedness-error" id=wfe-et-child><code>xml-well-formedness-error</code></a>.</li>
1015      <code>ProcessingInstruction</code>, or      <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>
1016      <code>EntityReference</code> node, then it is a      <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>
1017      <a href="#xml-well-formedness-error" id=wfe-entity-child><code>xml-well-formedness-error</code></a>.</li>      <li class=ed>@@ #vc-MixedChildrenUnique
1018        Validity constraint: No Duplicate Types</li>
1019        <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>
1020        <li>If there is more than one <code>AttributeDefinition</code> node
1021        with <span class=ed>attribute type <code>ID</code></span> in the
1022        <code>NamedNodeMap</code> list contained in the
1023        <code>attributeDefinitions</code> attribute of <var>n</var>, then raise an
1024        <a href="#xml-validity-error" id=vc-one-id-per-el><code>xml-validity-error</code></a>.</li>
1025        <li>If there is more than one <code>AttributeDefinition</code> node
1026        with <span class=ed>attribute type <code>NOTATION</code></span> in the
1027        <code>NamedNodeMap</code> list contained in the
1028        <code>attributeDefinitions</code> attribute of <var>n</var>, then raise an
1029        <a href="#xml-validity-error" id=vc-one-notation-per><code>xml-validity-error</code></a>.</li>
1030        <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>
1031        </ol>
1032      </dd>
1033    <dt>If <var>n</var> is an <code>Entity</code> node whose
1034    <code>notationName</code> attribute value is <code>null</code> (i.e. a
1035    parsed entity)</dt>
1036      <dd>
1037        <ol>
1038        <li>Raise an
1039        <a href="#entity-error" id=ee-entity-node><code>entity-error</code></a>.</li>
1040        <li><a href="#algorithm-to-validate-an-ncname">Validate the
1041        <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1042        <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate
1043        the <code>publicId</code> attribute value as a public identifier</a>.</li>
1044        <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate
1045        the <code>systemId</code> attribute value as a system identifier</a>.</li>
1046        <li>If the <code>publicId</code> attribute value of <var>n</var> is
1047        <em>not</em> <code>null</code> and the <code>systemId</code> attribute
1048        value of <var>n</var> is <code>null</code>, then raise an
1049        <a href="#xml-well-formedness-error" id=wfe-entity-sid><code>xml-well-formedness-error</code></a>.</li>
1050        <li>For each node <dfn id=var-entity-nc><var>n<sub><var>c</var></sub></var></dfn>
1051        in the <code>childNodes</code> list of <var>n</var>,
1052          <ol>
1053          <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1054          <code>Element</code>,
1055          <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,
1056          <code>ProcessingInstruction</code>, or <code>EntityReference</code>
1057          node, then it is an
1058          <a href="#xml-well-formedness-error" id=wfe-entity-child><code>xml-well-formedness-error</code></a>.</li>
1059          <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is an
1060          <code>EntityReference</code> node, then it is an
1061          <a href="#entity-error" id=ee-er-er><code>entity-error</code></a>.</li>
1062          <li>Otherwise,
1063          <a href="#algorithm-to-check-a-node" title="check a node">check
1064          <var>n<sub><var>c</var></sub></var></a> recursively.</li>
1065          </ol></li>
1066        </ol>
1067      </dd>
1068    <dt>If <var>n</var> is an <code>Entity</code> node whose
1069    <code>notationName</code> attribute value is <em>not</em> <code>null</code>
1070    (i.e. an unparsed entity)</dt>
1071      <dd>
1072        <ol>
1073        <li><a href="#algorithm-to-validate-an-ncname">Validate the
1074        <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1075        <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate
1076        the <code>publicId</code> attribute value as a public identifier</a>.</li>
1077        <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate
1078        the <code>systemId</code> attribute value as a system identifier</a>.</li>
1079        <li>If the <code>systemId</code> attribute value of <var>n</var> is
1080        <code>null</code>, then raise an
1081        <a href="#xml-well-formedness-error" id=wfe-uentity-sid><code>xml-well-formedness-error</code></a>.</li>
1082        <li><a href="#algorithm-to-validate-an-ncname">Validate the
1083        <code>notationName</code> attribute value of <var>n</var> as an
1084        <code>NCName</code></a>.</li>
1085        <li class=ed>@@ #not-declared Validity constraint: Notation Declared</li>
1086      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>If the <code>childNodes</code> list of <var>n</var> contains
1087      an <code>EntityReference</code> node, it is an      any nodes, they are in
1088      <a href="#entity-error" id=ee-er-in-er><code>entity-error</code></a>.</li>      <a href="#xml-well-formedness-error" id=wfe-uentity-child><code>xml-well-formedness-error</code></a>.</li>
     <li><a href="#algorithm-to-check-a-node">Check each node</a>  
     which is different from <code>EntityReference</code> in  
     <code>childNodes</code> list of <var>n</var> recursively.</li>  
1089      </ol>      </ol>
1090    </dd>    </dd>
1091  <dt>If <var>n</var> is an <code>EntityReference</code> node</dt>  <dt>If <var>n</var> is an <code>EntityReference</code> node</dt>
1092    <dd>    <dd>
1093      <ol>      <ol>
1094      <li>An <a href="#entity-error" id=ee-er-node><code>entity-error</code></a>.</li>      <li>An <a href="#entity-error" id=ee-er-node><code>entity-error</code></a>.</li>
1095      <li><a href="#algorithm-to-validate-a-ncname">Validate the      <li><a href="#algorithm-to-validate-an-ncname">Validate the
1096      <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>      <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1097      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>For each node <dfn id=var-er-nc><var>n<sub><var>c</var></sub></var></dfn>
1098      a node which is <em>not</em> <code>Element</code>,      in the <code>childNodes</code> list of <var>n</var>,
1099      <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,        <ol>
1100      <code>ProcessingInstruction</code>, or        <li>If <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1101      <code>EntityReference</code> node, then it is a        <code>Element</code>,
1102      <a href="#xml-well-formedness-error" id=wfe-er-child><code>xml-well-formedness-error</code></a>.</li>        <code>Text</code>, <code>CDATASection</code>, <code>Comment</code>,
1103      <li>If the <code>childNodes</code> list of <var>n</var> contains        <code>ProcessingInstruction</code>, or <code>EntityReference</code>
1104      an <code>EntityReference</code> node, it is an        node, then it is an
1105      <a href="#entity-error" id=ee-er-in-entity><code>entity-error</code></a>.</li>        <a href="#xml-well-formedness-error" id=wfe-er-child><code>xml-well-formedness-error</code></a>.</li>
1106      <li><a href="#algorithm-to-check-a-node">Check each node</a>        <li>Otherwise, if <var>n<sub><var>c</var></sub></var> is <em>not</em> an
1107      which is different from <code>EntityReference</code> in        <code>EntityReference</code> node, then it is an
1108      <code>childNodes</code> list of <var>n</var> recursively.</li>        <a href="#entity-error" id=ee-entity-er><code>entity-error</code></a>.</li>
1109          <li>Otherwise,
1110          <a href="#algorithm-to-check-a-node" title="check a node">check
1111          <var>n<sub><var>c</var></sub></var></a> recursively.</li>
1112          </ol></li>
1113      </ol>      </ol>
1114    </dd>    </dd>
1115  <dt>If <var>n</var> is a <code>Notation</code> node</dt>  <dt>If <var>n</var> is a <code>Notation</code> node</dt>
1116    <dd>    <dd>
1117      <ol>      <ol>
1118      <li><a href="#algorithm-to-validate-a-ncname">Validate the      <li><a href="#algorithm-to-validate-an-ncname">Validate the
1119      <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>      <code>nodeName</code> attribute value as an <code>NCName</code></a>.</li>
1120      <li>If the <code>publicId</code> attribute value contains any character      <li><a href="#algorithm-to-validate-a-public-identifier" title="validate a public identifier">Validate
1121      that is outside of the range of <code>#x20 | <!--#xD | #xA |-->      the <code>publicId</code> attribute value as a public identifier</a>.</li>
1122      [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]</code><!-- @@ TODO: formal def -->,      <li><a href="#algorithm-to-validate-a-system-identifier" title="validate a system identifier">Validate
1123      or contains a leading <code class=char>U+0020</code> character,      the <code>systemId</code> attribute value as a system identifier</a>.</li>
     a trailing <code class=char>U+0020</code> character, or a  
     sequence of two or more <code class=char>U+0020</code> characters,  
     then it is a  
     <a href="#xml-well-formedness-error" id=wfe-dt-public-id><code>xml-well-formedness-error</code></a>.</li>  
     <li>If the <code>systemId</code> attribute value contains  
     both <code>"</code> and <code>'</code> characters, it is a  
     <a href="#xml-well-formedness-error" id=wfe-dt-system-id><code>xml-well-formedness-error</code></a>.</li>  
1124      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>If the <code>childNodes</code> list of <var>n</var> contains
1125      any nodes, they are in      any nodes, they are in
1126      <a href="#xml-well-formedness-error" id=wfe-notation-child><code>xml-well-formedness-error</code></a>s.</li>      <a href="#xml-well-formedness-error" id=wfe-notation-child><code>xml-well-formedness-error</code></a>.</li>
1127      </ol>      </ol>
1128    </dd>    </dd>
1129  <dt>If <var>n</var> is a <code>ProcessingInstruction</code> node</dt>  <dt>If <var>n</var> is a <code>ProcessingInstruction</code> node</dt>
1130    <dd>    <dd>
1131      <ol>      <ol>
1132      <li><a href="#algorithm-to-validate-a-ncname">Validate the      <li>If the <code>target</code> attribute value matches to the string
1133      <code>target</code> attribute value as an <code>NCName</code></a>.</li>      <code>xml</code> in any case combination, then raise a
     <li>If the <code>target</code> attribute value matches to  
     <code>XML</code> case-insensitively, then it is a  
1134      <a href="#xml-well-formedness-error" id=wfe-pi-xml><code>xml-well-formedness-error</code></a>.</li>      <a href="#xml-well-formedness-error" id=wfe-pi-xml><code>xml-well-formedness-error</code></a>.</li>
1135      <li><a href="#algorithm-to-validate-an-xml-character-data">Validate the      <li>Otherwise, <a href="#algorithm-to-validate-an-ncname">validate the
1136      <code>data</code> attribute value as an <abbr>XML</abbr> character      <code>target</code> attribute value as an <code>NCName</code></a>.</li>
1137        <li>Then,
1138        <a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">validate
1139        the <code>data</code> attribute value as an <abbr>XML</abbr> character
1140      data</a>.</li>      data</a>.</li>
1141      <li>If the <code>data</code> attribute value contains      <li>If the <code>data</code> attribute value contains a string
1142      a string <code>?></code>, or starts with either      <code>?></code>, then raise a
1143      <code class=char>U+0009</code>, <code class=char>U+000A</code>,      <a href="#xml-well-formedness-error" id=wfe-pi-pic><code>xml-well-formedness-error</code></a>.</li>
1144      <code class=char>U+000D</code>, or <code class=char>U+0020</code>      <li>If the <code>data</code> attribute value starts with either
1145      character, then it is a      <code class=char>U+0009</code> <code class=charname>CHARACTER
1146      <a href="#round-trip-error" id=rte-pi-data><code>round-trip-error</code></a>.</li>      TABULATION</code>, <code class=char>U+000A</code> <code class=charname>LINE
1147        FEED</code>, <code class=char>U+000D</code> <code class=charname>CARRIAGE
1148        RETURN</code>, or <code class=char>U+0020</code>
1149        <code class=charname>SPACE</code> character, then raise a
1150        <a href="#round-trip-error" id=rte-pi-s><code>round-trip-error</code></a>.</li>
1151      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>If the <code>childNodes</code> list of <var>n</var> contains
1152      any nodes, they are in      any nodes, then raise an
1153      <a href="#xml-well-formedness-error" id=wfe-pi-child><code>xml-well-formedness-error</code></a>s.</li>      <a href="#xml-well-formedness-error" id=wfe-pi-child><code>xml-well-formedness-error</code></a>.</li>
1154      </ol>      </ol>
1155    </dd>    </dd>
1156  <dt>If <var>n</var> is a <code>Text</code> node</dt>  <dt>If <var>n</var> is a <code>Text</code> node</dt>
1157    <dd>    <dd>
1158      <ol>      <ol>
1159      <li><a href="#algorithm-to-validate-an-xml-character-data">Validate the      <li><a href="#algorithm-to-validate-an-xml-character-data" title="validate an XML string">Validate the
1160      <code>data</code> attribute value as an <abbr>XML</abbr> character      <code>data</code> attribute value as an <abbr>XML</abbr> character
1161      data</a>.</li>      data</a>.</li>
1162      <li>If the <code>childNodes</code> list of <var>n</var> contains      <li>If the <code>childNodes</code> list of <var>n</var> contains
1163      any nodes, they are in      any nodes, they are in
1164      <a href="#xml-well-formedness-error" id=wfe-text-child><code>xml-well-formedness-error</code></a>s.</li>      <a href="#xml-well-formedness-error" id=wfe-text-child><code>xml-well-formedness-error</code></a>.</li>
1165      </ol>      </ol>
1166    </dd>    </dd>
1167  <dt>Otherwise</dt>  <dt>Otherwise</dt>
1168    <dd><span class=ed>xml-well-formedness-error?  unknown-error?</span></dd>    <dd><span class=ed>xml-well-formedness-error?  unknown-error?</span></dd>
1169  </dl>  </dl>
1170    
1171  <p>The algorithm  </div>
 <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>  
1172    
1173  </div>  </div>
1174    
1175  <div class="section" id="examples">  <div id=classes class=section>
1176  <h2>Examples</h2>  <h2>Character Classes</h2>
1177    
1178  <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>  <p>This section defines a couple of character classes.
1179    These classes are referred to by algorithms specified above.</p>
1180    
1181    <p>Character class <dfn id=class-Char10><code>Char10</code></dfn>
1182    contains the following characters:</p>
1183    <ul>
1184    <li><code class=char>U+0009</code> <code class=charname>CHARACTER
1185    TABULATION</code></li>
1186    <li><code class=char>U+000A</code> <code class=charname>LINE FEED</code></li>
1187    <li><code class=char>U+000D</code> <code class=charname>CARRIAGE
1188    RETURN</code></li>
1189    <li><code class=char>U+0020</code> <code class=charname>SPACE</code>
1190    .. <code class=char>U+D7FF</code></li>
1191    <li><code class=char>U+E000</code> .. <code class=char>U+FFFD</code>
1192    <code class=charname>REPLACEMENT CHARACTER</code></li>
1193    <li><code class=char>U+10000</code> .. <code class=char>U+10FFFF</code></li>
1194    </ul>
1195    <div class="note memo">
1196    <p>This character class contains all characters allowed in the production rule
1197    <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Char"><code>Char</code></a>
1198    of <abbr>XML</abbr> 1.0
1199    <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p>
1200    </div>
1201    
1202  <div class="ed issue">  <p>Character class <dfn id=class-CompatChar10><code>CompatChar10</code></dfn>
1203    contains the following characters:</p>
1204    <ul>
1205    <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>
1206    </ul>
1207    
1208    <p>Character class <dfn id=class-ControlChar10><code>ControlChar10</code></dfn>
1209    contains the following characters:</p>
1210    <ul>
1211    <li><code class=char>U+007F</code> <code class=charname>DELETE</code> ..
1212    <code class=char>U+0084</code> <code class=charname>INDEX</code></li>
1213    <li><code class=char>U+0086</code> <code class=charname>START OF SELECTED
1214    AREA</code> .. <code class=char>U+009F</code> <code class=charname>APPLICATION
1215    PROGRAM COMMAND</code></li>
1216    <li><code class=char>U+FDD0</code> .. <code class=char>U+FDEF</code></li>
1217    <li><code class=char>U+1FFFE</code> .. <code class=char>U+1FFFF</code></li>
1218    <li><code class=char>U+2FFFE</code> .. <code class=char>U+2FFFF</code></li>
1219    <li><code class=char>U+3FFFE</code> .. <code class=char>U+3FFFF</code></li>
1220    <li><code class=char>U+4FFFE</code> .. <code class=char>U+4FFFF</code></li>
1221    <li><code class=char>U+5FFFE</code> .. <code class=char>U+5FFFF</code></li>
1222    <li><code class=char>U+6FFFE</code> .. <code class=char>U+6FFFF</code></li>
1223    <li><code class=char>U+7FFFE</code> .. <code class=char>U+7FFFF</code></li>
1224    <li><code class=char>U+8FFFE</code> .. <code class=char>U+8FFFF</code></li>
1225    <li><code class=char>U+9FFFE</code> .. <code class=char>U+9FFFF</code></li>
1226    <li><code class=char>U+AFFFE</code> .. <code class=char>U+AFFFF</code></li>
1227    <li><code class=char>U+BFFFE</code> .. <code class=char>U+BFFFF</code></li>
1228    <li><code class=char>U+CFFFE</code> .. <code class=char>U+CFFFF</code></li>
1229    <li><code class=char>U+DFFFE</code> .. <code class=char>U+DFFFF</code></li>
1230    <li><code class=char>U+EFFFE</code> .. <code class=char>U+EFFFF</code></li>
1231    <li><code class=char>U+FFFFE</code> .. <code class=char>U+FFFFF</code></li>
1232    <li><code class=char>U+10FFFE</code> .. <code class=char>U+10FFFF</code></li>
1233    </ul>
1234    <div class="note memo">
1235    <p>This character class contains the characters listed in the Note in
1236    <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#charsets">Section 2.2</a>
1237    of <abbr>XML</abbr> 1.0
1238    <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>,
1239    as amended by
1240    <a href="http://www.w3.org/XML/xml-V10-4e-errata#E02">errata</a>.</p>
1241    </div>
1242    
1243  <div class="example figure block">  <p>The character class <dfn id=class-NameStartChar10><code>NameStartChar10</code></dfn>
1244  <div class="caption">...</div>  contains the following characters:</p>
1245    <ul class=ed>
1246    </ul>
1247    <div class="note memo">
1248    <p>This character class contains all characters allowed as the first character
1249    of a string matching to the production rule
1250    <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Name"><code>Name</code></a>
1251    of <abbr>XML</abbr> 1.0
1252    <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p>
1253    </div>
1254    
1255  <pre><code>...</code></pre>  <p>The character class <dfn id=class-NameChar10><code>NameChar10</code></dfn>
1256    contains the following characters:</p>
1257    <ul>
1258    <li>The characters in the character class
1259    <a href="#class-NameStartChar10">NameStartChar10</a>.</li>
1260    <li class=ed></li>
1261    </ul>
1262    <div class="note memo">
1263    <p>This character class contains all characters allowed as the second
1264    character of a string matching to the production rule
1265    <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-Name"><code>Name</code></a>
1266    of <abbr>XML</abbr> 1.0
1267    <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p>
1268  </div>  </div>
1269    
1270    <p>The character class <dfn id=class-PubidChar><code>PubidChar</code></dfn>
1271    contains the following characters:</p>
1272    <ul>
1273    <li><code class=char>U+0009</code> <code class=charname>CHARACTER
1274    TABULATION</code></li>
1275    <li><code class=char>U+000A</code> <code class=charname>LINE FEED</code></li>
1276    <li><code class=char>U+000D</code> <code class=charname>CARRIAGE
1277    RETURN</code></li>
1278    <li><code class=char>U+0020</code> <code class=charname>SPACE</code></li>
1279    <li><code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>
1280    (<code class=char>!</code>)</li>
1281    <li><code class=char>U+0023</code> <code class=charname>DOLLAR SIGN</code>
1282    (<code class=char>$</code>)</li>
1283    <li><code class=char>U+0024</code> <code class=charname>NUMBER SIGN</code>
1284    (<code class=char>#</code>)</li>
1285    <li><code class=char>U+0025</code> <code class=charname>PERCENT SIGN</code>
1286    (<code class=char>%</code>)</li>
1287    <li><code class=char>U+0027</code> <code class=charname>APOSTROPHE</code>
1288    (<code class=char>'</code>)</li>
1289    <li><code class=char>U+0028</code> <code class=charname>LEFT PARENTHESIS</code>
1290    (<code class=char>(</code>)</li>
1291    <li><code class=char>U+0029</code> <code class=charname>RIGHT
1292    PARENTHESIS</code> (<code class=char>)</code>)</li>
1293    <li><code class=char>U+002A</code> <code class=charname>ASTERISK</code>
1294    (<code class=char>*</code>)</li>
1295    <li><code class=char>U+002B</code> <code class=charname>PLUS SIGN</code>
1296    (<code class=char>+</code>)</li>
1297    <li><code class=char>U+002C</code> <code class=charname>COMMA</code>
1298    (<code class=char>,</code>)</li>
1299    <li><code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
1300    (<code class=char>-</code>)</li>
1301    <li><code class=char>U+002E</code> <code class=charname>FULL STOP</code>
1302    (<code class=char>.</code>)</li>
1303    <li><code class=char>U+002F</code> <code class=charname>SOLIDUS</code>
1304    (<code class=char>/</code>)</li>
1305    <li><code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code>
1306    (<code class=char>0</code>) .. <code class=char>U+0039</code>
1307    <code class=charname>DIGIT NINE</code> (<code class=char>9</code>)</li>
1308    <li><code class=char>U+003A</code> <code class=charname>COLON</code>
1309    (<code class=char>:</code>)</li>
1310    <li><code class=char>U+003B</code> <code class=charname>SEMICOLON</code>
1311    (<code class=char>;</code>)</li>
1312    <li><code class=char>U+003D</code> <code class=charname>EQUAL SIGN</code>
1313    (<code class=char>=</code>)</li>
1314    <li><code class=char>U+003F</code> <code class=charname>QUESTION MARK</code>
1315    (<code class=char>?</code>)</li>
1316    <li><code class=char>U+0040</code> <code class=charname>COMMERCIAL AT</code>
1317    (<code class=char>@</code>)</li>
1318    <li><code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
1319    A</code> (<code class=char>A</code>) .. <code class=char>U+005A</code>
1320    <code class=charname>LATIN CAPITAL LETTER Z</code>
1321    (<code class=char>Z</code>)</li>
1322    <li><code class=char>U+005F</code> <code class=charname>LOW LINE</code>
1323    (<code class=char>_</code>)</li>
1324    <li><code class=char>U+0061</code> <code class=charname>LATIN CAPITAL LETTER
1325    A</code> (<code class=char>A</code>) .. <code class=char>U+007A</code>
1326    <code class=charname>LATIN CAPITAL LETTER Z</code>
1327    (<code class=char>Z</code>)</li>
1328    </ul>
1329    <div class="note memo">
1330    <p>This character class contains all characters allowed in the production rule
1331    <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#NT-PubidChar"><code>PubidChar</code></a>
1332    of <abbr>XML</abbr> 1.0
1333    <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>.</p>
1334  </div>  </div>
1335    
1336  </div>  </div>
# Line 497  is defined as following:</p> Line 1342  is defined as following:</p>
1342  <h3>Normative References</h3>  <h3>Normative References</h3>
1343    
1344  <dl>  <dl>
1345    <dt id=ref-DOM3CORE>DOM3CORE</dt>
1346      <dd class=ed>@@ W3C DOM Level 3 Core</dd>
1347    <dt id=ref-DOMDTDEF>DOMDTDEF</dt>
1348      <dd class=ed>@@ manakai's extension to DOM for document type definitions</dd>
1349  <dt id="ref-KEYWORDS">KEYWORDS</dt>  <dt id="ref-KEYWORDS">KEYWORDS</dt>
1350    <dd><cite><a href="urn:ietf:rfc:2119">Key words for use in    <dd><cite><a href="urn:ietf:rfc:2119">Key words for use in
1351    <abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>,    <abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>,
# Line 559  is defined as following:</p> Line 1408  is defined as following:</p>
1408    <abbr title="World Wide Web Consortium">W3C</abbr>$B!>(Bpublished    <abbr title="World Wide Web Consortium">W3C</abbr>$B!>(Bpublished
1409    version of the specification is available at    version of the specification is available at
1410    <code class=URI>&lt;<a href="http://www.w3.org/TR/xbl/">http://www.w3.org/TR/xbl/</a>></code>.</dd>    <code class=URI>&lt;<a href="http://www.w3.org/TR/xbl/">http://www.w3.org/TR/xbl/</a>></code>.</dd>
1411    <dt id=ref-XML5>XML5</dt>
1412      <dd class=ed>@@</dd>
1413  </dl>  </dl>
1414  </div>  </div>
1415    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.26

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24