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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.26 - (show annotations) (download) (as text)
Sat Mar 29 06:35:16 2008 UTC (18 years, 7 months ago) by wakaba
Branch: MAIN
Changes since 1.25: +116 -15 lines
File MIME type: text/html
How general entity declarations should be handled

1 <!DOCTYPE html>
2 <html lang="en" class="formal-specification status-work-in-progress">
3 <head>
4 <title>manakai's XML Conformance Checking</title>
5 <link rel="stylesheet" href="http://suika.fam.cx/www/style/html/spec">
6 <link rel="license" href="http://suika.fam.cx/c/gnu/fdl">
7 <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>
17 <body class="has-abstract">
18
19 <div class="header">
20 <h1>manakai's <abbr>XML</abbr> Conformance Checking</h1>
21 <h2>Working Draft <time datetime=2008-03-29>29 March 2008</time></h2>
22
23 <dl class="versions-uri">
24 <dt>This Version</dt>
25 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work"
26 >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc-work</a>&gt;</code></dd>
27 <dt>Latest Version</dt>
28 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc"
29 >http://suika.fam.cx/www/markup/xml/xmlcc/xmlcc</a>&gt;</code></dd>
30 <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> -->
34 <dt>Version History</dt>
35 <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>
37 <dl class="authors" id="author">
38 <dt>Author</dt>
39 <dd><a href="http://suika.fam.cx/~wakaba/who?" rel="author"
40 lang=ja>Wakaba</a>
41 <code class="mail">&lt;<a href="mailto:[email protected]" rel="author"
42 >[email protected]</a>&gt;</code></dd>
43 </dl>
44
45 <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>.
47 Permission is granted to copy, distribute and/or modify this document
48 under the terms of the <a rel="license"
49 href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>,
50 Version 1.2
51 or any later version published by the <a
52 href="http://www.fsf.org/">Free Software Foundation</a>;
53 with no Invariant Sections, no Front$B!>(BCover Texts, and no Back$B!>(BCover
54 Texts. A copy of the license is
55 available at <code class="URI">&lt;<a
56 href="http://www.gnu.org/copyleft/fdl.html"
57 rel="license">http://www.gnu.org/copyleft/fdl.html</a>&gt;</code>.</p>
58 </div>
59
60 <div id="abstract" class="section">
61 <h2>Abstract</h2>
62
63 <div class="ed issue">...</div>
64
65 </div>
66
67 <div id="status" class="section">
68 <h2>Status of This Document</h2>
69
70 <p class=section-info><em>This section describes the status of this document
71 at the time of its publication. Other documents
72 might supersede this document.</em></p>
73
74 <p>This document is a working draft, produced as part of the
75 <a href="http://suika.fam.cx/www/markup/html/whatpm/readme">Whatpm</a>
76 subproject of the
77 <a href="http://suika.fam.cx/www/manakai-core/doc/web/">manakai</a>
78 project. It might be updated, replaced, or obsoleted by
79 other documents at any time. It is inappropriate to
80 cite this document as other than <q>work in progress</q>.</p>
81
82 <p>Comments on this document are welcome and
83 may be sent to the <a href="#author">author</a>.</p>
84
85 <p>Translations of thie document might be available.
86 The English version of the document is the only
87 normative version.</p>
88 </div>
89
90 <div id="introduction" class="section">
91 <h2>Introduction</h2>
92
93 <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>
94
95 <div class="issue ed">...</div>
96
97
98 </div>
99
100 <div class="section" id="terminology">
101 <h2>Terminology</h2>
102
103 <p>The key words <q><em class="rfc2119">MUST</em></q>,
104 <q><em class="rfc2119">MUST NOT</em></q>,
105 <q><em class="rfc2119">SHOULD</em></q>,
106 <q><em class="rfc2119">SHOULD NOT</em></q>, and
107 <q><em class=rfc2119>MAY</em></q> in this
108 document are to be interpreted as described in
109 <a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr>
110 2119</a>
111 <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>
112
113 <!-- Strictly speaking the paragraph below is not part of terminology. -->
114 <p>All examples and notes in this specification are non$B!>(Bnormative,
115 as are all sections explicitly marked non$B!>(Bnormative. Everything
116 else in this specification is normative.</p>
117
118 <p><span class=ed>Algorithm is normative but non-normative</span>.
119 In addition, the order in which <a href="#errors">errors</a> are
120 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>
127
128
129 <div class=section id=error-categories>
130 <h2>Error Classification</h2>
131
132 <p class=ed>If a <code>Document</code> node has no
133 xml-well-formedness-error, entity-error, and unknown-error,
134 then it is well-formed. If a well-formed <code>Document</code>
135 node has no xml-validity-error, it is valid.</p>
136
137 <div class="note memo">
138 <p>A well$B!>(Bformed <code>Document</code> can be safely serialized
139 into a well$B!>(Bformed XML document. A valid <code>Document</code>
140 can be easily serialized into a valid XML document.</p>
141 </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
147 <dfn id=error-category title="error category">error categories</dfn>:</p>
148
149 <dl id=errors>
150 <dt><dfn id=entity-error><code>entity-error</code></dfn></dt>
151 <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>
163 <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>
178 <dd class=ed>@@</dd>
179 <dt><dfn id=xml-misc-error><code>xml-misc-error</code></dt>
180 <dd>An <abbr>XML</abbr> <i>error</i> (<abbr>XML</abbr> 1.0
181 <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>
182 <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-error">error</a> /
183 <abbr>XML</abbr> 1.1
184 <cite class="bibref normative">[<a href="#ref-XML11">XML11</a>]</cite>
185 <a href="@@/#dt-error">error</a>)
186 that is not classified to any other <a href="#error-category">error
187 category</a>.</dd>
188 <dt><dfn id=xml-misc-fatal-error><code>xml-misc-fatal-error</code></dt>
189 <dd>An <abbr>XML</abbr> <i>fatal error</i> (<abbr>XML</abbr> 1.0
190 <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>]</cite>
191 <a href="http://www.w3.org/TR/2006/REC-xml-20060816/#dt-fatal">fatal
192 error</a> / <abbr>XML</abbr> 1.1
193 <cite class="bibref normative">[<a href="#ref-XML11">XML11</a>]</cite>
194 <a href="@@/#dt-fatal">fatal error</a>)
195 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>
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>
205 <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>
207 <dd><p>If an <code>xml-well-formedness-error</code> is raised,
208 it would not be possible to generate an XML serialization that
209 would match to the appropriate production rule and that would not
210 violate to any well$B!>(Bformedness constraint in XML
211 specification <cite class="bibref normative">[<a href="#ref-XML10">XML10</a>,
212 <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>
219
220 <div class=ed><p>@@ TODO: #dt-atuseroption at user option
221 (MAY or MUST), #dt-compat for compatibility,
222 #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>