No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0044.xml 8.0KB

  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM "xep.ent">
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Full Namespace Support for XML Streams</title>
  10. <abstract>A description of the use of namespaces within Jabber.</abstract>
  12. <number>0044</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies/>
  17. <supersedes/>
  18. <supersededby/>
  19. <shortname>N/A</shortname>
  20. <author>
  21. <firstname>Robert</firstname>
  22. <surname>Norris</surname>
  23. <email></email>
  24. <jid></jid>
  25. </author>
  26. <revision>
  27. <version>0.1</version>
  28. <date>2002-08-26</date>
  29. <initials>rn</initials>
  30. <remark>Initial version.</remark>
  31. </revision>
  32. </header>
  33. <section1 topic='Introduction'>
  34. <p>Jabber has traditionally supported a subset of the XML Namespaces specification <note><link url=""></link></note>. The protocol has been restricted to using specific namespace prefixes.</p>
  35. <p>This is convenient for client and server implementors, since they only need to check the element name to determine both the name and the context of the element. However, these restrictions mean that developers are unable to take advantage of some of the features that namespaces provide.</p>
  36. <p>Many developers have expressed an interest in having Jabber fully support namespaces - a desire which is likely to increase as time goes on. This support consists of allowing any namespace prefix to be used with any namespace, and also to allow namespace prefixes to be pre-declared on the stream root.</p>
  37. <p>This document outlines the semantics required for servers and clients to support namespaces fully, and also discusses implementation techniques and methods for providing compatibility with older "fixed-prefix" implementations.</p>
  38. </section1>
  39. <section1 topic='Requirements and Protocol'>
  40. <p>A typical XML stream is a pair of XML documents, one for each direction of communication between the two peers. An simple example of these might look like this:</p>
  41. <example caption="A typical XML stream"><![CDATA[
  42. SEND: <stream:stream xmlns='jabber:client'
  43. xmlns:stream=''
  44. to=''>
  45. RECV: <stream:stream xmlns='jabber:client'
  46. xmlns:stream=''
  47. id='12345678'>
  48. SEND: <iq type='get' to=''>
  49. <query xmlns='jabber:iq:version'/>
  50. </iq>
  51. RECV: <iq type='result' from=''>
  52. <query xmlns='jabber:iq:version'>
  53. <name>jsm</name>
  54. <version>1.4.2</version>
  55. <os>Linux 2.4.19</os>
  56. </query>
  57. </iq>]]>
  58. </example>
  59. <p>Note that there may also be additional namespaces specified in the stream header, to select or inform of various server features:</p>
  60. <example caption="A typical XML stream with stream options"><![CDATA[
  61. SEND: <stream:stream xmlns='jabber:client'
  62. xmlns:stream=''
  63. xmlns:sasl=''
  64. to=''>
  65. RECV: <stream:stream xmlns='jabber:client'
  66. xmlns:stream=''
  67. xmlns:sasl=''
  68. id='12345678'>
  69. <sasl:mechanisms>
  70. <sasl:mechanism>PLAIN</sasl:mechanism>
  71. <sasl:mechanism>DIGEST-MD5</sasl:mechanism>
  72. <sasl:mechanism>EXTERNAL</sasl:mechanism>
  73. </sasl:mechanisms>
  74. SEND: <iq type='get' to=''>
  75. <query xmlns='jabber:iq:version'/>
  76. </iq>
  77. RECV: <iq type='result' from=''>
  78. <query xmlns='jabber:iq:version'>
  79. <name>jsm</name>
  80. <version>1.4.2</version>
  81. <os>Linux 2.4.19</os>
  82. </query>
  83. </iq>]]>
  84. </example>
  85. <p>Currently, the prefix for each namespace is fixed; it cannot vary at all, since implementations use it for matching. The desire is to be able to use arbitrary prefixes:</p>
  86. <example caption="XML stream with arbitrary namespace prefixes (1)"><![CDATA[
  87. SEND: <stream xmlns:app='jabber:client'
  88. xmlns=''
  89. to=''>
  90. RECV: <stream xmlns:app='jabber:client'
  91. xmlns=''
  92. id='12345678'>
  93. SEND: <app:iq type='get' to=''>
  94. <query xmlns='jabber:iq:version'/>
  95. </app:iq>
  96. RECV: <app:iq type='result' from=''>
  97. <query xmlns='jabber:iq:version'>
  98. <name>jsm</name>
  99. <version>1.4.2</version>
  100. <os>Linux 2.4.19</os>
  101. </query>
  102. </app:iq>]]>
  103. </example>
  104. <p>Also, since there exist streams in both directions, it should be possible for prefixes to differ between the two streams:</p>
  105. <example caption="XML stream with arbitrary namespace prefixes"><![CDATA[
  106. SEND: <stream xmlns:app='jabber:client'
  107. xmlns=''
  108. to=''>
  109. RECV: <stream:stream xmlns='jabber:client'
  110. xmlns:stream=''
  111. id='12345678'>
  112. SEND: <app:iq type='get' to=''>
  113. <query xmlns='jabber:iq:version'/>
  114. </app:iq>
  115. RECV: <iq type='result' from=''>
  116. <ver:query xmlns:ver='jabber:iq:version'>
  117. <ver:name>jsm</ver:name>
  118. <ver:version>1.4.2</ver:version>
  119. <ver:os>Linux 2.4.19</ver:os>
  120. </ver:query>
  121. </iq>]]>
  122. </example>
  123. <p>Additionally, it should be possible to declare namespaces on the stream header so that they don't need to be declared later:</p>
  124. <example caption="XML stream with namespaces declared in the stream header"><![CDATA[
  125. SEND: <stream:stream xmlns='jabber:client'
  126. xmlns:stream=''
  127. xmlns:ver='jabber:iq:version'
  128. to=''>
  129. RECV: <stream:stream xmlns='jabber:client'
  130. xmlns:stream=''
  131. xmlns:ver='jabber:iq:version'
  132. id='12345678'>
  133. SEND: <iq type='get' to=''>
  134. <ver:query/>
  135. </iq>
  136. RECV: <iq type='result' from=''>
  137. <ver:query>
  138. <ver:name>jsm</ver:name>
  139. <ver:version>1.4.2</ver:version>
  140. <ver:os>Linux 2.4.19</ver:os>
  141. </ver:query>
  142. </iq>]]>
  143. </example>
  144. <p>And of course, any combinations of these should be valid, as long as they conform to the XML Namespaces specification.</p>
  145. </section1>
  146. <section1 topic='Implementation Notes'>
  147. <p>In order to implement namespaces correctly, implementations will need to check both the namespace of an element (or attribute), and its namespace, in order to match it. An implementation will need to maintain some sort of mapping between prefixes and namespaces, though some parsers, such as recent versions of Expat, can do this for the implementor.</p>
  148. <p>Implementations should, wherever possible, adhere to the IETF maxim "be liberal in what you accept, and conservative in what you send". This means accepting any valid namespace prefix, but using only the traditional prefixes (i.e. "stream" for "", "sasl" for "", and no prefix for the application namespace). For servers, this has the added benefit of getting compatibility with non-namespace-aware clients for free.</p>
  149. <p>In server components that may have to forward packets received from one stream to another stream, it may be necessary for the application namespace to be rewritten before the packet is forwarded. Examples of this are client-to-server and server-to-server components, which must convert "jabber:client" and "jabber:server" components, respectively, into "jabber:component:accept" packets before they are forwarded to the router.</p>
  150. </section1>
  151. </xep>