home *** CD-ROM | disk | FTP | other *** search
/ XML Bible (2nd Edition) / XML_Bible_Second_Edition_Hungry_Minds_2001.iso / mac / specs / xml-names.xml < prev    next >
Extensible Markup Language  |  2001-04-26  |  34KB  |  874 lines

  1. <?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
  2. <!DOCTYPE spec SYSTEM "spec.dtd" [
  3.  <!ENTITY iso6.doc.date "19990114">
  4.  <!ENTITY xmlspec "http://www.w3.org/TR/REC-xml" >
  5.  <!ENTITY cellback '#c0d9c0'>
  6. ]>
  7.  
  8. <spec>
  9. <header>
  10. <title>Namespaces in XML</title>
  11. <w3c-designation>REC-xml-names-&iso6.doc.date;</w3c-designation>
  12. <w3c-doctype>World Wide Web Consortium</w3c-doctype>
  13. <pubdate><day>14</day><month>January</month><year>1999</year></pubdate>
  14. <notice><p>This draft is for public discussion.</p></notice>
  15. <publoc>
  16. <loc href="http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;">
  17. http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;</loc>
  18. <loc href="http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;/xml-names.xml">
  19. http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;/xml-names.xml</loc>
  20. <loc href="http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;/Overview.html">
  21. http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;/Overview.html</loc>
  22. </publoc>
  23. <latestloc>
  24. <loc href='http://www.w3.org/TR/REC-xml-names'>http://www.w3.org/TR/REC-xml-names</loc>
  25. </latestloc> 
  26. <prevlocs>
  27. <loc href="http://www.w3.org/TR/1998/PR-xml-names-19981117">
  28. http://www.w3.org/TR/1998/PR-xml-names-19981117</loc>
  29. </prevlocs>
  30. <authlist>
  31. <author><name>Tim Bray</name>
  32. <affiliation>Textuality</affiliation>
  33. <email 
  34. href="mailto:tbray@textuality.com">tbray@textuality.com</email></author>
  35. <author><name>Dave Hollander</name>
  36. <affiliation>Hewlett-Packard Company</affiliation>
  37. <email href="mailto:dmh@corp.hp.com">dmh@corp.hp.com</email></author>
  38. <author><name>Andrew Layman</name>
  39. <affiliation>Microsoft</affiliation>
  40. <email href="mailto:andrewl@microsoft.com">andrewl@microsoft.com</email></author>
  41. </authlist>
  42. <status>
  43. <p>This document has been reviewed by W3C Members and
  44. other interested parties and has been endorsed by the
  45. Director as a W3C Recommendation. It is a stable
  46. document and may be used as reference material or cited
  47. as a normative reference from another document. W3C's
  48. role in making the Recommendation is to draw attention
  49. to the specification and to promote its widespread
  50. deployment. This enhances the functionality and
  51. interoperability of the Web.</p>
  52. <p>The list of known errors in this specification is 
  53. available at 
  54. <loc href='http://www.w3.org/XML/xml-names-19990114-errata'>http://www.w3.org/XML/xml-names-19990114-errata</loc>.</p>
  55. <p>Please report errors in this document to 
  56. <loc href='mailto:xml-names-editor@w3.org'>xml-names-editor@w3.org</loc>.
  57. </p>
  58. </status> 
  59. <abstract>
  60. <p>XML namespaces provide a simple method for qualifying 
  61. element and attribute
  62. names used in Extensible Markup Language documents by associating them
  63. with namespaces identified by URI references.</p>
  64. </abstract>
  65. <sourcedesc>
  66. <p>Created in electronic form.</p>
  67. </sourcedesc>
  68. <langusage>
  69. <language id='EN'>English</language>
  70. <language id='ebnf'>Extended Backus-Naur Form (formal grammar)</language>
  71. </langusage>
  72. <revisiondesc>
  73. <slist>
  74. <sitem>1997-10-10 : TB : Assembled Andrew's material and mine</sitem>
  75. </slist>
  76. </revisiondesc>
  77. </header>
  78. <body> 
  79. <div1 id='sec-intro'>
  80. <head>Motivation and Summary</head>
  81. <p>We envision applications of Extensible Markup Language (XML) where
  82. a single XML document may
  83. contain elements and attributes
  84. (here referred to as a "markup vocabulary")
  85. that are defined for and used by multiple software modules.
  86. One motivation for this is modularity; if such a markup vocabulary exists
  87. which is well-understood and for which there is useful software 
  88. available, it is better to re-use this markup rather than re-invent it.
  89. </p>
  90. <p>Such documents, containing multiple markup vocabularies,
  91. pose problems of recognition and collision.  Software modules need to
  92. be able to recognize the tags and attributes which they are designed
  93. to process, even in the face 
  94. of "collisions" occurring when markup intended for some other software
  95. package uses the same element type or attribute name.
  96. </p>
  97.  
  98. <p>These considerations require that document
  99. constructs
  100. should have universal names, 
  101. whose scope extends beyond their
  102. containing document. 
  103. This specification describes a mechanism,
  104. <emph>XML namespaces</emph>, which accomplishes this.</p>
  105.  
  106. <p><termdef id='dt-namespace' term='Namespace'>An <term>XML namespace</term>
  107. is a collection of names, identified by a URI reference
  108. <bibref ref='URIRef'/>,
  109. which are used in XML documents as 
  110. <xtermref href='&xmlspec;#dt-stag'>element types</xtermref> 
  111. and <xtermref href='&xmlspec;#dt-attrname'>attribute names</xtermref>.
  112. </termdef>
  113. XML namespaces
  114. differ from the "namespaces" conventionally used in computing disciplines
  115. in that the XML version has internal structure and is not, mathematically
  116. speaking, a set.
  117. These issues are discussed in
  118. <specref ref='Philosophy' />.
  119. </p>
  120. <p><termdef id='dt-identical' term='Identical'>URI references which
  121. identify namespaces are considered <term>identical</term> when they are
  122. exactly the same character-for-character.</termdef>
  123. Note that URI references which are not identical in this sense may in fact be
  124. functionally equivalent.
  125. Examples include URI references which differ only in case, or which are in
  126. external entities which have different effective base URIs.
  127. </p>
  128.  
  129. <p>Names from XML namespaces may appear as
  130. <termref def='dt-qname'>qualified names</termref>, 
  131. which contain a single colon, separating the name into a
  132. <termref def='dt-prefix'>namespace prefix</termref> and a
  133. <termref def='dt-localname'>local part</termref>.
  134. The prefix, which is mapped to a URI reference, selects a namespace. 
  135. The combination of
  136. the universally managed URI namespace and the document's own namespace
  137. produces identifiers that are universally unique.
  138. Mechanisms are provided for prefix scoping and defaulting.
  139. </p>
  140.  
  141. <p>URI references can contain characters not allowed in names, so cannot
  142. be used directly as namespace prefixes.
  143. Therefore, the 
  144. namespace prefix serves as a proxy for a URI reference.
  145. An attribute-based syntax described below is used
  146. to <termref def='dt-NSDecl'>declare</termref> the association of the 
  147. namespace prefix with a URI reference; 
  148. software which supports this namespace proposal must
  149. recognize and act on these declarations and prefixes.
  150. </p>
  151. <div2 id='notation'>
  152. <head>A Note on Notation and Usage</head>
  153. <p>Note that many of the
  154. nonterminals in the productions in 
  155. this specification are defined not here but in
  156. the XML specification <bibref ref='XML'/>.
  157. When nonterminals defined here have the same names as nonterminals
  158. defined in the XML specification, the productions here
  159. in all cases match a subset of the strings matched by the 
  160. corresponding ones there.
  161. </p>
  162. <p>In this document's productions, 
  163. the <code>NSC</code> is a "Namespace Constraint", 
  164. one of the rules that documents conforming to this specification must follow.
  165. </p>
  166. <p>Note that all Internet domain names used in
  167. examples, with the exception of <code>w3.org</code>, are selected
  168. at random and should not be taken as having any import.</p>
  169. </div2>
  170. </div1>
  171. <div1 id='ns-decl'> 
  172. <head>Declaring Namespaces</head>
  173. <p><termdef id='dt-NSDecl' term='Namespace declaration'>A namespace is
  174. <term>declared</term> using 
  175. a family of reserved attributes.
  176. Such an attribute's name  must either
  177. be <kw>xmlns</kw> or have <kw>xmlns:</kw> as a prefix.
  178. These attributes, like any other XML attributes, may be provided
  179. directly or by <xtermref href='&xmlspec;#dt-default'>default</xtermref>.
  180. </termdef>
  181. </p>
  182. <scrap lang='ebnf'>
  183. <head>Attribute Names for Namespace Declaration</head>
  184. <!--
  185. <prod id='NT-AttNSDecl'><lhs>NSDecl</lhs>
  186. <rhs><nt def='NT-NSAttName'>NSAttName</nt>
  187. <xnt href='&xmlspec;#NT-Eq'>Eq</xnt>
  188. <xnt href="&xmlspec;#NT-AttValue">AttValue</xnt></rhs>
  189. <nsc def='nsc-emptyLit' />
  190. </prod> -->
  191. <prod id='NT-NSAttName'><lhs>NSAttName</lhs>
  192. <rhs><nt def='NT-PrefixedAttName'>PrefixedAttName</nt></rhs>
  193. <rhs>| <nt def='NT-DefaultAttName'>DefaultAttName</nt></rhs></prod>
  194. <prod id='NT-PrefixedAttName'><lhs>PrefixedAttName</lhs>
  195. <rhs>'xmlns:' <nt def='NT-NCName'>NCName</nt></rhs>
  196. <nsc def='xmlReserved' />
  197. </prod>
  198. <prod id='NT-DefaultAttName'><lhs>DefaultAttName</lhs>
  199. <rhs>'xmlns'</rhs></prod>
  200. <prod id='NT-NCName'><lhs>NCName</lhs>
  201. <rhs>(<xnt href='&xmlspec;#NT-Letter'>Letter</xnt> | '_')
  202. (<nt def='NT-NCNameChar'>NCNameChar</nt>)*</rhs><com>An XML
  203. <xnt href='&xmlspec;#NT-Name'>Name</xnt>, minus the ":"</com></prod>
  204. <prod id='NT-NCNameChar'><lhs>NCNameChar</lhs>
  205. <rhs><xnt href="&xmlspec;#NT-Letter">Letter</xnt>
  206. | <xnt href='&xmlspec;#NT-Digit'>Digit</xnt> 
  207. | '.' | '-' | '_'
  208. | <xnt href='&xmlspec;#NT-CombiningChar'>CombiningChar</xnt>
  209. | <xnt href='&xmlspec;#NT-Extender'>Extender</xnt></rhs>
  210. </prod>
  211. </scrap>
  212.  
  213. <p>
  214. <termdef id='dt-NSName' term="Namespace name">The attribute's 
  215. <xtermref href="&xmlspec;#dt-attrval">value</xtermref>,
  216. a URI reference,
  217. is the <term>namespace name</term> identifying the namespace.</termdef>
  218. The namespace name, to serve its
  219. intended purpose, should have the characteristics of uniqueness and
  220. persistence.
  221. It is not a goal that it be directly usable for retrieval of a schema (if
  222. any exists). 
  223. An example of a syntax that is designed with these goals in mind is
  224. that for Uniform Resource Names <bibref ref='URNs'/>.
  225. However, it should be noted that ordinary URLs can be managed in such a way as
  226. to achieve these same goals.</p>
  227.  
  228. <p>
  229. <termdef id='dt-prefix' term='Namespace Prefix'>If the
  230. attribute name matches <nt def='NT-PrefixedAttName'>PrefixedAttName</nt>,
  231. then the
  232. <nt def="NT-NCName">NCName</nt> gives the <term>namespace prefix</term>,
  233. used to associate element and attribute names with the
  234. <termref def='dt-NSName'>namespace name</termref> in the attribute value
  235. in the scope of the element to which the declaration
  236. is attached.</termdef>
  237. In such declarations, the namespace name may not be empty.</p>
  238.  
  239. <p><termdef id='dt-defaultNS' term='Default Namespace'>If the 
  240. attribute name matches <nt def='NT-DefaultAttName'>DefaultAttName</nt>,
  241. then the
  242. <termref def='dt-NSName'>namespace name</termref> in the
  243. attribute value is
  244. that of the <term>default namespace</term>
  245. in the scope of the element to which the declaration
  246. is attached.</termdef>
  247.  
  248. In such a default declaration, the attribute value may be empty.
  249. Default namespaces and overriding of declarations are discussed in 
  250. <specref ref='scoping-defaulting'/>.
  251. </p>
  252.  
  253.  
  254. <p>An example namespace declaration, which associates the 
  255. namespace prefix <kw>edi</kw> with the namespace name 
  256. <code>http://ecommerce.org/schema</code>:
  257. <eg><![CDATA[<x xmlns:edi='http://ecommerce.org/schema'>
  258.   <!-- the "edi" prefix is bound to http://ecommerce.org/schema
  259.        for the "x" element and contents -->
  260. </x>]]></eg>
  261. </p>
  262.  
  263.  
  264.  
  265. <nscnote id='xmlReserved'>
  266. <head>Leading "XML"</head>
  267. <p>Prefixes beginning with the three-letter sequence <code>x</code>,
  268. <code>m</code>, <code>l</code>, in any case combination, are reserved
  269. for use by XML and XML-related specifications.</p>
  270. </nscnote>
  271.  
  272.  
  273. </div1>
  274. <div1 id='ns-qualnames'>
  275. <head>Qualified Names</head>
  276. <p><termdef id='dt-qname' term='Qualified Name'>In XML
  277. documents conforming to this specification, some
  278. names (constructs corresponding to the nonterminal 
  279. <xnt href="&xmlspec;#NT-Name">Name</xnt>)
  280. may be given as <term>qualified names</term>, defined as follows:
  281. <scrap lang='ebnf'>
  282. <head>Qualified Name</head>
  283. <prod id='NT-QName'><lhs>QName</lhs>
  284. <rhs>
  285. (<nt def='NT-Prefix'>Prefix</nt> ':')?
  286. <nt def='NT-LocalPart'>LocalPart</nt></rhs></prod>
  287. <prod id='NT-Prefix'><lhs>Prefix</lhs>
  288. <rhs><nt def="NT-NCName">NCName</nt></rhs></prod>
  289. <prod id='NT-LocalPart'><lhs>LocalPart</lhs>
  290. <rhs><nt def="NT-NCName">NCName</nt></rhs>
  291. </prod>
  292.  
  293. </scrap></termdef>
  294. The 
  295. <nt def='NT-Prefix'>Prefix</nt> provides the 
  296. <termref def='dt-prefix'>namespace prefix</termref>
  297. part of the qualified name, and must be associated with a namespace URI
  298. reference in a
  299. <termref def='dt-NSDecl'>namespace declaration</termref>.
  300. <termdef id='dt-localname' term='Local Part'>
  301. The <nt def='NT-LocalPart'>LocalPart</nt> provides the
  302. <term>local part</term> of the qualified name.</termdef>
  303. </p>
  304. <p>Note that the prefix functions <emph>only</emph> as a placeholder for a
  305. namespace name.
  306. Applications should use the namespace name, not the prefix, in constructing
  307. names whose scope extends beyond the 
  308. containing document.</p>
  309. </div1>
  310. <div1 id='ns-using'>
  311. <head>Using Qualified Names</head>
  312. <p>In XML documents conforming to this specification,
  313. element types are given as
  314. <termref def='dt-qname'>qualified names</termref>, as
  315. follows:
  316. <scrap lang='ebnf'>
  317. <head>Element Types</head>
  318. <prod id='NT-STag'><lhs>STag</lhs>
  319. <rhs>'<' <nt def='NT-QName'>QName</nt> 
  320. (<xnt href='&xmlspec;#NT-S'>S</xnt> 
  321. <xnt href='&xmlspec;#NT-Attribute'>Attribute</xnt>)* 
  322. <xnt href='&xmlspec;#NT-S'>S</xnt>? '>'
  323. </rhs><nsc def='nsc-NSDeclared'/>
  324. </prod>
  325. <prod id='NT-ETag'><lhs>ETag</lhs>
  326. <rhs>'</' <nt def='NT-QName'>QName</nt> 
  327. <xnt href='&xmlspec;#NT-S'>S</xnt>? '>'</rhs>
  328. <nsc def='nsc-NSDeclared'/></prod>
  329. <prod id='NT-EmptyElemTag'><lhs>EmptyElemTag</lhs>
  330. <rhs>'<' <nt def='NT-QName'>QName</nt> 
  331. (<xnt href='&xmlspec;#NT-S'>S</xnt>
  332. <xnt href='&xmlspec;#NT-Attribute'>Attribute</xnt>)* 
  333. <xnt href='&xmlspec;#NT-S'>S</xnt>? '/>'</rhs>
  334. <nsc def='nsc-NSDeclared'/></prod>
  335. </scrap>
  336. </p>
  337. <p>An example of a qualified name serving as an element type:
  338. <eg><![CDATA[<x xmlns:edi='http://ecommerce.org/schema'>
  339.   <!-- the 'price' element's namespace is http://ecommerce.org/schema -->
  340.   <edi:price units='Euro'>32.18</edi:price>
  341. </x>]]></eg>
  342. </p>
  343.  
  344. <p>
  345. Attributes are either <termref def='dt-NSDecl'>namespace
  346. declarations</termref>
  347. or their names are given as
  348. <termref def='dt-qname'>qualified names</termref>:
  349. <scrap lang='ebnf'>
  350. <head>Attribute</head>
  351. <prod id='NT-Attribute'><lhs>Attribute</lhs>
  352. <rhs><nt def='NT-NSAttName'>NSAttName</nt>
  353. <xnt href='&xmlspec;#NT-Eq'>Eq</xnt> 
  354. <xnt href='&xmlspec;#NT-AttValue'>AttValue</xnt></rhs>
  355. <rhs>| <nt def='NT-QName'>QName</nt> <xnt href='&xmlspec;#NT-Eq'>Eq</xnt> 
  356. <xnt href='&xmlspec;#NT-AttValue'>AttValue</xnt></rhs>
  357. <nsc def='nsc-NSDeclared'/></prod>
  358. </scrap>
  359. </p>
  360. <p>An example of a qualified name serving as an attribute name:
  361. <eg><![CDATA[<x xmlns:edi='http://ecommerce.org/schema'>
  362.   <!-- the 'taxClass' attribute's namespace is http://ecommerce.org/schema -->
  363.   <lineItem edi:taxClass="exempt">Baby food</lineItem>
  364. </x>]]></eg>
  365. </p>
  366. <nscnote id='nsc-NSDeclared'>
  367. <head>Prefix Declared</head>
  368. <p>The namespace prefix, unless it is <code>xml</code>
  369. or <code>xmlns</code>, must have been
  370. declared in a <termref def='dt-NSDecl'>namespace declaration</termref>
  371. attribute in either the start-tag of the element where the prefix 
  372. is used or in an an ancestor element (i.e. an element in whose 
  373. <xtermref href='&xmlspec;#dt-content'>content</xtermref> the
  374. prefixed markup occurs).
  375. The prefix <code>xml</code> is by definition bound to the 
  376. namespace name <code>http://www.w3.org/XML/1998/namespace</code>.
  377. The prefix <code>xmlns</code> is used only for namespace bindings
  378. and is not itself bound to any namespace name.
  379. </p></nscnote>
  380. <p>This constraint may lead to operational difficulties in the case where
  381. the namespace declaration attribute is provided, not directly in the XML
  382. <xtermref href='&xmlspec;#dt-docent'>document entity</xtermref>, but 
  383. via a default attribute declared in an external entity.
  384. Such declarations may not be read by software which is based on a
  385. non-validating XML processor.
  386. Many XML applications, presumably including namespace-sensitive ones, fail to
  387. require validating processors.
  388. For correct operation with such applications, namespace declarations must be
  389. provided either directly or via default attributes declared in the
  390. <xtermref href='&xmlspec;#dt-doctype'>internal subset of the DTD</xtermref>.
  391. </p>
  392. <p>Element names and attribute types are also given as qualified names when
  393. they appear in declarations in the 
  394. <xtermref href='&xmlspec;#dt-dtd'>DTD</xtermref>:
  395. <scrap lang='ebnf'>
  396. <head>Qualified Names in Declarations</head>
  397. <prod id='NT-doctypedecl'><lhs>doctypedecl</lhs>
  398. <rhs>'<!DOCTYPE' <xnt href='&xmlspec;#NT-S'>S</xnt>
  399. <nt def='NT-QName'>QName</nt> (<xnt href='&xmlspec;#NT-S'>S</xnt>
  400. <xnt href='&xmlspec;#NT-ExternalID'>ExternalID</xnt>)? 
  401. <xnt href='&xmlspec;#NT-S'>S</xnt>? ('[' 
  402. (<xnt href='&xmlspec;#NT-markupdecl'>markupdecl</xnt> 
  403. | <xnt href='&xmlspec;#NT-PEReference'>PEReference</xnt> 
  404. | <xnt href='&xmlspec;#NT-S'>S</xnt>)* 
  405. ']' 
  406. <xnt href='&xmlspec;#NT-S'>S</xnt>?)? '>'</rhs>
  407. </prod>
  408.  
  409. <prod id='NT-elementdecl'><lhs>elementdecl</lhs>
  410. <rhs>'<!ELEMENT' <xnt href='&xmlspec;#NT-S'>S</xnt> 
  411. <nt def='NT-QName'>QName</nt> 
  412. <xnt href='&xmlspec;#NT-S'>S</xnt> 
  413. <xnt href='&xmlspec;#NT-contentspec'>contentspec</xnt>
  414. <xnt href='&xmlspec;#NT-S'>S</xnt>? '>'</rhs>
  415. </prod>
  416. <prod id='NT-cp'><lhs>cp</lhs>
  417. <rhs>(<nt def='NT-QName'>QName</nt> 
  418. | <xnt href='&xmlspec;#NT-choice'>choice</xnt> 
  419. | <xnt href='&xmlspec;#NT-seq'>seq</xnt>) 
  420. ('?' | '*' | '+')?</rhs></prod>
  421. <prod id='NT-Mixed'><lhs>Mixed</lhs>
  422. <rhs>'(' <xnt href='&xmlspec;#NT-S'>S</xnt>? 
  423. '#PCDATA'
  424. (<xnt href='&xmlspec;#NT-S'>S</xnt>? 
  425. '|' 
  426. <xnt href='&xmlspec;#NT-S'>S</xnt>? 
  427. <nt def='NT-QName'>QName</nt>)* 
  428. <xnt href='&xmlspec;#NT-S'>S</xnt>? 
  429. ')*' </rhs>
  430. <rhs>| '(' <xnt href='&xmlspec;#NT-S'>S</xnt>? '#PCDATA' <xnt href='&xmlspec;#NT-S'>S</xnt>? ')'
  431. </rhs>
  432. </prod>
  433. <prod id='NT-AttlistDecl'><lhs>AttlistDecl</lhs>
  434. <rhs>'<!ATTLIST' <xnt href='&xmlspec;#NT-S'>S</xnt> 
  435. <nt def='NT-QName'>QName</nt> 
  436. <nt def='NT-AttDef'>AttDef</nt>*
  437. <xnt href='&xmlspec;#NT-S'>S</xnt>? '>'</rhs>
  438. </prod>
  439. <prod id='NT-AttDef'><lhs>AttDef</lhs>
  440. <rhs><xnt href='&xmlspec;#NT-S'>S</xnt> 
  441. (<nt def='NT-QName'>QName</nt> | <nt def='NT-NSAttName'>NSAttName</nt>)
  442. <xnt href='&xmlspec;#NT-S'>S</xnt> <xnt href='&xmlspec;#NT-AttType'>AttType</xnt> 
  443. <xnt href='&xmlspec;#NT-S'>S</xnt> <xnt href='&xmlspec;#NT-DefaultDecl'>DefaultDecl</xnt></rhs>
  444. </prod>
  445. </scrap>
  446. </p>
  447.  
  448. </div1>
  449.  
  450. <div1 id='scoping-defaulting'>
  451. <head>Applying Namespaces to Elements and Attributes</head>
  452. <div2 id='scoping'>
  453. <head>Namespace Scoping</head>
  454. <p>The namespace declaration is considered to apply to the 
  455. element where it is specified and to all elements within the content  
  456. of that element, unless overridden by another namespace declaration
  457. with the same <nt def='NT-NSAttName'>NSAttName</nt> part:
  458. <eg><![CDATA[<?xml version="1.0"?>
  459. <!-- all elements here are explicitly in the HTML namespace -->
  460. <html:html xmlns:html='http://www.w3.org/TR/REC-html40'>
  461.   <html:head><html:title>Frobnostication</html:title></html:head>
  462.   <html:body><html:p>Moved to 
  463.     <html:a href='http://frob.com'>here.</html:a></html:p></html:body>
  464. </html:html>]]></eg>
  465. </p>
  466. <p>Multiple namespace prefixes can be declared as attributes of a single element, 
  467. as shown in this example:
  468. <eg><![CDATA[<?xml version="1.0"?>
  469. <!-- both namespace prefixes are available throughout -->
  470. <bk:book xmlns:bk='urn:loc.gov:books'
  471.          xmlns:isbn='urn:ISBN:0-395-36341-6'>
  472.     <bk:title>Cheaper by the Dozen</bk:title>
  473.     <isbn:number>1568491379</isbn:number>
  474. </bk:book>]]></eg>
  475. </p>
  476. </div2>
  477. <div2 id='defaulting'>
  478. <head>Namespace Defaulting</head>
  479. <p>A <termref def='dt-defaultNS'>default namespace</termref> is considered
  480. to apply to the element where it is declared (if that element has no
  481. <termref def='dt-prefix'>namespace prefix</termref>), and to all elements
  482. with no prefix within the content of that
  483. element.
  484. If the URI reference in a default namespace declaration is empty, then 
  485. unprefixed
  486. elements in the scope of the declaration are not considered to be in 
  487. any namespace.
  488. Note that default namespaces do not apply directly to attributes.
  489.  
  490. <eg><![CDATA[<?xml version="1.0"?>
  491. <!-- elements are in the HTML namespace, in this case by default -->
  492. <html xmlns='http://www.w3.org/TR/REC-html40'>
  493.   <head><title>Frobnostication</title></head>
  494.   <body><p>Moved to 
  495.     <a href='http://frob.com'>here</a>.</p></body>
  496. </html>]]></eg>
  497. <eg><![CDATA[<?xml version="1.0"?>
  498. <!-- unprefixed element types are from "books" -->
  499. <book xmlns='urn:loc.gov:books'
  500.       xmlns:isbn='urn:ISBN:0-395-36341-6'>
  501.     <title>Cheaper by the Dozen</title>
  502.     <isbn:number>1568491379</isbn:number>
  503. </book>]]></eg>
  504. </p>
  505. <p>A larger example of namespace scoping:
  506. <eg><![CDATA[<?xml version="1.0"?>
  507. <!-- initially, the default namespace is "books" -->
  508. <book xmlns='urn:loc.gov:books'
  509.       xmlns:isbn='urn:ISBN:0-395-36341-6'>
  510.     <title>Cheaper by the Dozen</title>
  511.     <isbn:number>1568491379</isbn:number>
  512.     <notes>
  513.       <!-- make HTML the default namespace for some commentary -->
  514.       <p xmlns='urn:w3-org-ns:HTML'>
  515.           This is a <i>funny</i> book!
  516.       </p>
  517.     </notes>
  518. </book>]]></eg>
  519. </p>
  520. <p>The default namespace can be set to the empty string.  
  521. This has the same
  522. effect, within the scope of the declaration, of there being no default
  523. namespace.
  524. <eg><![CDATA[<?xml version='1.0'?>
  525. <Beers>
  526.   <!-- the default namespace is now that of HTML -->
  527.   <table xmlns='http://www.w3.org/TR/REC-html40'>
  528.    <th><td>Name</td><td>Origin</td><td>Description</td></th>
  529.    <tr> 
  530.      <!-- no default namespace inside table cells -->
  531.      <td><brandName xmlns="">Huntsman</brandName></td>
  532.      <td><origin xmlns="">Bath, UK</origin></td>
  533.      <td>
  534.        <details xmlns=""><class>Bitter</class><hop>Fuggles</hop>
  535.          <pro>Wonderful hop, light alcohol, good summer beer</pro>
  536.          <con>Fragile; excessive variance pub to pub</con>
  537.          </details>
  538.         </td>
  539.       </tr>
  540.     </table>
  541.   </Beers>]]></eg>
  542. </p>
  543. </div2>
  544. <div2 id='uniqAttrs'>
  545. <head>Uniqueness of Attributes</head>
  546. <p>In XML documents conforming
  547. to this specification, no tag
  548. may contain two attributes which:
  549. <olist><item><p>have identical names, or</p></item>
  550. <item><p>have qualified names with the same
  551. <termref def='dt-localname'>local part</termref> and with 
  552. <termref def='dt-prefix'>prefixes</termref> which have been bound
  553. to <termref def='dt-NSName'>namespace names</termref> that
  554. are <termref def='dt-identical'>identical</termref>.
  555. </p>
  556. </item>
  557. </olist>
  558. </p>
  559. <p>For example, each of the <code>bad</code> start-tags is illegal in the
  560. following:
  561. <eg><![CDATA[<!-- http://www.w3.org is bound to n1 and n2 -->
  562. <x xmlns:n1="http://www.w3.org" 
  563.    xmlns:n2="http://www.w3.org" >
  564.   <bad a="1"     a="2" />
  565.   <bad n1:a="1"  n2:a="2" />
  566. </x>]]></eg>
  567. However, each of the following is legal, the second because the default 
  568. namespace does not apply to attribute names:
  569. <eg><![CDATA[<!-- http://www.w3.org is bound to n1 and is the default -->
  570. <x xmlns:n1="http://www.w3.org" 
  571.    xmlns="http://www.w3.org" >
  572.   <good a="1"     b="2" />
  573.   <good a="1"     n1:a="2" />
  574. </x>]]></eg>
  575. </p>
  576. </div2>
  577. </div1>
  578.  
  579. <div1 id='Conformance'>
  580. <head>Conformance of Documents</head>
  581. <p>In XML documents which conform to this specification, 
  582. element types and attribute names must match the production for 
  583. <nt def='NT-QName'>QName</nt> and
  584. must satisfy the "Namespace Constraints".</p>
  585. <p>An XML document conforms to this specification if all other 
  586. tokens in the document which are required, for XML conformance, to match the
  587. XML production for <xnt href="&xmlspec;#NT-Name">Name</xnt>, match
  588. this specification's production for <nt def='NT-NCName'>NCName</nt>.
  589. </p>
  590. <p>The effect of conformance is that in such a document:
  591. <ulist><item><p>All element types and attribute names contain either zero
  592. or one colon.</p></item>
  593. <item><p>No entity names, PI targets, or notation names contain any colons.</p>
  594. </item>
  595. </ulist></p>
  596. <p>Strictly speaking, attribute values declared to be of types
  597. <kw>ID</kw>, <kw>IDREF(S)</kw>, <kw>ENTITY(IES)</kw>,
  598. and <kw>NOTATION</kw> are also <xnt href="&xmlspec;#NT-Name">Names</xnt>,
  599. and thus should be colon-free.
  600. However, the declared type of attribute values is only available
  601. to processors which read markup declarations, for example
  602. <xtermref href='&xmlspec;#dt-validating'>validating processors</xtermref>.
  603. Thus, unless the use of a validating processor has been specified,
  604. there can be no assurance that the contents of attribute values
  605. have been checked for conformance to this specification.</p>
  606. </div1>
  607.  
  608. </body>
  609. <back>
  610.  
  611. <inform-div1 id='Philosophy'>
  612. <head>The Internal Structure of XML Namespaces</head>
  613. <div2 id='sets-no-good'>
  614. <head>The Insufficiency of the Traditional Namespace</head>
  615. <p>In the computing disciplines, the term "namespace" conventionally refers to
  616. a <emph>set</emph> of names, i.e. a collection containing no duplicates.
  617. However, treating the names used in XML markup
  618. as such a namespace would greatly impair their usefulness.
  619. The primary use of such names in XML documents is to enable identification 
  620. of logical 
  621. structures in documents by software modules such as query processors,
  622. stylesheet-driven
  623. rendering engines, and schema-driven validators.
  624. Consider the following example:
  625. <eg><![CDATA[<section><title>Book-Signing Event</title>
  626. <signing>
  627.   <author title="Mr" name="Vikram Seth" />
  628.   <book title="A Suitable Boy" price="$22.95" /></signing>
  629. <signing>
  630.   <author title="Dr" name="Oliver Sacks" />
  631.   <book title="The Island of the Color-Blind" price="$12.95" /></signing>
  632. </section>]]></eg>
  633. In this example, there are three occurrences of the name <code>title</code>
  634. within markup, and the name alone clearly provides insufficient information
  635. to allow correct processing by a software module.</p>
  636. <p>Another problematic area comes from the use of "global" attributes, as
  637. illustrated by this example, a fragment of an XML document which is to 
  638. be displayed using a CSS stylesheet:
  639. <eg><![CDATA[<RESERVATION>
  640.  <NAME HTML:CLASS="largeSansSerif">Layman, A</NAME>
  641.  <SEAT CLASS="Y" HTML:CLASS="reallyImportant">33B</SEAT>
  642.  <DEPARTURE>1997-05-24T07:55:00+1</DEPARTURE></RESERVATION>]]></eg>
  643. In this case, the <code>CLASS</code> attribute, which describes the fare basis
  644. and takes values such as "J", "Y", and "C", is distinct at all semantic levels
  645. from the <code>HTML:CLASS</code> attribute, which 
  646. is used to
  647. simulate syntactic richness in HTML, as a means of overcoming the
  648. limited element repertoire by subclassing.</p>
  649. <p>XML 1.0 does not provide a built-in way to declare "global" attributes;
  650. items such as the HTML <code>CLASS</code> attribute are global only in their
  651. prose description and their interpretation by HTML applications.
  652. However, such attributes, an important distinguishing feature of which is that
  653. their names are unique, are commonly observed to occur in a variety of
  654. applications.</p>
  655. </div2>
  656. <div2 id='ns-breakdown'>
  657. <head>XML Namespace Partitions</head>
  658. <p>In order to support the goal of making both qualified and unqualified names
  659. useful in meeting their intended purpose, we identify the names appearing in
  660. an XML namespace as belonging to one of several disjoint traditional
  661. (i.e. set-structured) namespaces, called namespace partitions.
  662. The partitions are:
  663. <glist>
  664. <gitem><label>The All Element Types Partition</label>
  665. <def><p>All element types in an XML namespace appear in this partition.
  666. Each has a unique <termref def='dt-localname'>local part</termref>; the
  667. combination of the namespace name and the local part uniquely identifies the
  668. element type.</p></def></gitem>
  669. <gitem><label>The Global Attribute Partition</label>
  670. <def><p>This partition contains the names of all attributes which are defined,
  671. in this namespace, to be global.
  672. The only required characteristic of a global attribute is that its name be
  673. unique in the global attribute partition.
  674. This specification makes no
  675. assertions as to the proper usage of such attributes.
  676. The combination of the namespace name and the attribute name uniquely
  677. identifies the global attribute.</p></def></gitem>
  678. <gitem><label>The Per-Element-Type Partitions</label>
  679. <def><p>Each type in the All Element Types Partition has an
  680. associated namespace in which appear the names of the unqualified attributes
  681. that are provided for that element.
  682. This is a traditional namespace because the appearance of duplicate attribute
  683. names on an element is forbidden by XML 1.0.
  684. The combination of the attribute name with the element's type and namespace
  685. name uniquely identifies each unqualified attribute.</p></def></gitem>
  686. </glist>
  687. </p>
  688. <p>In XML documents conforming to this specification, the names of 
  689. all qualified (prefixed) attributes are assigned to the global attribute
  690. partition, and the names of all unqualified attributes are assigned to the
  691. appropriate per-element-type partition.</p>
  692. </div2>
  693. <div2 id='ns-expnames'>
  694. <head>Expanded Element Types and Attribute Names</head>
  695. <p>For convenience in specifying rules and in making comparisons, we define an
  696. expanded form, expressed here in XML element syntax, for each element type and
  697. attribute name in an XML document.</p>
  698. <p><termdef id='dt-ExpEType' term="Expanded Element Type">An 
  699. <term>expanded element
  700. type</term> is expressed as an empty XML element of type
  701. <code>ExpEType</code>. 
  702. It has a required <code>type</code> attribute which
  703. gives the type's <nt def='NT-LocalPart'>LocalPart</nt>, and an optional
  704. <code>ns</code> attribute which, if the element is qualified, gives its
  705. <termref def='dt-NSName'>namespace name</termref>.</termdef></p>
  706. <p><termdef id='dt-expaname' term="Expanded Attribute Name">An 
  707. <term>expanded
  708. attribute name</term> is expressed as an empty XML element of type
  709. <code>ExpAName</code>.
  710. It has a required <code>name</code> attribute which gives the name.
  711. If the attribute is global, it has a required <code>ns</code> attribute
  712. which gives the <termref def='dt-NSName'>namespace name</termref>;
  713. otherwise, it has a required attribute <code>eltype</code> which
  714. gives the type of the attached element, and an optional attribute
  715. <code>elns</code> which gives the namespace name, if known, of the
  716. attached element.</termdef></p>
  717. <p>Slight variations on the examples given above will illustrate
  718. the working of expanded element types and attribute names.
  719. The following two fragments are each followed by a table showing
  720. the expansion of the names:
  721. <eg><![CDATA[<!-- 1 --> <section xmlns='urn:com:books-r-us'>
  722. <!-- 2 -->   <title>Book-Signing Event</title>
  723. <!-- 3 -->   <signing>
  724. <!-- 4 -->     <author title="Mr" name="Vikram Seth" />
  725. <!-- 5 -->     <book title="A Suitable Boy" price="$22.95" />
  726.              </signing>
  727.            </section>]]></eg>
  728. The names would expand as follows:
  729.  
  730. <table bgcolor="&cellback;" border="1" cellpadding="7"><tbody>
  731. <tr align='left'><td>Line</td><td>Name</td><td>Expanded</td>
  732. </tr>
  733. <tr>
  734. <td>1</td><td>section</td>
  735. <td><ExpEType type="section" ns="urn:com:books-r-us" /> </td></tr>
  736. <tr><td>2</td>
  737. <td>title</td><td><ExpEType type="title" ns="urn:com:books-r-us" /> </td>
  738. </tr>
  739. <tr>
  740. <td>3</td>
  741. <td>signing</td><td><ExpEType type="signing" ns="urn:com:books-r-us" />
  742. </td>
  743. </tr>
  744. <tr>
  745. <td>4</td>
  746. <td>author</td><td><ExpEType type="author" ns="urn:com:books-r-us" /> </td>
  747. </tr>
  748. <tr>
  749. <td>4</td>
  750. <td>title</td>
  751. <td><ExpAName name='title' eltype="author" elns="urn:com:books-r-us" />
  752. </td>
  753. </tr>
  754. <tr>
  755. <td>4</td>
  756. <td>name</td>
  757. <td><ExpAName name='name' eltype="author" elns="urn:com:books-r-us" /></td>
  758. </tr>
  759. <tr>
  760. <td>5</td>
  761. <td>book</td><td><ExpEType type="book" ns="urn:com:books-r-us" /></td>
  762. </tr>
  763. <tr>
  764. <td>5</td>
  765. <td>title</td><td><ExpAName name='title' eltype="book" elns="urn:com:books-r-us" /></td>
  766. </tr>
  767. <tr>
  768. <td>5</td>
  769. <td>price</td><td><ExpAName name='price' eltype="book" elns="urn:com:books-r-us" /></td>
  770. </tr>
  771. </tbody>
  772. </table>
  773.  
  774. <eg><![CDATA[<!-- 1 --> <RESERVATION xmlns:HTML="http://www.w3.org/TR/REC-html40">
  775. <!-- 2 --> <NAME HTML:CLASS="largeSansSerif">Layman, A</NAME>
  776. <!-- 3 --> <SEAT CLASS="Y" HTML:CLASS="largeMonotype">33B</SEAT>
  777. <!-- 4 --> <HTML:A HREF='/cgi-bin/ResStatus'>Check Status</HTML:A>
  778. <!-- 5 --> <DEPARTURE>1997-05-24T07:55:00+1</DEPARTURE></RESERVATION>]]></eg>
  779.  
  780. <table bgcolor="&cellback;" border="1" cellpadding="7">
  781. <tbody>
  782. <tr><td>1</td>
  783. <td>RESERVATION</td><td><ExpEType type="RESERVATION" /></td>
  784. </tr>
  785. <tr>
  786. <td>2</td>
  787. <td>NAME</td><td><ExpEType type="NAME" /></td>
  788. </tr>
  789. <tr>
  790. <td>2</td>
  791. <td>HTML:CLASS</td>
  792. <td><ExpAName name="CLASS" ns=http://www.w3.org/TR/REC-html40 /></td>
  793. </tr>
  794. <tr>
  795. <td>3</td>
  796. <td>SEAT</td><td><ExpEType type="SEAT" /></td>
  797. </tr>
  798. <tr>
  799. <td>3</td>
  800. <td>CLASS</td><td><ExpAName name="CLASS" eltype="SEAT"></td>
  801. </tr>
  802. <tr>
  803. <td>3</td>
  804. <td>HTML:CLASS</td><td><ExpAName name="CLASS" ns="http://www.w3.org/TR/REC-html40" /></td>
  805. </tr>
  806. <tr>
  807. <td>4</td>
  808. <td>HTML:A</td><td><ExpEType type="A" ns="http://www.w3.org/TR/REC-html40" /></td>
  809. </tr>
  810. <tr>
  811. <td>4</td>
  812. <td>HREF</td><td><ExpAName name="HREF" eltype="A" elns="http://www.w3.org/TR/REC-html40" /></td>
  813. </tr>
  814. <tr>
  815. <td>5</td>
  816. <td>DEPARTURE</td><td><ExpEType type="DEPARTURE" /></td>
  817. </tr>
  818. </tbody></table>
  819. </p>
  820. </div2>
  821. <div2 id='check-uniqattr'>
  822. <head>Unique Expanded Attribute Names</head>
  823. <p>The constraint expressed by <specref ref='uniqAttrs' /> above
  824. may straightforwardly be implemented by requiring that
  825. no element have
  826. two attributes whose expanded names are equivalent, i.e. have the same
  827. attribute-value pairs.</p>
  828. </div2>
  829. </inform-div1>
  830.  
  831. <inform-div1 id='sec-xml-and-sgml'>
  832. <head>Acknowledgements</head>
  833.  
  834. <p>This work reflects input from a very large number of people, 
  835. including especially the members of the World Wide
  836. Web Consortium XML Working Group and Special Interest Group 
  837. and the participants in the W3C Metadata Activity.
  838. The contributions of Charles Frankston of Microsoft 
  839. were particularly valuable.</p>
  840. </inform-div1>
  841. <div1 id='refs'>
  842. <head>References</head>
  843. <blist>
  844. <bibl id='URNs' key='RFC2141'>
  845. IETF (Internet Engineering Task Force)
  846. <emph>RFC 2141: URN Syntax</emph>, ed. R. Moats. May 1997.
  847. </bibl>
  848. <bibl id='URIRef' key='RFC2396'>
  849. IETF (Internet Engineering Task Force)
  850. <emph>RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax</emph>, eds. 
  851. T. Berners-Lee, R. Fielding, L. Masinter.  
  852. August 1998.
  853. </bibl>
  854. <bibl id='XML' key='XML'>
  855. <emph>Extensible Markup Language
  856. (XML) 1.0</emph>, eds. Tim Bray, Jean
  857. Paoli, and C. M.
  858. Sperberg-McQueen.
  859. 10 February 1998. Available at
  860. <loc href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</loc>.
  861. </bibl>
  862. </blist>
  863. </div1>
  864. </back>
  865. </spec>
  866. <!-- Keep this comment at the end of the file
  867. Local variables:
  868. mode: sgml
  869. sgml-default-dtd-file:"~/sgml/spec.ced"
  870. sgml-omittag:t
  871. sgml-shorttag:t
  872. End:
  873. -->
  874.