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