Debian Codegraph @

test/grammar/xml-names.html

raw
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="EN">
4 <head>
5 <title>Namespaces in XML 1.0 (Third Edition)</title>
6 <style type="text/css">
7 code {
8 font-family: monospace;
9 }
10
11 div.constraint,
12 div.issue,
13 div.note,
14 div.notice {
15 margin-left: 2em;
16 }
17
18 ol.enumar {
19 list-style-type: decimal;
20 }
21 ol.enumla {
22 list-style-type: lower-alpha;
23 }
24 ol.enumlr {
25 list-style-type: lower-roman;
26 }
27 ol.enumua {
28 list-style-type: upper-alpha;
29 }
30 ol.enumur {
31 list-style-type: upper-roman;
32 }
33
34 div.exampleInner pre {
35 margin-left: 1em;
36 margin-top: 0em;
37 margin-bottom: 0em;
38 }
39 div.exampleOuter {
40 border: 4px double gray;
41 margin: 0em;
42 padding: 0em;
43 }
44 div.exampleInner {
45 background-color: #d5dee3;
46 border-top-width: 4px;
47 border-top-style: double;
48 border-top-color: #d3d3d3;
49 border-bottom-width: 4px;
50 border-bottom-style: double;
51 border-bottom-color: #d3d3d3;
52 padding: 4px;
53 margin: 0em;
54 }
55 div.exampleWrapper {
56 margin: 4px;
57 }
58 div.exampleHeader {
59 font-weight: bold;
60 margin: 4px;
61 }
62 </style>
63 <link
64 type="text/css"
65 rel="stylesheet"
66 href="http://www.w3.org/StyleSheets/TR/W3C-REC.css"
67 />
68 </head>
69 <body>
70 <div class="head">
71 <p>
72 <a href="http://www.w3.org/"
73 ><img
74 width="72"
75 height="48"
76 alt="W3C"
77 src="http://www.w3.org/Icons/w3c_home"
78 /></a>
79 </p>
80 <h1>
81 <a id="title" name="title" />Namespaces in XML 1.0 (Third Edition)
82 </h1>
83 <h2>
84 <a id="w3c-doctype" name="w3c-doctype" />W3C Recommendation 8 December
85 2009
86 </h2>
87 <dl>
88 <dt>This version:</dt>
89 <dd>
90 <a href="http://www.w3.org/TR/2009/REC-xml-names-20091208/">
91 http://www.w3.org/TR/2009/REC-xml-names-20091208/</a
92 >
93 </dd>
94 <dt>Latest version:</dt>
95 <dd>
96 <a href="http://www.w3.org/TR/xml-names/">
97 http://www.w3.org/TR/xml-names/</a
98 >
99 </dd>
100 <dt>Previous versions:</dt>
101 <dd>
102 <a href="http://www.w3.org/TR/2006/REC-xml-names-20060816/">
103 http://www.w3.org/TR/2006/REC-xml-names-20060816/</a
104 >
105 <a href="http://www.w3.org/TR/2009/PER-xml-names-20090806/"
106 >http://www.w3.org/TR/2009/PER-xml-names-20090806/</a
107 >
108 </dd>
109 <dt>Editors:</dt>
110 <dd>
111 Tim Bray, Textuality
112 <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
113 </dd>
114 <dd>
115 Dave Hollander, Contivo, Inc.
116 <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
117 </dd>
118 <dd>
119 Andrew Layman, Microsoft
120 <a href="mailto:[email protected]"
121 >&lt;[email protected]&gt;</a
122 >
123 </dd>
124 <dd>
125 Richard Tobin, University of Edinburgh and Markup Technology Ltd
126 <a href="mailto:[email protected]">&lt;[email protected]&gt;</a>
127 </dd>
128 <dd>
129 Henry S. Thompson, University of Edinburgh and W3C
130 <a href="mailto:[email protected]">&lt;[email protected]&gt;</a> - Third Edition
131 </dd>
132 </dl>
133 <p>
134 Please refer to the
135 <a href="http://www.w3.org/XML/2009/xml-names-errata"
136 ><strong>errata</strong></a
137 >
138 for this document, which may include normative corrections.
139 </p>
140 <p>
141 See also
142 <a
143 href="http://www.w3.org/2003/03/Translations/byTechnology?technology=xml-names"
144 ><strong>translations</strong></a
145 >.
146 </p>
147 <p>
148 This document is also available in these non-normative formats:
149 <a
150 href="http://www.w3.org/TR/2009/REC-xml-names-20091208/xml-names-10-3e.xml"
151 >XML</a
152 >
153 and&nbsp;<a
154 href="http://www.w3.org/TR/2009/REC-xml-names-20091208/xml-names-10-3e-diff.html"
155 >HTML highlighting differences from the second edition</a
156 >.
157 </p>
158 <p class="copyright">
159 <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"
160 >Copyright</a
161 >&nbsp;©&nbsp;2009&nbsp;<a href="http://www.w3.org/"
162 ><acronym title="World Wide Web Consortium">W3C</acronym></a
163 ><sup>®</sup> (<a href="http://www.csail.mit.edu/"
164 ><acronym title="Massachusetts Institute of Technology"
165 >MIT</acronym
166 ></a
167 >,
168 <a href="http://www.ercim.org/"
169 ><acronym
170 title="European Research Consortium for Informatics and Mathematics"
171 >ERCIM</acronym
172 ></a
173 >, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C
174 <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer"
175 >liability</a
176 >,
177 <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks"
178 >trademark</a
179 >
180 and
181 <a href="http://www.w3.org/Consortium/Legal/copyright-documents"
182 >document use</a
183 >
184 rules apply.
185 </p>
186 </div>
187 <hr />
188 <div>
189 <h2><a id="abstract" name="abstract" />Abstract</h2>
190 <p>
191 XML namespaces provide a simple method for qualifying element and
192 attribute names used in Extensible Markup Language documents by
193 associating them with namespaces identified by URI references.
194 </p>
195 </div>
196 <div>
197 <h2><a id="status" name="status" />Status of this Document</h2>
198 <p>
199 <em>
200 This section describes the status of this document at the time of its
201 publication. Other documents may supersede this document. A list of
202 current W3C publications and the latest revision of this technical
203 report can be found in the
204 <a href="http://www.w3.org/TR/">W3C technical reports index</a>
205 at http://www.w3.org/TR/.
206 </em>
207 </p>
208 <p>
209 This document is a product of the
210 <a href="http://www.w3.org/XML/Core/">XML Core Working Group</a>
211 as part of the
212 <a href="http://www.w3.org/XML/Activity.html">W3C XML Activity</a>. The
213 English version of this specification is the only normative version.
214 However, for translations of this document, see
215 <a
216 href="http://www.w3.org/2003/03/Translations/byTechnology?technology=xml-names"
217 >
218 http://www.w3.org/2003/03/Translations/byTechnology?technology=xml-names </a
219 >.
220 </p>
221 <p>
222 Known implementations are documented in the
223 <a href="http://www.w3.org/XML/2002/12/xml-names11-implementation.html">
224 Namespaces 1.1 implementation report</a
225 ><span>
226 (all known Namespaces 1.1 implementations also support Namespaces 1.0) </span
227 >. A test suite is also available via the
228 <a href="http://www.w3.org/XML/Test/">XML Test Suite</a>
229 page.
230 </p>
231 <p>
232 This third edition incorporates all known errata as of the publication
233 date. It supersedes the previous
234 <a href="http://www.w3.org/TR/2006/REC-xml-names-20060816/">
235 edition of 16 August 2006</a
236 >.
237 </p>
238 <p>
239 This edition has been widely reviewed. Only minor editorial changes have
240 been made since the 6 August 2009 Proposed Edited Recommendation.
241 </p>
242 <p>
243 Please report errors in this document to
244 <a href="mailto:[email protected]">[email protected]</a>;
245 public
246 <a href="http://lists.w3.org/Archives/Public/xml-names-editor/"
247 >archives</a
248 >
249 are available. The errata list for this document is available at
250 <a href="http://www.w3.org/XML/2009/xml-names-errata">
251 http://www.w3.org/XML/2009/xml-names-errata </a
252 >.
253 </p>
254 <p>
255 This document has been reviewed by W3C Members, by software developers,
256 and by other W3C groups and interested parties, and is endorsed by the
257 Director as a W3C Recommendation. It is a stable document and may be
258 used as reference material or cited from another document. W3C's role in
259 making the Recommendation is to draw attention to the specification and
260 to promote its widespread deployment. This enhances the functionality
261 and interoperability of the Web.
262 </p>
263 <p>
264 W3C maintains a
265 <a
266 rel="disclosure"
267 href="http://www.w3.org/2002/08/xmlcore-IPR-statements"
268 >public list of any patent disclosures</a
269 >
270 made in connection with the deliverables of the group; that page also
271 includes instructions for disclosing a patent. An individual who has
272 actual knowledge of a patent which the individual believes contains
273 <a
274 href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential"
275 >Essential Claim(s)</a
276 >
277 must disclose the information in accordance with
278 <a
279 href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure"
280 >section 6 of the W3C Patent Policy</a
281 >.
282 </p>
283 </div>
284 <div class="toc">
285 <h2><a id="contents" name="contents" />Table of Contents</h2>
286 <p class="toc">
287 1 <a href="#sec-intro">Motivation and Summary</a><br />
288 &nbsp;&nbsp;&nbsp;&nbsp;1.1
289 <a href="#notation">A Note on Notation and Usage</a><br />
290 2 <a href="#sec-namespaces">XML Namespaces</a><br />
291 &nbsp;&nbsp;&nbsp;&nbsp;2.1 <a href="#concepts">Basic Concepts</a><br />
292 &nbsp;&nbsp;&nbsp;&nbsp;2.2
293 <a href="#iri-use">Use of URIs as Namespace Names</a><br />
294 &nbsp;&nbsp;&nbsp;&nbsp;2.3
295 <a href="#NSNameComparison">Comparing URI References</a><br />
296 3 <a href="#ns-decl">Declaring Namespaces</a><br />
297 4 <a href="#ns-qualnames">Qualified Names</a><br />
298 5 <a href="#ns-using">Using Qualified Names</a><br />
299 6
300 <a href="#scoping-defaulting"
301 >Applying Namespaces to Elements and Attributes</a
302 ><br />
303 &nbsp;&nbsp;&nbsp;&nbsp;6.1 <a href="#scoping">Namespace Scoping</a
304 ><br />
305 &nbsp;&nbsp;&nbsp;&nbsp;6.2
306 <a href="#defaulting">Namespace Defaulting</a><br />
307 &nbsp;&nbsp;&nbsp;&nbsp;6.3
308 <a href="#uniqAttrs">Uniqueness of Attributes</a><br />
309 7 <a href="#Conformance">Conformance of Documents</a><br />
310 8 <a href="#ProcessorConformance">Conformance of Processors</a><br />
311 </p>
312 <h3><a id="appendices" name="appendices" />Appendices</h3>
313 <p class="toc">
314 A <a href="#refs">Normative References</a><br />
315 B <a href="#nrefs">Other references</a> (Non-Normative)<br />
316 C
317 <a href="#Philosophy">The Internal Structure of XML Namespaces</a>
318 (Non-Normative)<br />
319 D <a href="#changes">Changes since version 1.0</a> (Non-Normative)<br />
320 E <a href="#sec-xml-and-sgml">Acknowledgements</a> (Non-Normative)<br />
321 F <a href="#orphans">Orphaned Productions</a> (Non-Normative)<br />
322 </p>
323 </div>
324 <hr />
325 <div class="body">
326 <div class="div1">
327 <h2><a id="sec-intro" name="sec-intro" />1 Motivation and Summary</h2>
328 <p>
329 We envision applications of Extensible Markup Language (XML) where a
330 single XML document may contain elements and attributes (here referred
331 to as a "markup vocabulary") that are defined for and used by multiple
332 software modules. One motivation for this is modularity: if such a
333 markup vocabulary exists which is well-understood and for which there
334 is useful software available, it is better to re-use this markup
335 rather than re-invent it.
336 </p>
337 <p>
338 Such documents, containing multiple markup vocabularies, pose problems
339 of recognition and collision. Software modules need to be able to
340 recognize the elements and attributes which they are designed to
341 process, even in the face of "collisions" occurring when markup
342 intended for some other software package uses the same element
343 <span>name</span>
344 or attribute name.
345 </p>
346 <p>
347 These considerations require that document constructs should have
348 names constructed so as to avoid clashes between names from different
349 markup vocabularies. This specification describes a mechanism,
350 <em>XML namespaces</em>, which accomplishes this by assigning
351 <a title="Expanded Name" href="#dt-expname">expanded names</a>
352 to elements and attributes.
353 </p>
354 <div class="div2">
355 <h3>
356 <a id="notation" name="notation" />1.1 A Note on Notation and Usage
357 </h3>
358 <p>
359 Where <em class="RFC2119">EMPHASIZED</em>, the key words
360 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>,
361 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
362 >MUST NOT</em
363 >,
364 <em class="RFC2119" title="REQUIRED in RFC 2119 context"
365 >REQUIRED</em
366 >,
367 <em class="RFC2119" title="SHOULD in RFC 2119 context">SHOULD</em>,
368 <em class="RFC2119" title="SHOULD NOT in RFC 2119 context"
369 >SHOULD NOT</em
370 >,
371 <em class="RFC2119" title="MAY in RFC 2119 context">MAY</em>
372 in this document are to be interpreted as described in
373 <a href="#keywords">[Keywords]</a>.
374 </p>
375 <p>
376 Note that many of the nonterminals in the productions in this
377 specification are defined not here but in the XML specification
378 <a href="#XML">[XML]</a>. When nonterminals defined here have the
379 same names as nonterminals defined in the XML specification, the
380 productions here in all cases match a subset of the strings matched
381 by the corresponding ones there.
382 </p>
383 <p>
384 In this document's productions, the <code>NSC</code> is a "Namespace
385 Constraint", one of the rules that documents conforming to this
386 specification
387 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
388 follow.
389 </p>
390 </div>
391 </div>
392 <div class="div1">
393 <h2><a id="sec-namespaces" name="sec-namespaces" />2 XML Namespaces</h2>
394 <div class="div2">
395 <h3><a id="concepts" name="concepts" />2.1 Basic Concepts</h3>
396 <p>
397 [<a title="Namespace" id="dt-namespace" name="dt-namespace"
398 >Definition</a
399 >: An <b>XML namespace</b> is identified by a URI reference
400 <a href="#URIRef">[RFC3986]</a>; element and attribute names may be
401 placed in an XML namespace using the mechanisms described in this
402 specification. ]
403 </p>
404 <p>
405 [<a title="Expanded Name" id="dt-expname" name="dt-expname"
406 >Definition</a
407 >: An <b>expanded name</b>
408 is a pair consisting of a
409 <a title="Namespace Name" href="#dt-NSName">namespace name</a>
410 and a
411 <a title="Local Name" href="#dt-localname">local name</a>. ] [<a
412 title="Namespace Name"
413 id="dt-NSName"
414 name="dt-NSName"
415 >Definition</a
416 >: For a name <var>N</var> in a namespace identified by a URI
417 <var>I</var>, the
418 <b>namespace name</b>
419 is <var>I</var>. For a name <var>N</var> that is not in a namespace,
420 the
421 <b>namespace name</b>
422 has no value. ] [<a
423 title="Local Name"
424 id="dt-localname"
425 name="dt-localname"
426 >Definition</a
427 >: In either case the
428 <b>local name</b>
429 is <var>N</var>. ] It is this combination of the universally managed
430 URI namespace with the vocabulary's local names that is effective in
431 avoiding name clashes.
432 </p>
433 <p>
434 URI references can contain characters not allowed in names, and are
435 often inconveniently long, so expanded names are not used directly
436 to name elements and attributes in XML documents. Instead
437 <a title="Qualified Name" href="#dt-qualname">qualified names</a>
438 are used. [<a
439 title="Qualified Name"
440 id="dt-qualname"
441 name="dt-qualname"
442 >Definition</a
443 >: A
444 <b>qualified name</b>
445 is a name subject to namespace interpretation. ] In documents
446 conforming to this specification, element and attribute names appear
447 as qualified names. Syntactically, they are either
448 <a title="" href="#NT-PrefixedName">prefixed names</a> or
449 <a title="" href="#NT-UnprefixedName">unprefixed names</a>. An
450 attribute-based declaration syntax is provided to bind prefixes to
451 namespace names and to bind a default namespace that applies to
452 unprefixed element names; these declarations are scoped by the
453 elements on which they appear so that different bindings may apply
454 in different parts of a document. Processors conforming to this
455 specification
456 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
457 recognize and act on these declarations and prefixes.
458 </p>
459 </div>
460 <div class="div2">
461 <h3>
462 <a id="iri-use" name="iri-use" />2.2 Use of URIs as Namespace Names
463 </h3>
464 <p>
465 The empty string, though it is a legal URI reference, cannot be used
466 as a namespace name.
467 </p>
468 <p>
469 The use of relative URI references, including same-document
470 references, in namespace declarations is deprecated.
471 </p>
472 <div class="note">
473 <p class="prefix"><b>Note:</b></p>
474 <p>
475 This deprecation of relative URI references was decided on by a
476 W3C XML Plenary Ballot
477 <a href="#reluri">[Relative URI deprecation]</a>. It also declares
478 that "later specifications such as DOM, XPath, etc. will define no
479 interpretation for them".
480 </p>
481 </div>
482 </div>
483 <div class="div2">
484 <h3>
485 <a id="NSNameComparison" name="NSNameComparison" />2.3 Comparing URI
486 References
487 </h3>
488 <p>
489 URI references identifying namespaces are compared when determining
490 whether a name belongs to a given namespace, and whether two names
491 belong to the same namespace. [<a
492 title="Identical"
493 id="dt-identical"
494 name="dt-identical"
495 >Definition</a
496 >: The two URIs are treated as strings, and they are
497 <b>identical</b>
498 if and only if the strings are identical, that is, if they are the
499 same sequence of characters. ] The comparison is case-sensitive, and
500 no %-escaping is done or undone.
501 </p>
502 <p>
503 A consequence of this is that URI references which are not identical
504 in this sense may resolve to the same resource. Examples include URI
505 references which differ only in case or %-escaping, or which are in
506 external entities which have different base URIs (but note that
507 relative URIs are deprecated as namespace names).
508 </p>
509 <p>
510 In a namespace declaration, the URI reference is the
511 <a href="http://www.w3.org/TR/REC-xml/#AVNormalize"
512 >normalized value</a
513 >
514 of the attribute, so replacement of XML character and entity
515 references has already been done before any comparison.
516 </p>
517 <p>Examples:</p>
518 <p>
519 The URI references below are all different for the purposes of
520 identifying namespaces, since they differ in case:
521 </p>
522 <ul>
523 <li>
524 <p><code> http://www.example.org/wine </code></p>
525 </li>
526 <li>
527 <p><code> http://www.Example.org/wine </code></p>
528 </li>
529 <li>
530 <p><code> http://www.example.org/Wine </code></p>
531 </li>
532 </ul>
533 <p>
534 The URI references below are also all different for the purposes of
535 identifying namespaces:
536 </p>
537 <ul>
538 <li>
539 <p><code> http://www.example.org/~wilbur </code></p>
540 </li>
541 <li>
542 <p><code> http://www.example.org/%7ewilbur </code></p>
543 </li>
544 <li>
545 <p><code> http://www.example.org/%7Ewilbur </code></p>
546 </li>
547 </ul>
548 <p>
549 Because of the risk of confusion between URIs that would be
550 equivalent if dereferenced, the use of %-escaped characters in
551 namespace names is strongly discouraged.
552 </p>
553 </div>
554 </div>
555 <div class="div1">
556 <h2><a id="ns-decl" name="ns-decl" />3 Declaring Namespaces</h2>
557 <p>
558 [<a title="Namespace declaration" id="dt-NSDecl" name="dt-NSDecl"
559 >Definition</a
560 >: A namespace
561 <span>(or more precisely, a namespace binding)</span>
562 is
563 <b>declared</b> using a family of reserved attributes. Such an
564 attribute's name must either be <b>xmlns</b> or
565 <span>begin <b>xmlns:</b></span
566 >. These attributes, like any other XML attributes, may be provided
567 directly or by
568 <a href="http://www.w3.org/TR/REC-xml/#dt-default">default</a>. ]
569 </p>
570 <h5>
571 <a id="A785" name="A785" />Attribute Names for Namespace Declaration
572 </h5>
573 <table summary="Scrap" class="scrap">
574 <tbody>
575 <tr valign="baseline">
576 <td>
577 <a id="NT-NSAttName" name="NT-NSAttName" />[1]&nbsp;&nbsp;&nbsp;
578 </td>
579 <td><code>NSAttName</code></td>
580 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
581 <td>
582 <code><a href="#NT-PrefixedAttName">PrefixedAttName</a></code>
583 </td>
584 </tr>
585 <tr valign="baseline">
586 <td />
587 <td />
588 <td />
589 <td>
590 <code>| <a href="#NT-DefaultAttName">DefaultAttName</a></code>
591 </td>
592 </tr>
593 </tbody>
594 <tbody>
595 <tr valign="baseline">
596 <td>
597 <a
598 id="NT-PrefixedAttName"
599 name="NT-PrefixedAttName"
600 />[2]&nbsp;&nbsp;&nbsp;
601 </td>
602 <td><code>PrefixedAttName</code></td>
603 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
604 <td>
605 <code>'xmlns:' <a href="#NT-NCName">NCName</a></code>
606 </td>
607 <td>
608 <a href="#xmlReserved"
609 >[NSC: Reserved Prefixes and Namespace Names]</a
610 >
611 </td>
612 </tr>
613 </tbody>
614 <tbody>
615 <tr valign="baseline">
616 <td>
617 <a
618 id="NT-DefaultAttName"
619 name="NT-DefaultAttName"
620 />[3]&nbsp;&nbsp;&nbsp;
621 </td>
622 <td><code>DefaultAttName</code></td>
623 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
624 <td><code>'xmlns'</code></td>
625 </tr>
626 </tbody>
627 <tbody>
628 <tr valign="baseline">
629 <td>
630 <a id="NT-NCName" name="NT-NCName" />[4]&nbsp;&nbsp;&nbsp;
631 </td>
632 <td><code>NCName</code></td>
633 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
634 <td>
635 <code
636 ><a href="http://www.w3.org/TR/REC-xml/#NT-Name">Name</a> -
637 (<a href="http://www.w3.org/TR/REC-xml/#NT-Char">Char</a>* ':'
638 <a href="http://www.w3.org/TR/REC-xml/#NT-Char">Char</a
639 >*)</code
640 >
641 </td>
642 <td>
643 <i
644 >/* An XML
645 <a href="http://www.w3.org/TR/REC-xml/#NT-Name">Name</a>,
646 minus the ":" */</i
647 >
648 </td>
649 </tr>
650 </tbody>
651 </table>
652 <p>
653 <span>
654 The attribute's
655 <a href="http://www.w3.org/TR/REC-xml/#AVNormalize"
656 >normalized value</a
657 >
658 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
659 be either a URI reference — the
660 <a title="Namespace Name" href="#dt-NSName">namespace name</a>
661 identifying the namespace — or an empty string.
662 </span>
663 The namespace name, to serve its intended purpose,
664 <em class="RFC2119" title="SHOULD in RFC 2119 context">SHOULD</em>
665 have the characteristics of uniqueness and persistence. It is not a
666 goal that it be directly usable for retrieval of a schema (if any
667 exists). Uniform Resource Names <a href="#URNs">[RFC2141]</a> is an
668 example of a syntax that is designed with these goals in mind.
669 However, it should be noted that ordinary URLs can be managed in such
670 a way as to achieve these same goals.
671 </p>
672 <p>
673 [<a title="Namespace Prefix" id="dt-prefix" name="dt-prefix"
674 >Definition</a
675 >: If the attribute name matches
676 <a href="#NT-PrefixedAttName">PrefixedAttName</a>, then the
677 <a href="#NT-NCName">NCName</a> gives the <b>namespace prefix</b>,
678 used to associate element and attribute names with the
679 <a title="Namespace Name" href="#dt-NSName">namespace name</a> in the
680 attribute value in the scope of the element to which the declaration
681 is attached. ]
682 </p>
683 <p>
684 [<a title="Default Namespace" id="dt-defaultNS" name="dt-defaultNS"
685 >Definition</a
686 >: If the attribute name matches
687 <a href="#NT-DefaultAttName">DefaultAttName</a>, then the
688 <a title="Namespace Name" href="#dt-NSName">namespace name</a> in the
689 attribute value is that of the <b>default namespace</b>
690 in the scope of the element to which the declaration is attached.]
691 Default namespaces and overriding of declarations are discussed in
692 <a href="#scoping-defaulting"
693 ><b>6 Applying Namespaces to Elements and Attributes</b></a
694 >.
695 </p>
696 <p>
697 An example namespace declaration, which associates the namespace
698 prefix <b>edi</b> with the namespace name
699 <code>http://ecommerce.example.org/schema</code>:
700 </p>
701 <div class="exampleInner">
702 <pre>
703 &lt;x xmlns:edi='http://ecommerce.example.org/schema'&gt;
704 &lt;!-- the "edi" prefix is bound to http://ecommerce.example.org/schema
705 for the "x" element and contents --&gt;
706 &lt;/x&gt;</pre
707 >
708 </div>
709 <div class="constraint">
710 <p class="prefix">
711 <a id="xmlReserved" name="xmlReserved" /><b
712 >Namespace constraint: Reserved Prefixes and Namespace Names</b
713 >
714 </p>
715
716 <p>
717 The prefix <b>xml</b> is by definition bound to the namespace name
718 <code>http://www.w3.org/XML/1998/namespace</code>. It
719 <em class="RFC2119" title="MAY in RFC 2119 context">MAY</em>, but
720 need not, be declared, and
721 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
722 >MUST NOT</em
723 >
724 be bound to any other namespace name. Other prefixes
725 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
726 >MUST NOT</em
727 >
728 be bound to this namespace name, and it
729 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
730 >MUST NOT</em
731 >
732 be declared as the default namespace.
733 </p>
734
735 <p>
736 The prefix <b>xmlns</b> is used only to declare namespace bindings
737 and is by definition bound to the namespace name
738 <code>http://www.w3.org/2000/xmlns/</code>. It
739 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
740 >MUST NOT</em
741 >
742 be declared . Other prefixes
743 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
744 >MUST NOT</em
745 >
746 be bound to this namespace name, and it
747 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
748 >MUST NOT</em
749 >
750 be declared as the default namespace. Element names
751 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
752 >MUST NOT</em
753 >
754 have the prefix
755 <code>xmlns</code>.
756 </p>
757
758 <p>
759 All other prefixes beginning with the three-letter sequence x, m, l,
760 in any case combination, are reserved. This means that:
761 </p>
762
763 <ul>
764 <li>
765 <p>
766 users
767 <em class="RFC2119" title="SHOULD NOT in RFC 2119 context"
768 >SHOULD NOT</em
769 >
770 use them except as defined by later specifications
771 </p>
772 </li>
773 <li>
774 <p>
775 processors
776 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
777 >MUST NOT</em
778 >
779 treat them as fatal errors.
780 </p>
781 </li>
782 </ul>
783 </div>
784 <p>
785 Though they are not themselves reserved, it is inadvisable to use
786 prefixed names whose LocalPart begins with the letters x, m, l, in any
787 case combination, as these names would be reserved if used without a
788 prefix.
789 </p>
790 </div>
791 <div class="div1">
792 <h2><a id="ns-qualnames" name="ns-qualnames" />4 Qualified Names</h2>
793 <p>
794 In XML documents conforming to this specification, some names
795 (constructs corresponding to the nonterminal
796 <a href="http://www.w3.org/TR/REC-xml/#NT-Name">Name</a>)
797 <span>
798 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
799 be</span
800 >
801 given as
802 <a title="Qualified Name" href="#dt-qualname">qualified names</a>,
803 defined as follows:
804 </p>
805 <h5><a id="A1153" name="A1153" />Qualified Name</h5>
806 <table summary="Scrap" class="scrap">
807 <tbody>
808 <tr valign="baseline">
809 <td><a id="NT-QName" name="NT-QName" />[7]&nbsp;&nbsp;&nbsp;</td>
810 <td><code>QName</code></td>
811 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
812 <td>
813 <code><a href="#NT-PrefixedName">PrefixedName</a></code>
814 </td>
815 </tr>
816 <tr valign="baseline">
817 <td />
818 <td />
819 <td />
820 <td>
821 <code>| <a href="#NT-UnprefixedName">UnprefixedName</a></code>
822 </td>
823 </tr>
824 </tbody>
825 <tbody>
826 <tr valign="baseline">
827 <td>
828 <a
829 id="NT-PrefixedName"
830 name="NT-PrefixedName"
831 />[8]&nbsp;&nbsp;&nbsp;
832 </td>
833 <td><code>PrefixedName</code></td>
834 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
835 <td>
836 <code>
837 <a href="#NT-Prefix">Prefix</a> ':'
838 <a href="#NT-LocalPart">LocalPart</a>
839 </code>
840 </td>
841 </tr>
842 </tbody>
843 <tbody>
844 <tr valign="baseline">
845 <td>
846 <a
847 id="NT-UnprefixedName"
848 name="NT-UnprefixedName"
849 />[9]&nbsp;&nbsp;&nbsp;
850 </td>
851 <td><code>UnprefixedName</code></td>
852 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
853 <td>
854 <code>
855 <a href="#NT-LocalPart">LocalPart</a>
856 </code>
857 </td>
858 </tr>
859 </tbody>
860 <tbody>
861 <tr valign="baseline">
862 <td>
863 <a id="NT-Prefix" name="NT-Prefix" />[10]&nbsp;&nbsp;&nbsp;
864 </td>
865 <td><code>Prefix</code></td>
866 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
867 <td>
868 <code><a href="#NT-NCName">NCName</a></code>
869 </td>
870 </tr>
871 </tbody>
872 <tbody>
873 <tr valign="baseline">
874 <td>
875 <a
876 id="NT-LocalPart"
877 name="NT-LocalPart"
878 />[11]&nbsp;&nbsp;&nbsp;
879 </td>
880 <td><code>LocalPart</code></td>
881 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
882 <td>
883 <code><a href="#NT-NCName">NCName</a></code>
884 </td>
885 </tr>
886 </tbody>
887 </table>
888 <p>
889 The
890 <a href="#NT-Prefix">Prefix</a> provides the
891 <a title="Namespace Prefix" href="#dt-prefix">namespace prefix</a>
892 part of the qualified name, and
893 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
894 be associated with a namespace URI reference in a
895 <a title="Namespace declaration" href="#dt-NSDecl"
896 >namespace declaration</a
897 >. [<a title="Local Part" id="dt-localpart" name="dt-localpart"
898 >Definition</a
899 >: The <a href="#NT-LocalPart">LocalPart</a> provides the
900 <b>local part</b> of the qualified name.]
901 </p>
902 <p>
903 Note that the prefix functions <em>only</em> as a placeholder for a
904 namespace name. Applications
905 <em class="RFC2119" title="SHOULD in RFC 2119 context">SHOULD</em>
906 use the namespace name, not the prefix, in constructing names whose
907 scope extends beyond the containing document.
908 </p>
909 </div>
910 <div class="div1">
911 <h2><a id="ns-using" name="ns-using" />5 Using Qualified Names</h2>
912 <p>
913 In XML documents conforming to this specification, element
914 <span>names</span> are given as
915 <a title="Qualified Name" href="#dt-qualname">qualified names</a>, as
916 follows:
917 </p>
918 <h5><a id="A1329" name="A1329" />Element Names</h5>
919 <table summary="Scrap" class="scrap">
920 <tbody>
921 <tr valign="baseline">
922 <td><a id="NT-STag" name="NT-STag" />[12]&nbsp;&nbsp;&nbsp;</td>
923 <td><code>STag</code></td>
924 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
925 <td>
926 <code
927 >'&lt;' <a href="#NT-QName">QName</a> (<a
928 href="http://www.w3.org/TR/REC-xml/#NT-S"
929 >S</a
930 >
931 <a href="#NT-Attribute">Attribute</a>)*
932 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>? '&gt;'
933 </code>
934 </td>
935 <td><a href="#nsc-NSDeclared">[NSC: Prefix Declared]</a></td>
936 </tr>
937 </tbody>
938 <tbody>
939 <tr valign="baseline">
940 <td><a id="NT-ETag" name="NT-ETag" />[13]&nbsp;&nbsp;&nbsp;</td>
941 <td><code>ETag</code></td>
942 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
943 <td>
944 <code
945 >'&lt;/' <a href="#NT-QName">QName</a>
946 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
947 '&gt;'</code
948 >
949 </td>
950 <td><a href="#nsc-NSDeclared">[NSC: Prefix Declared]</a></td>
951 </tr>
952 </tbody>
953 <tbody>
954 <tr valign="baseline">
955 <td>
956 <a
957 id="NT-EmptyElemTag"
958 name="NT-EmptyElemTag"
959 />[14]&nbsp;&nbsp;&nbsp;
960 </td>
961 <td><code>EmptyElemTag</code></td>
962 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
963 <td>
964 <code
965 >'&lt;' <a href="#NT-QName">QName</a> (<a
966 href="http://www.w3.org/TR/REC-xml/#NT-S"
967 >S</a
968 >
969 <a href="#NT-Attribute">Attribute</a>)*
970 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
971 '/&gt;'</code
972 >
973 </td>
974 <td><a href="#nsc-NSDeclared">[NSC: Prefix Declared]</a></td>
975 </tr>
976 </tbody>
977 </table>
978 <p>An example of a qualified name serving as an element name:</p>
979 <div class="exampleInner">
980 <pre>
981 &lt;!-- the 'price' element's namespace is http://ecommerce.example.org/schema --&gt;
982 &lt;edi:price xmlns:edi='http://ecommerce.example.org/schema' units='Euro'&gt;32.18&lt;/edi:price&gt;
983 </pre
984 >
985 </div>
986 <p>
987 Attributes are either
988 <a title="Namespace declaration" href="#dt-NSDecl"
989 >namespace declarations</a
990 >
991 or their names are given as
992 <a title="Qualified Name" href="#dt-qualname">qualified names</a>:
993 </p>
994 <h5><a id="A1472" name="A1472" />Attribute</h5>
995 <table summary="Scrap" class="scrap">
996 <tbody>
997 <tr valign="baseline">
998 <td>
999 <a
1000 id="NT-Attribute"
1001 name="NT-Attribute"
1002 />[15]&nbsp;&nbsp;&nbsp;
1003 </td>
1004 <td><code>Attribute</code></td>
1005 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1006 <td>
1007 <code
1008 ><a href="#NT-NSAttName">NSAttName</a>
1009 <a href="http://www.w3.org/TR/REC-xml/#NT-Eq">Eq</a>
1010 <a href="http://www.w3.org/TR/REC-xml/#NT-AttValue"
1011 >AttValue</a
1012 ></code
1013 >
1014 </td>
1015 </tr>
1016 <tr valign="baseline">
1017 <td />
1018 <td />
1019 <td />
1020 <td>
1021 <code
1022 >| <a href="#NT-QName">QName</a>
1023 <a href="http://www.w3.org/TR/REC-xml/#NT-Eq">Eq</a>
1024 <a href="http://www.w3.org/TR/REC-xml/#NT-AttValue"
1025 >AttValue</a
1026 ></code
1027 >
1028 </td>
1029 <td><a href="#nsc-NSDeclared">[NSC: Prefix Declared]</a></td>
1030 </tr>
1031 <tr valign="baseline">
1032 <td />
1033 <td />
1034 <td />
1035 <td />
1036 <td>
1037 <a href="#nsc-NoPrefixUndecl">[NSC: No Prefix Undeclaring]</a>
1038 </td>
1039 </tr>
1040 <tr valign="baseline">
1041 <td />
1042 <td />
1043 <td />
1044 <td />
1045 <td><a href="#nsc-AttrsUnique">[NSC: Attributes Unique]</a></td>
1046 </tr>
1047 </tbody>
1048 </table>
1049 <p>An example of a qualified name serving as an attribute name:</p>
1050 <div class="exampleInner">
1051 <pre>
1052 &lt;x xmlns:edi='http://ecommerce.example.org/schema'&gt;
1053 &lt;!-- the 'taxClass' attribute's namespace is http://ecommerce.example.org/schema --&gt;
1054 &lt;lineItem edi:taxClass="exempt"&gt;Baby food&lt;/lineItem&gt;
1055 &lt;/x&gt;</pre
1056 >
1057 </div>
1058 <div class="constraint">
1059 <p class="prefix">
1060 <a id="nsc-NSDeclared" name="nsc-NSDeclared" /><b
1061 >Namespace constraint: Prefix Declared</b
1062 >
1063 </p>
1064 <p>
1065 The namespace prefix, unless it is <code>xml</code> or
1066 <code>xmlns</code>,
1067 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
1068 have been declared in a
1069 <a title="Namespace declaration" href="#dt-NSDecl"
1070 >namespace declaration</a
1071 >
1072 attribute in either the start-tag of the element where the prefix is
1073 used or in an ancestor element (i.e., an element in whose
1074 <a href="http://www.w3.org/TR/REC-xml/#dt-content">content</a> the
1075 prefixed markup occurs).
1076 </p>
1077 </div>
1078 <div class="constraint">
1079 <p class="prefix">
1080 <a id="nsc-NoPrefixUndecl" name="nsc-NoPrefixUndecl" /><b
1081 >Namespace constraint: No Prefix Undeclaring</b
1082 >
1083 </p>
1084 <p>
1085 In a
1086 <a title="Namespace declaration" href="#dt-NSDecl"
1087 >namespace declaration</a
1088 >
1089 for a <a title="" href="#NT-Prefix">prefix</a> (i.e., where the
1090 <a title="" href="#NT-NSAttName">NSAttName</a> is a
1091 <a title="" href="#NT-PrefixedAttName">PrefixedAttName</a>), the
1092 <a href="http://www.w3.org/TR/REC-xml/#NT-AttValue"
1093 >attribute value</a
1094 >
1095 <em class="RFC2119" title="MUST NOT in RFC 2119 context"
1096 >MUST NOT</em
1097 >
1098 be empty.
1099 </p>
1100 </div>
1101 <p>
1102 This constraint may lead to operational difficulties in the case where
1103 the namespace declaration attribute is provided, not directly in the
1104 XML
1105 <a href="http://www.w3.org/TR/REC-xml/#dt-docent">document entity</a>,
1106 but via a default attribute declared in an external entity. Such
1107 declarations may not be read by software which is based on a
1108 non-validating XML processor. Many XML applications, presumably
1109 including namespace-sensitive ones, fail to require validating
1110 processors.
1111 <span>If correct operation with such applications is required</span>,
1112 namespace declarations
1113 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
1114 be provided either directly or via default attributes declared in the
1115 <a href="http://www.w3.org/TR/REC-xml/#dt-doctype"
1116 >internal subset of the DTD</a
1117 >.
1118 </p>
1119 <p>
1120 Element names and attribute <span>names</span> are also given as
1121 qualified names when they appear in declarations in the
1122 <a href="http://www.w3.org/TR/REC-xml/#dt-doctype">DTD</a>:
1123 </p>
1124 <h5><a id="A1686" name="A1686" />Qualified Names in Declarations</h5>
1125 <table summary="Scrap" class="scrap">
1126 <tbody>
1127 <tr valign="baseline">
1128 <td>
1129 <a
1130 id="NT-doctypedecl"
1131 name="NT-doctypedecl"
1132 />[16]&nbsp;&nbsp;&nbsp;
1133 </td>
1134 <td><code>doctypedecl</code></td>
1135 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1136 <td>
1137 <code
1138 >'&lt;!DOCTYPE'
1139 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>
1140 <a href="#NT-QName">QName</a> (<a
1141 href="http://www.w3.org/TR/REC-xml/#NT-S"
1142 >S</a
1143 >
1144 <a href="http://www.w3.org/TR/REC-xml/#NT-ExternalID"
1145 >ExternalID</a
1146 >)? <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>? ('['
1147 (<a href="http://www.w3.org/TR/REC-xml/#NT-markupdecl"
1148 >markupdecl</a
1149 >
1150 |
1151 <a href="http://www.w3.org/TR/REC-xml/#NT-PEReference"
1152 >PEReference</a
1153 >
1154 | <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>)* ']'
1155 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?)?
1156 '&gt;'</code
1157 >
1158 </td>
1159 </tr>
1160 </tbody>
1161 <tbody>
1162 <tr valign="baseline">
1163 <td>
1164 <a
1165 id="NT-elementdecl"
1166 name="NT-elementdecl"
1167 />[17]&nbsp;&nbsp;&nbsp;
1168 </td>
1169 <td><code>elementdecl</code></td>
1170 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1171 <td>
1172 <code
1173 >'&lt;!ELEMENT'
1174 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>
1175 <a href="#NT-QName">QName</a>
1176 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>
1177 <a href="http://www.w3.org/TR/REC-xml/#NT-contentspec"
1178 >contentspec</a
1179 >
1180 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
1181 '&gt;'</code
1182 >
1183 </td>
1184 </tr>
1185 </tbody>
1186 <tbody>
1187 <tr valign="baseline">
1188 <td><a id="NT-cp" name="NT-cp" />[18]&nbsp;&nbsp;&nbsp;</td>
1189 <td><code>cp</code></td>
1190 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1191 <td>
1192 <code
1193 >(<a href="#NT-QName">QName</a> |
1194 <a href="http://www.w3.org/TR/REC-xml/#NT-choice">choice</a> |
1195 <a href="http://www.w3.org/TR/REC-xml/#NT-seq">seq</a>) ('?' |
1196 '*' | '+')?</code
1197 >
1198 </td>
1199 </tr>
1200 </tbody>
1201 <tbody>
1202 <tr valign="baseline">
1203 <td><a id="NT-Mixed" name="NT-Mixed" />[19]&nbsp;&nbsp;&nbsp;</td>
1204 <td><code>Mixed</code></td>
1205 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1206 <td>
1207 <code
1208 >'(' <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
1209 '#PCDATA' (<a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
1210 '|' <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
1211 <a href="#NT-QName">QName</a>)*
1212 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>? ')*'
1213 </code>
1214 </td>
1215 </tr>
1216 <tr valign="baseline">
1217 <td />
1218 <td />
1219 <td />
1220 <td>
1221 <code
1222 >| '(' <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
1223 '#PCDATA' <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
1224 ')'
1225 </code>
1226 </td>
1227 </tr>
1228 </tbody>
1229 <tbody>
1230 <tr valign="baseline">
1231 <td>
1232 <a
1233 id="NT-AttlistDecl"
1234 name="NT-AttlistDecl"
1235 />[20]&nbsp;&nbsp;&nbsp;
1236 </td>
1237 <td><code>AttlistDecl</code></td>
1238 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1239 <td>
1240 <code
1241 >'&lt;!ATTLIST'
1242 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>
1243 <a href="#NT-QName">QName</a>
1244 <a href="#NT-AttDef">AttDef</a>*
1245 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>?
1246 '&gt;'</code
1247 >
1248 </td>
1249 </tr>
1250 </tbody>
1251 <tbody>
1252 <tr valign="baseline">
1253 <td>
1254 <a id="NT-AttDef" name="NT-AttDef" />[21]&nbsp;&nbsp;&nbsp;
1255 </td>
1256 <td><code>AttDef</code></td>
1257 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1258 <td>
1259 <code
1260 ><a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a> (<a
1261 href="#NT-QName"
1262 >QName</a
1263 >
1264 | <a href="#NT-NSAttName">NSAttName</a>)
1265 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>
1266 <a href="http://www.w3.org/TR/REC-xml/#NT-AttType">AttType</a>
1267 <a href="http://www.w3.org/TR/REC-xml/#NT-S">S</a>
1268 <a href="http://www.w3.org/TR/REC-xml/#NT-DefaultDecl"
1269 >DefaultDecl</a
1270 ></code
1271 >
1272 </td>
1273 </tr>
1274 </tbody>
1275 </table>
1276 <p>
1277 Note that DTD-based validation is not namespace-aware in the following
1278 sense: a DTD constrains the elements and attributes that may appear in
1279 a document by their uninterpreted names, not by (namespace name, local
1280 name) pairs. To validate a document that uses namespaces against a
1281 DTD, the same prefixes must be used in the DTD as in the instance. A
1282 DTD may however indirectly constrain the namespaces used in a valid
1283 document by providing <code>#FIXED</code> values for attributes that
1284 declare namespaces.
1285 </p>
1286 </div>
1287 <div class="div1">
1288 <h2>
1289 <a id="scoping-defaulting" name="scoping-defaulting" />6 Applying
1290 Namespaces to Elements and Attributes
1291 </h2>
1292 <div class="div2">
1293 <h3><a id="scoping" name="scoping" />6.1 Namespace Scoping</h3>
1294 <p>
1295 The scope of a namespace declaration declaring a prefix extends from
1296 the beginning of the start-tag in which it appears to the end of the
1297 corresponding end-tag, excluding the scope of any inner declarations
1298 with the same NSAttName part. In the case of an empty tag, the scope
1299 is the tag itself.
1300 </p>
1301 <p>
1302 Such a namespace declaration applies to all element and attribute
1303 names within its scope whose prefix matches that specified in the
1304 declaration.
1305 </p>
1306 <p>
1307 The
1308 <a title="Expanded Name" href="#dt-expname">expanded name</a>
1309 corresponding to a prefixed element or attribute name has the URI to
1310 which the
1311 <a title="" href="#NT-Prefix">prefix</a>
1312 is bound as its
1313 <a title="Namespace Name" href="#dt-NSName">namespace name</a>, and
1314 the
1315 <a title="" href="#NT-LocalPart">local part</a>
1316 as its
1317 <a title="Local Name" href="#dt-localname">local name</a>.
1318 </p>
1319 <div class="exampleInner">
1320 <pre>
1321 &lt;?xml version="1.0"?&gt;
1322
1323 &lt;html:html xmlns:html='<span>http://www.w3.org/1999/xhtml</span>'&gt;
1324
1325 &lt;html:head&gt;&lt;html:title&gt;Frobnostication&lt;/html:title&gt;&lt;/html:head&gt;
1326 &lt;html:body&gt;&lt;html:p&gt;Moved to
1327 &lt;html:a href='http://frob.example.com'&gt;here.&lt;/html:a&gt;&lt;/html:p&gt;&lt;/html:body&gt;
1328 &lt;/html:html&gt;</pre
1329 >
1330 </div>
1331 <p>
1332 Multiple namespace prefixes can be declared as attributes of a
1333 single element, as shown in this example:
1334 </p>
1335 <div class="exampleInner">
1336 <pre>
1337 &lt;?xml version="1.0"?&gt;
1338 &lt;!-- both namespace prefixes are available throughout --&gt;
1339 &lt;bk:book xmlns:bk='urn:loc.gov:books'
1340 xmlns:isbn='urn:ISBN:0-395-36341-6'&gt;
1341 &lt;bk:title&gt;Cheaper by the Dozen&lt;/bk:title&gt;
1342 &lt;isbn:number&gt;1568491379&lt;/isbn:number&gt;
1343 &lt;/bk:book&gt;</pre
1344 >
1345 </div>
1346 </div>
1347 <div class="div2">
1348 <h3>
1349 <a id="defaulting" name="defaulting" />6.2 Namespace Defaulting
1350 </h3>
1351 <p>
1352 The scope of a
1353 <a title="Default Namespace" href="#dt-defaultNS"
1354 >default namespace</a
1355 >
1356 declaration extends from the beginning of the start-tag in which it
1357 appears to the end of the corresponding end-tag, excluding the scope
1358 of any inner default namespace declarations. In the case of an empty
1359 tag, the scope is the tag itself.
1360 </p>
1361 <p>
1362 A default namespace declaration applies to all unprefixed element
1363 names within its scope. Default namespace declarations do not apply
1364 directly to attribute names; the interpretation of unprefixed
1365 attributes is determined by the element on which they appear.
1366 </p>
1367 <p>
1368 If there is a default namespace declaration in scope, the
1369 <a title="Expanded Name" href="#dt-expname">expanded name</a>
1370 corresponding to an unprefixed element name has the URI of the
1371 <a title="Default Namespace" href="#dt-defaultNS"
1372 >default namespace</a
1373 >
1374 as its
1375 <a title="Namespace Name" href="#dt-NSName">namespace name</a>. If
1376 there is no default namespace declaration in scope, the namespace
1377 name has no value. The namespace name for an unprefixed attribute
1378 name always has no value. In all cases, the
1379 <a title="Local Name" href="#dt-localname">local name</a> is
1380 <a title="" href="#NT-LocalPart">local part</a>
1381 (which is of course the same as the unprefixed name itself).
1382 </p>
1383 <div class="exampleInner">
1384 <pre>
1385 &lt;?xml version="1.0"?&gt;
1386 &lt;!-- elements are in the HTML namespace, in this case by default --&gt;
1387 &lt;html xmlns='<span>http://www.w3.org/1999/xhtml</span>'&gt;
1388 &lt;head&gt;&lt;title&gt;Frobnostication&lt;/title&gt;&lt;/head&gt;
1389 &lt;body&gt;&lt;p&gt;Moved to
1390 &lt;a href='http://frob.example.com'&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/body&gt;
1391 &lt;/html&gt;</pre
1392 >
1393 </div>
1394 <div class="exampleInner">
1395 <pre>
1396 &lt;?xml version="1.0"?&gt;
1397 &lt;!-- unprefixed element types are from "books" --&gt;
1398 &lt;book xmlns='urn:loc.gov:books'
1399 xmlns:isbn='urn:ISBN:0-395-36341-6'&gt;
1400 &lt;title&gt;Cheaper by the Dozen&lt;/title&gt;
1401 &lt;isbn:number&gt;1568491379&lt;/isbn:number&gt;
1402 &lt;/book&gt;</pre
1403 >
1404 </div>
1405 <p>A larger example of namespace scoping:</p>
1406 <div class="exampleInner">
1407 <pre>
1408 &lt;?xml version="1.0"?&gt;
1409 &lt;!-- initially, the default namespace is "books" --&gt;
1410 &lt;book xmlns='urn:loc.gov:books'
1411 xmlns:isbn='urn:ISBN:0-395-36341-6'&gt;
1412 &lt;title&gt;Cheaper by the Dozen&lt;/title&gt;
1413 &lt;isbn:number&gt;1568491379&lt;/isbn:number&gt;
1414 &lt;notes&gt;
1415 &lt;!-- make HTML the default namespace for some commentary --&gt;
1416 &lt;p xmlns='<span>http://www.w3.org/1999/xhtml</span>'&gt;
1417 This is a &lt;i&gt;funny&lt;/i&gt; book!
1418 &lt;/p&gt;
1419 &lt;/notes&gt;
1420 &lt;/book&gt;</pre
1421 >
1422 </div>
1423 <p>
1424 The attribute value in a default namespace declaration
1425 <em class="RFC2119" title="MAY in RFC 2119 context">MAY</em>
1426 be empty. This has the same effect, within the scope of the
1427 declaration, of there being no default namespace.
1428 </p>
1429 <div class="exampleInner">
1430 <pre>&lt;?xml version='1.0'?&gt;
1431 &lt;Beers&gt;
1432 &lt;!-- <span>the default namespace inside tables is that of HTML</span> --&gt;
1433 &lt;table xmlns='<span>http://www.w3.org/1999/xhtml</span>'&gt;
1434 &lt;th&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;Origin&lt;/td&gt;&lt;td&gt;Description&lt;/td&gt;&lt;/th&gt;
1435 &lt;tr&gt;
1436 &lt;!-- no default namespace inside table cells --&gt;
1437 &lt;td&gt;&lt;brandName xmlns=""&gt;Huntsman&lt;/brandName&gt;&lt;/td&gt;
1438 &lt;td&gt;&lt;origin xmlns=""&gt;Bath, UK&lt;/origin&gt;&lt;/td&gt;
1439 &lt;td&gt;
1440 &lt;details xmlns=""&gt;&lt;class&gt;Bitter&lt;/class&gt;&lt;hop&gt;Fuggles&lt;/hop&gt;
1441 &lt;pro&gt;Wonderful hop, light alcohol, good summer beer&lt;/pro&gt;
1442 &lt;con&gt;Fragile; excessive variance pub to pub&lt;/con&gt;
1443 &lt;/details&gt;
1444 &lt;/td&gt;
1445 &lt;/tr&gt;
1446 &lt;/table&gt;
1447 &lt;/Beers&gt;</pre>
1448 </div>
1449 </div>
1450 <div class="div2">
1451 <h3>
1452 <a id="uniqAttrs" name="uniqAttrs" />6.3 Uniqueness of Attributes
1453 </h3>
1454 <div class="constraint">
1455 <p class="prefix">
1456 <a id="nsc-AttrsUnique" name="nsc-AttrsUnique" /><b
1457 >Namespace constraint: Attributes Unique</b
1458 >
1459 </p>
1460 <p>
1461 In XML documents conforming to this specification, no tag may
1462 contain two attributes which:
1463 </p>
1464 <ol class="enumar">
1465 <li><p>have identical names, or</p></li>
1466 <li>
1467 <p>
1468 have qualified names with the same
1469 <a title="Local Part" href="#dt-localpart">local part</a> and
1470 with
1471 <a title="Namespace Prefix" href="#dt-prefix">prefixes</a>
1472 which have been bound to
1473 <a title="Namespace Name" href="#dt-NSName"
1474 >namespace names</a
1475 >
1476 that are
1477 <a title="Identical" href="#dt-identical">identical</a>.
1478 </p>
1479 </li>
1480 </ol>
1481 </div>
1482 <p>
1483 This constraint is equivalent to requiring that no element have two
1484 attributes with the same
1485 <a title="Expanded Name" href="#dt-expname">expanded name</a>.
1486 </p>
1487 <p>
1488 For example, each of the <code>bad</code> empty-element tags is
1489 illegal in the following:
1490 </p>
1491 <div class="exampleInner">
1492 <pre>
1493 &lt;!-- http://www.w3.org is bound to n1 and n2 --&gt;
1494 &lt;x xmlns:n1="http://www.w3.org"
1495 xmlns:n2="http://www.w3.org" &gt;
1496 &lt;bad a="1" a="2" /&gt;
1497 &lt;bad n1:a="1" n2:a="2" /&gt;
1498 &lt;/x&gt;</pre
1499 >
1500 </div>
1501 <p>
1502 However, each of the following is legal, the second because the
1503 default namespace does not apply to attribute names:
1504 </p>
1505 <div class="exampleInner">
1506 <pre>
1507 &lt;!-- http://www.w3.org is bound to n1 and is the default --&gt;
1508 &lt;x xmlns:n1="http://www.w3.org"
1509 xmlns="http://www.w3.org" &gt;
1510 &lt;good a="1" b="2" /&gt;
1511 &lt;good a="1" n1:a="2" /&gt;
1512 &lt;/x&gt;</pre
1513 >
1514 </div>
1515 </div>
1516 </div>
1517 <div class="div1">
1518 <h2>
1519 <a id="Conformance" name="Conformance" />7 Conformance of Documents
1520 </h2>
1521 <p>
1522 This specification applies to XML 1.0 documents. To conform to this
1523 specification, a document
1524 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
1525 be well-formed according to the XML 1.0 specification
1526 <a href="#XML">[XML]</a>.
1527 </p>
1528 <p>
1529 In XML documents which conform to this specification, element and
1530 attribute names
1531 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
1532 match the production for
1533 <a href="#NT-QName">QName</a>
1534 and
1535 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
1536 satisfy the "Namespace Constraints". All other tokens in the document
1537 which are
1538 <em class="RFC2119" title="REQUIRED in RFC 2119 context">REQUIRED</em
1539 >, for XML 1.0 well-formedness, to match the XML production for
1540 <a href="http://www.w3.org/TR/REC-xml/#NT-Name">Name</a>
1541
1542 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
1543 match this specification's production for
1544 <a href="#NT-NCName">NCName</a>.
1545 </p>
1546 <p>
1547 [<a title="namespace well-formedness" id="dt-nwf" name="dt-nwf"
1548 >Definition</a
1549 >: A document is <b>namespace-well-formed</b>
1550 if it conforms to this specification. ]
1551 </p>
1552 <p>It follows that in a namespace-well-formed document:</p>
1553 <ul>
1554 <li>
1555 <p>
1556 All element and attribute names contain either zero or one colon;
1557 </p>
1558 </li>
1559 <li>
1560 <p>
1561 No entity names, processing instruction targets, or notation names
1562 contain any colons.
1563 </p>
1564 </li>
1565 </ul>
1566 <p>
1567 In addition, a namespace-well-formed document may also be
1568 namespace-valid.
1569 </p>
1570 <p>
1571 [<a title="namespace validity" id="dt-nv" name="dt-nv">Definition</a>:
1572 A namespace-well-formed document is <b>namespace-valid</b>
1573 if it is valid according to the XML 1.0 specification, and all tokens
1574 other than element and attribute names which are
1575 <em class="RFC2119" title="REQUIRED in RFC 2119 context">REQUIRED</em
1576 >, for XML 1.0 validity, to match the XML production for
1577 <a href="http://www.w3.org/TR/REC-xml/#NT-Name">Name</a>
1578 match this specification's production for
1579 <a href="#NT-NCName">NCName</a>. ]
1580 </p>
1581 <p>It follows that in a namespace-valid document:</p>
1582 <ul>
1583 <li>
1584 <p>
1585 No attributes with a declared type of
1586 <b>ID</b>, <b>IDREF(S)</b>, <b>ENTITY(IES)</b>, or <b>NOTATION</b>
1587 contain any colons.
1588 </p>
1589 </li>
1590 </ul>
1591 </div>
1592 <div class="div1">
1593 <h2>
1594 <a id="ProcessorConformance" name="ProcessorConformance" />8
1595 Conformance of Processors
1596 </h2>
1597 <p>
1598 To conform to this specification, a processor
1599 <em class="RFC2119" title="MUST in RFC 2119 context">MUST</em>
1600 report violations of namespace well-formedness, with the exception
1601 that it is not
1602 <em class="RFC2119" title="REQUIRED in RFC 2119 context">REQUIRED</em>
1603 to check that namespace names are URI references
1604 <a href="#URIRef">[RFC3986]</a>.
1605 </p>
1606 <p>
1607 [<a title="namespace-validating" id="dt-nvp" name="dt-nvp"
1608 >Definition</a
1609 >: A validating XML processor that conforms to this specification is
1610 <b>namespace-validating</b> if in addition it reports violations of
1611 namespace validity. ]
1612 </p>
1613 </div>
1614 </div>
1615 <div class="back">
1616 <div class="div1">
1617 <h2><a id="refs" name="refs" />A Normative References</h2>
1618 <dl>
1619 <dt class="label"><a id="keywords" name="keywords" />Keywords</dt>
1620 <dd>
1621 <a href="http://www.rfc-editor.org/rfc/rfc2119.txt"
1622 ><cite
1623 >RFC 2119: Key words for use in RFCs to Indicate Requirement
1624 Levels</cite
1625 ></a
1626 >, S. Bradner, ed. IETF (Internet Engineering Task Force), March
1627 1997. Available at http://www.rfc-editor.org/rfc/rfc2119.txt
1628 </dd>
1629 <dt class="label"><a id="URNs" name="URNs" />RFC2141</dt>
1630 <dd>
1631 <a href="http://www.rfc-editor.org/rfc/rfc2141.txt"
1632 ><cite>RFC 2141: URN Syntax</cite></a
1633 >, R. Moats, ed. IETF (Internet Engineering Task Force), May 1997.
1634 <span>
1635 Available at http://www.rfc-editor.org/rfc/rfc2141.txt.
1636 </span>
1637 </dd>
1638 <dt class="label"><a id="URIRef" name="URIRef" />RFC3986</dt>
1639 <dd>
1640 <a href="http://www.rfc-editor.org/rfc/rfc3986.txt"
1641 ><cite
1642 >RFC 3986: Uniform Resource Identifier (URI): Generic
1643 Syntax</cite
1644 ></a
1645 >, T. Berners-Lee, R. Fielding, and L. Masinter, eds. IETF (Internet
1646 Engineering Task Force), January 2005. Available at
1647 http://www.rfc-editor.org/rfc/rfc3986.txt
1648 </dd>
1649 <dt class="label"><a id="UTF8" name="UTF8" />RFC3629</dt>
1650 <dd>
1651 <a href="http://www.rfc-editor.org/rfc/rfc3629.txt"
1652 ><cite
1653 >RFC 3629: UTF-8, a transformation format of ISO 10646</cite
1654 ></a
1655 >, F. Yergeau, ed. IETF (Internet Engineering Task Force), November
1656 2003. Available at http://www.rfc-editor.org/rfc/rfc3629.txt
1657 </dd>
1658 <dt class="label"><a id="XML" name="XML" />XML</dt>
1659 <dd>
1660 <a href="http://www.w3.org/TR/REC-xml/"
1661 ><cite>Extensible Markup Language (XML) 1.0</cite></a
1662 >, Tim Bray, Jean Paoli, C. M. Sperberg-McQueen, Eve Maler, and
1663 François Yergeau eds. W3C (World Wide Web Consortium). Available at
1664 http://www.w3.org/TR/REC-xml/.
1665 </dd>
1666 </dl>
1667 </div>
1668 <div class="div1">
1669 <h2><a id="nrefs" name="nrefs" />B Other references (Non-Normative)</h2>
1670 <dl>
1671 <dt class="label"><a id="errata10" name="errata10" />1.0 Errata</dt>
1672 <dd>
1673 <a href="http://www.w3.org/XML/xml-names-19990114-errata"
1674 ><cite>Namespaces in XML Errata</cite></a
1675 >. W3C (World Wide Web Consortium). Available at
1676 http://www.w3.org/XML/xml-names-19990114-errata.
1677 </dd>
1678 <dt class="label">
1679 <a id="errata10.2" name="errata10.2" />1.0 2e Errata
1680 </dt>
1681 <dd>
1682 <a href="http://www.w3.org/XML/2006/xml-names-errata"
1683 ><cite>Namespaces in XML (Second Edition) Errata</cite></a
1684 >. W3C (World Wide Web Consortium). Available at
1685 http://www.w3.org/XML/2006/xml-names-errata.
1686 </dd>
1687 <dt class="label">
1688 <a id="reluri" name="reluri" />Relative URI deprecation
1689 </dt>
1690 <dd>
1691 <a href="http://www.w3.org/2000/09/xppa"
1692 ><cite>
1693 Results of W3C XML Plenary Ballot on relative URI References In
1694 namespace declarations 3-17 July 2000</cite
1695 ></a
1696 >, Dave Hollander and C. M. Sperberg-McQueen, 6 September 2000.
1697 Available at http://www.w3.org/2000/09/xppa.
1698 </dd>
1699 </dl>
1700 </div>
1701 <div class="div1">
1702 <h2>
1703 <a id="Philosophy" name="Philosophy" />C The Internal Structure of XML
1704 Namespaces (Non-Normative)
1705 </h2>
1706 <p>This appendix has been deleted.</p>
1707 </div>
1708 <div class="div1">
1709 <h2>
1710 <a id="changes" name="changes" />D Changes since version 1.0
1711 (Non-Normative)
1712 </h2>
1713 <p>
1714 This version incorporates the errata as of 20 July 2009
1715 <a href="#errata10">[1.0 Errata]</a>
1716 <a href="#errata10.2">[1.0 2e Errata]</a>.
1717 </p>
1718 <p>
1719 There are several editorial changes, including a number of terminology
1720 changes and additions intended to produce greater consistency. The
1721 non-normative appendix "The Internal Structure of XML Namespaces" has
1722 been removed. The BNF has been adjusted to interconnect properly with
1723 all editions of XML 1.0, including the fifth edition.
1724 </p>
1725 </div>
1726 <div class="div1">
1727 <h2>
1728 <a id="sec-xml-and-sgml" name="sec-xml-and-sgml" />E Acknowledgements
1729 (Non-Normative)
1730 </h2>
1731 <p>
1732 This work reflects input from a very large number of people, including
1733 especially the participants in the World Wide Web Consortium XML
1734 Working Group and Special Interest Group and the participants in the
1735 W3C Metadata Activity. The contributions of Charles Frankston of
1736 Microsoft were particularly valuable.
1737 </p>
1738 </div>
1739 <div class="div1">
1740 <h2>
1741 <a id="orphans" name="orphans" />F Orphaned Productions
1742 (Non-Normative)
1743 </h2>
1744 <p>
1745 The following two productions are modified versions of ones which were
1746 present in the first two editions of this specification. They are no
1747 longer used, but are retained here to satisfy cross-references to
1748 undated versions of this specification.
1749 </p>
1750 <p>
1751 Because the <code>Letter</code> production of XML 1.0, originally used
1752 in the definition of <code>NCNameStartChar</code>, is no longer the
1753 correct basis for defining names since XML 1.0 Fifth Edition, the
1754 <code>NCNameStartChar</code> production has been modified to give the
1755 correct results against any edition of XML, by defining
1756 <code>NCNameStartChar</code> in terms of
1757 <a href="#NT-NCName">NCName</a>.
1758 </p>
1759 <table summary="Scrap" class="scrap">
1760 <tbody>
1761 <tr valign="baseline">
1762 <td>
1763 <a
1764 id="NT-NCNameChar"
1765 name="NT-NCNameChar"
1766 />[5]&nbsp;&nbsp;&nbsp;
1767 </td>
1768 <td><code>NCNameChar</code></td>
1769 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1770 <td>
1771 <code
1772 ><a href="http://www.w3.org/TR/REC-xml/#NT-NameChar"
1773 >NameChar</a
1774 >
1775 - ':'
1776 <i
1777 >/* An XML
1778 <a href="http://www.w3.org/TR/REC-xml/#NT-NameChar"
1779 >NameChar</a
1780 >, minus the ":" */</i
1781 ></code
1782 >
1783 </td>
1784 </tr>
1785 </tbody>
1786 <tbody>
1787 <tr valign="baseline">
1788 <td>
1789 <a
1790 id="NT-NCNameStartChar"
1791 name="NT-NCNameStartChar"
1792 />[6]&nbsp;&nbsp;&nbsp;
1793 </td>
1794 <td><code>NCNameStartChar</code></td>
1795 <td>&nbsp;&nbsp;&nbsp;::=&nbsp;&nbsp;&nbsp;</td>
1796 <td>
1797 <code>
1798 <a href="#NT-NCName">NCName</a> - (
1799 <a href="http://www.w3.org/TR/REC-xml/#NT-Char">Char</a>
1800 <a href="http://www.w3.org/TR/REC-xml/#NT-Char">Char</a>
1801 <a href="http://www.w3.org/TR/REC-xml/#NT-Char">Char</a>* )
1802 <i
1803 >/* The first letter of an
1804 <a href="#NT-NCName">NCName</a> */</i
1805 >
1806 </code>
1807 </td>
1808 </tr>
1809 </tbody>
1810 </table>
1811 <div class="note">
1812 <p class="prefix"><b>Note:</b></p>
1813 <p>
1814 Production
1815 <a href="#NT-NCNameStartChar">NC-NCNameStartChar</a>
1816 takes advantage of the fact that a single-character NCName is
1817 necessarily an NCNameStartChar, and works by subtracting from the
1818 set of NCNames of all lengths the set of all strings of two or more
1819 characters, leaving only the NCNames which are one character long.
1820 </p>
1821 </div>
1822 </div>
1823 </div>
1824 <script
1825 type="application/javascript"
1826 src="https://www.w3.org/scripts/TR/fixup.js"
1827 ></script>
1828 </body>
1829 </html>