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-0059.xml 30KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561
  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>Result Set Management</title>
  10. <abstract>This specification defines an XMPP protocol extension that enables an entity to page through and otherwise manage the receipt of large result sets. The protocol can be used in the context of any XMPP protocol that might send large result sets (such as service discovery, multi-user chat, and publish-subscribe). While the requesting entity in such an interaction can explicitly request the use of result set management, an indication that result set management is in use can also be proactively included by the responding entity when returning a limited result set in response to a query.</abstract>
  11. &LEGALNOTICE;
  12. <number>0059</number>
  13. <status>Draft</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <dependencies>
  17. <spec>XMPP Core</spec>
  18. <spec>XMPP IM</spec>
  19. <spec>XEP-0030</spec>
  20. </dependencies>
  21. <supersedes/>
  22. <supersededby/>
  23. <shortname>rsm</shortname>
  24. <schemaloc>
  25. <url>http://www.xmpp.org/schemas/rsm.xsd</url>
  26. </schemaloc>
  27. &ianpaterson;
  28. &stpeter;
  29. &val;
  30. <author>
  31. <firstname>Jean-Louis</firstname>
  32. <surname>Seguineau</surname>
  33. <email>jls@antepo.com</email>
  34. <jid>jlseguineau@im.antepo.com</jid>
  35. </author>
  36. <revision>
  37. <version>1.0</version>
  38. <date>2006-09-20</date>
  39. <initials>psa</initials>
  40. <remark><p>Per a vote of the Jabber Council, advanced status to Draft.</p></remark>
  41. </revision>
  42. <revision>
  43. <version>0.14</version>
  44. <date>2006-09-13</date>
  45. <initials>ip</initials>
  46. <remark><p>Clarified terminology regarding pages and result sets.</p></remark>
  47. </revision>
  48. <revision>
  49. <version>0.13</version>
  50. <date>2006-09-07</date>
  51. <initials>ip/psa</initials>
  52. <remark><p>Reverted to v0.11 with slight wording changes.</p></remark>
  53. </revision>
  54. <revision>
  55. <version>0.12</version>
  56. <date>2006-09-06</date>
  57. <initials>psa/vm</initials>
  58. <remark><p>Added index attribute to before element; removed index element (use after or before instead).</p></remark>
  59. </revision>
  60. <revision>
  61. <version>0.11</version>
  62. <date>2006-08-25</date>
  63. <initials>ip</initials>
  64. <remark><p>Made count and index optional, changed protocol for getting count, more clarifications and examples.</p></remark>
  65. </revision>
  66. <revision>
  67. <version>0.10</version>
  68. <date>2006-08-24</date>
  69. <initials>ip</initials>
  70. <remark><p>Added before and first elements, specified how to return an empty page and how to request the last page, removed reverse order sets, added out-of-order page access.</p></remark>
  71. </revision>
  72. <revision>
  73. <version>0.9</version>
  74. <date>2006-08-23</date>
  75. <initials>ip</initials>
  76. <remark><p>Eliminated static result sets, justified expanded and clarified dynamic result sets, added page-not-found error, described when minimal state is necessary, added reverse order sets.</p></remark>
  77. </revision>
  78. <revision>
  79. <version>0.8</version>
  80. <date>2006-08-22</date>
  81. <initials>psa</initials>
  82. <remark><p>Added optional method for handling dynamic result sets.</p></remark>
  83. </revision>
  84. <revision>
  85. <version>0.7</version>
  86. <date>2006-08-10</date>
  87. <initials>psa</initials>
  88. <remark><p>Updated implementation note to clarify handling of result sets (static vs. dynamic).</p></remark>
  89. </revision>
  90. <revision>
  91. <version>0.6</version>
  92. <date>2006-07-12</date>
  93. <initials>psa</initials>
  94. <remark><p>Updated implementation note to clarify handling of result sets (static vs. dynamic).</p></remark>
  95. </revision>
  96. <revision>
  97. <version>0.5</version>
  98. <date>2006-05-02</date>
  99. <initials>psa</initials>
  100. <remark><p>Clarified error handling, determination of support in the context of using protocols, and security considerations.</p></remark>
  101. </revision>
  102. <revision>
  103. <version>0.4</version>
  104. <date>2006-04-24</date>
  105. <initials>psa</initials>
  106. <remark><p>Specified that an item count may be approximate; specified that an item count may be returned with a page of results.</p></remark>
  107. </revision>
  108. <revision>
  109. <version>0.3</version>
  110. <date>2006-04-21</date>
  111. <initials>psa/vm</initials>
  112. <remark><p>Added &lt;end/&gt; element to specify last result set; added service discovery information; added more examples.</p></remark>
  113. </revision>
  114. <revision>
  115. <version>0.2</version>
  116. <date>2005-12-22</date>
  117. <initials>psa/vm</initials>
  118. <remark><p>Revived and renamed the XEP; modified syntax; added use case for getting number of items; defined XML schema.</p></remark>
  119. </revision>
  120. <revision>
  121. <version>0.1</version>
  122. <date>2002-11-12</date>
  123. <initials>jls</initials>
  124. <remark><p>Initial version.</p></remark>
  125. </revision>
  126. </header>
  127. <section1 topic='Introduction' anchor='intro'>
  128. <p>In &xep0055;, &xep0030;, &xep0060;, &xep0136;, and probably other future XMPP extensions, it is possible to receive large dynamic result sets in response to information requests (e.g., a user directory search on a common first name or a service discovery items request sent to a &xep0045; service). This XMPP protocol extension enables the following functionality for use by other XMPP protocols:</p>
  129. <ol>
  130. <li>Limit the number of items returned.</li>
  131. <li>Page forwards or backwards through a result set by retrieving the items in smaller subsets.</li>
  132. <li>Discover the size of a result set without retrieving the items themselves.</li>
  133. <li>Retrieve a page (subset) of items starting at any point in a result set.</li>
  134. </ol>
  135. </section1>
  136. <section1 topic='Use Cases' anchor='usecases'>
  137. <section2 topic='Limiting the Number of Items' anchor='limit'>
  138. <p>In order to limit the number of items of a result set to be returned, the requesting entity specifies a request type of "set" and the maximum size of the desired subset (via the XML character data of the &lt;max/&gt; element):</p>
  139. <example caption='Requesting a Limit to the Result Set'><![CDATA[
  140. <iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='limit1'>
  141. <query xmlns='jabber:iq:search'>
  142. <nick>Pete</nick>
  143. <set xmlns='http://jabber.org/protocol/rsm'>
  144. <max>10</max>
  145. </set>
  146. </query>
  147. </iq>
  148. ]]></example>
  149. <p>The responding entity then returns the first items of the result set in order. The number of items is limited to the requested size:</p>
  150. <example caption='Returning a Limited Result Set'><![CDATA[
  151. <iq type='result' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='limit1'>
  152. <query xmlns='jabber:iq:search'>
  153. <item jid='stpeter@jabber.org'>
  154. <first>Peter</first>
  155. <last>Saint-Andre</last>
  156. <nick>Pete</nick>
  157. </item>
  158. .
  159. [8 more items]
  160. .
  161. <item jid='peterpan@neverland.lit'>
  162. <first>Peter</first>
  163. <last>Pan</last>
  164. <nick>Pete</nick>
  165. </item>
  166. </query>
  167. </iq>
  168. ]]></example>
  169. </section2>
  170. <section2 topic='Paging Forwards Through a Result Set' anchor='forwards'>
  171. <p>An entity often needs to retrieve a page of items adjacent to a page it has already received. For examples, when retrieving a complete result set in order page by page, or when a user 'scrolls' forwards one page.</p>
  172. <p>The set of items that match a query MAY change over time, even during the time that a requesting entity pages through the result set (e.g., a set of chatrooms, since rooms can be created and destroyed at any time). The paging protocol outlined in this section is designed so that entities MAY provide the following features:</p>
  173. <ul>
  174. <li>Each page of the result set is up-to-date at the time it is sent (not just at the time the first page was sent).</li>
  175. <li>No items will be omitted from pages not yet sent (even if, after earlier pages were sent, some of the items they contained were removed from the set).</li>
  176. <li>When paging through the list in order, duplicate items are never received.</li>
  177. <li>The responding entity maintains no state (or a single minimal state for all requesting entities containing the positions of all recently deleted items).</li>
  178. <li>Rapid calculation of which items should appear on a requested page by responding entity (even for large result sets).</li>
  179. </ul>
  180. <p>Note: If a responding entity implements dynamic result sets then receiving entities paging through the complete result set should be aware that it may not correspond to the result set as it existed at any one point in time.</p>
  181. <p>The request for the first page is the same as when <link url='#limit'>Limiting the Number of Items</link>:</p>
  182. <example caption='Requesting the First Page of a Result Set'><![CDATA[
  183. <iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='page1'>
  184. <query xmlns='jabber:iq:search'>
  185. <nick>Pete</nick>
  186. <set xmlns='http://jabber.org/protocol/rsm'>
  187. <max>10</max>
  188. </set>
  189. </query>
  190. </iq>
  191. ]]></example>
  192. <p>Responding entity support for paging through a result set is optional. If it does support paging (not just <link url='#limit'>Limiting the Number of Items</link>), then in each page it returns, the responding entity MUST include &lt;first/&gt; and &lt;last/&gt; elements that specify the unique ID (UID) for the first and last items in the page. If there is only one item in the page, then the first and last UIDs MUST be the same. If there are no items in the page, then the &lt;first/&gt; and &lt;last/&gt; elements MUST NOT be included.</p>
  193. <p>The responding entity may generate these UIDs in any way, as long as the UIDs are unique in the context of all possible members of the full result set. Each UID MAY be based on part of the content of its associated item, as shown below, or on an internal table index. Another possible method is to serialize the XML of the item and then hash it to generate the UID. Note: The requesting entity MUST treat all UIDs as opaque.</p>
  194. <p>The responding entity SHOULD also include the number of items in the full result set (which MAY be approximate) encapsulated in a &lt;count/&gt; element. The &lt;first/&gt; element SHOULD include an 'index' attribute. This integer specifies the position within the full set (which MAY be approximate) of the first item in the page. If that item is the first in the full set, then the index SHOULD be '0'. If the last item in the page is the last item in the full set, then the value of the &lt;first/&gt; element's 'index' attribute SHOULD be the specified count minus the number of items in the last page.</p>
  195. <p>Note: The &lt;count/&gt; element and 'index' attribute enable important functionality for requesting entities (for example, a scroll-bar user-interface component). They MAY be omitted, but <em>only</em> if it would be either impossible or exceptionally resource intensive to calculate reasonably accurate values.</p>
  196. <example caption='Returning the First Page of a Result Set'><![CDATA[
  197. <iq type='result' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='page1'>
  198. <query xmlns='jabber:iq:search'>
  199. <item jid='stpeter@jabber.org'>
  200. <first>Peter</first>
  201. <last>Saint-Andre</last>
  202. <nick>Pete</nick>
  203. </item>
  204. .
  205. [8 more items]
  206. .
  207. <item jid='peterpan@neverland.lit'>
  208. <first>Peter</first>
  209. <last>Pan</last>
  210. <nick>Pete</nick>
  211. </item>
  212. <set xmlns='http://jabber.org/protocol/rsm'>
  213. <first index='0'>stpeter@jabber.org</first>
  214. <last>peterpan@neverland.lit</last>
  215. <count>800</count>
  216. </set>
  217. </query>
  218. </iq>
  219. ]]></example>
  220. <p>The requesting entity can then ask for the next page in the result set by including in its request the UID of the <em>last</em> item from the previous page (encapsulated in an &lt;after/&gt; element), along with the maximum number of items to return. Note: If no &lt;after/&gt; element is specified, then the UID defaults to "before the first item in the result set" (i.e., effectively an index of negative one).</p>
  221. <example caption='Requesting the Second Page of a Result Set'><![CDATA[
  222. <iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='page2'>
  223. <query xmlns='jabber:iq:search'>
  224. <nick>Pete</nick>
  225. <set xmlns='http://jabber.org/protocol/rsm'>
  226. <max>10</max>
  227. <after>peterpan@neverland.lit</after>
  228. </set>
  229. </query>
  230. </iq>
  231. ]]></example>
  232. <p>The <em>first</em> item in the page returned by the responding entity MUST be the item that immediately <em>follows</em> the item that the requesting entity indicated in the &lt;after/&gt; element:</p>
  233. <example caption='Returning the Second Page of a Result Set'><![CDATA[
  234. <iq type='result' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='page2'>
  235. <query xmlns='jabber:iq:search'>
  236. <item jid='peter@pixyland.org'>
  237. <first>Peter</first>
  238. <last>Pan</last>
  239. <nick>Pete</nick>
  240. </item>
  241. .
  242. [8 more items]
  243. .
  244. <item jid='peter@rabbit.lit'>
  245. <first>Peter</first>
  246. <last>Rabbit</last>
  247. <nick>Pete</nick>
  248. </item>
  249. <set xmlns='http://jabber.org/protocol/rsm'>
  250. <first index='10'>peter@pixyland.org</first>
  251. <last>peter@rabbit.lit</last>
  252. <count>800</count>
  253. </set>
  254. </query>
  255. </iq>
  256. ]]></example>
  257. <p>It may sometimes be necessary to return an empty <em>page</em> to the requesting entity. For example, with dynamic result sets the responding entity MAY delete some items from the full result set between requests. Another example occurs when the requesting entity specifies "0" for the maximum number items to return (see <link url='#count'>Getting the Item Count</link>).</p>
  258. <example caption='Returning an Empty Page'><![CDATA[
  259. <iq type='result' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='page80'>
  260. <query xmlns='jabber:iq:search'>
  261. <set xmlns='http://jabber.org/protocol/rsm'>
  262. <count>790</count>
  263. </set>
  264. </query>
  265. </iq>
  266. ]]></example>
  267. <p>If there are no items whatsoever in the <em>full</em> result set, the responding entity MUST return a response that adheres to the definition of the wrapper protocol (e.g., "jabber:iq:search", "http://jabber.org/protocol/disco#items", or "http://jabber.org/protocol/pubsub"). For both <cite>XEP-0055</cite> and <cite>XEP-0030</cite>, that means the responding entity shall return an empty &QUERY; element; for <cite>XEP-0060</cite>, that means the responding entity shall return an empty &lt;pubsub/&gt; element; for <cite>XEP-0136</cite>, that means the responding entity shall return an empty &lt;list/&gt; or &lt;store/&gt; element.</p>
  268. </section2>
  269. <section2 topic='Paging Backwards Through a Result Set' anchor='backwards'>
  270. <p>The requesting entity MAY ask for the previous page in a result set by including in its request the UID of the <em>first</em> item from the page that has already been received (encapsulated in a &lt;before/&gt; element), along with the maximum number of items to return.</p>
  271. <example caption='Requesting the Previous Page of a Result Set'><![CDATA[
  272. <iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='back1'>
  273. <query xmlns='jabber:iq:search'>
  274. <nick>Pete</nick>
  275. <set xmlns='http://jabber.org/protocol/rsm'>
  276. <max>10</max>
  277. <before>peter@pixyland.org</before>
  278. </set>
  279. </query>
  280. </iq>
  281. ]]></example>
  282. <p>The <em>last</em> item in the page returned by the responding entity MUST be the item that immediately <em>preceeds</em> the item that the requesting entity indicated it has already received:</p>
  283. <example caption='Returning the Previous Page of a Result Set'><![CDATA[
  284. <iq type='result' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='back1'>
  285. <query xmlns='jabber:iq:search'>
  286. <item jid='stpeter@jabber.org'>
  287. <first>Peter</first>
  288. <last>Saint-Andre</last>
  289. <nick>Pete</nick>
  290. </item>
  291. .
  292. [8 more items]
  293. .
  294. <item jid='peterpan@neverland.lit'>
  295. <first>Peter</first>
  296. <last>Pan</last>
  297. <nick>Pete</nick>
  298. </item>
  299. <set xmlns='http://jabber.org/protocol/rsm'>
  300. <first index='0'>stpeter@jabber.org</first>
  301. <last>peterpan@neverland.lit</last>
  302. <count>800</count>
  303. </set>
  304. </query>
  305. </iq>
  306. ]]></example>
  307. </section2>
  308. <section2 topic='Page Not Found' anchor='notfound'>
  309. <p>The responding entity MUST reply with an 'item-not-found' error if <em>all</em> the following circumstances apply:</p>
  310. <ol>
  311. <li><p>The item specified by the requesting entity via the UID in the &lt;after/&gt; or &lt;before/&gt; element no longer exists (it was deleted after the previous page was sent).</p></li>
  312. <li><p>The UID itself cannot be used to derive directly the next item within the set (e.g. the alphabetical or numerical order of the UIDs do not specify the order of the items).</p></li>
  313. <li><p>The responding entity does not remember the position of the deleted item within the full list. (Even if the responding entity bothers to remember the position of each deleted item, it will typically be necessary to expire that 'state' after an implementation-specific period of time.)</p></li>
  314. </ol>
  315. <example caption='Returning a Page-Not-Found Error'><![CDATA[
  316. <iq type='error' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='page2'>
  317. <query xmlns='jabber:iq:search'>
  318. <nick>Pete</nick>
  319. <set xmlns='http://jabber.org/protocol/rsm'>
  320. <max>10</max>
  321. <after>peterpan@neverland.lit</after>
  322. </set>
  323. </query>
  324. <error type='cancel'>
  325. <item-not-found xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  326. </error>
  327. </iq>
  328. ]]></example>
  329. </section2>
  330. <section2 topic='Requesting the Last Page in a Result Set' anchor='last'>
  331. <p>The requesting entity MAY ask for the last page in a result set by including in its request an empty &lt;before/&gt; element, and the maximum number of items to return.</p>
  332. <example caption='Requesting the Last Page of a Result Set'><![CDATA[
  333. <iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='page1'>
  334. <query xmlns='jabber:iq:search'>
  335. <nick>Pete</nick>
  336. <set xmlns='http://jabber.org/protocol/rsm'>
  337. <max>10</max>
  338. <before/>
  339. </set>
  340. </query>
  341. </iq>
  342. ]]></example>
  343. </section2>
  344. <section2 topic='Retrieving a Page Out of Order' anchor='jump'>
  345. <p>The requesting entity MAY choose not to retrieve pages from the result set in order. (For example, when its user drags a user-interface slider to a radically new position within a very large result set.)</p>
  346. <p>Only if the UID before the start (or after the end) of a desired result set page is not known, then the requesting entity MAY request the page that <em>starts</em> at a particular index within the result set. It does that by including in its request the index of the <em>first</em> item to be returned (encapsulated in an &lt;index/&gt; element), as well as the maximum number of items to return. Note: For reasons mentioned in <link url='#forwards'>Paging Forwards Through a Result Set</link> requesting entities SHOULD, where possible, specify pages using a UID instead of an index.</p>
  347. <p>Note: If the responding entity omitted the &lt;count/&gt; element from previous responses for this result set, then the requesting entity SHOULD assume that the responding entity does not support page retrieval by index for this result set (see error below).</p>
  348. <example caption='Requesting a Result Page by Index'><![CDATA[
  349. <iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='index10'>
  350. <query xmlns='jabber:iq:search'>
  351. <nick>Pete</nick>
  352. <set xmlns='http://jabber.org/protocol/rsm'>
  353. <max>10</max>
  354. <index>371</index>
  355. </set>
  356. </query>
  357. </iq>
  358. ]]></example>
  359. <p>The responding entity SHOULD derive the first UID from the specified index (the method used MAY be approximate) before returning the requested result set page in the normal way. If the specified index was "0" then the responding entity SHOULD derive the UID that is the first in the full result set.</p>
  360. <p>Note: The 'index' attribute of the &lt;first/&gt; element MUST be the same as the index specified in the request. If the index specified by the requesting entity is greater than or equal to the number of items in the full set then the responding entity MUST return an empty page (see <link url='#forwards'>Paging Forwards Through a Result Set</link>).</p>
  361. <example caption='Returning a Result Page at an Index'><![CDATA[
  362. <iq type='result' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='index10'>
  363. <query xmlns='jabber:iq:search'>
  364. <item jid='peter@pixyland.org'>
  365. <first>Peter</first>
  366. <last>Pan</last>
  367. <nick>Pete</nick>
  368. </item>
  369. .
  370. [8 more items]
  371. .
  372. <item jid='peter@rabbit.lit'>
  373. <first>Peter</first>
  374. <last>Rabbit</last>
  375. <nick>Pete</nick>
  376. </item>
  377. <set xmlns='http://jabber.org/protocol/rsm'>
  378. <first index='371'>peter@pixyland.org</first>
  379. <last>peter@rabbit.lit</last>
  380. <count>800</count>
  381. </set>
  382. </query>
  383. </iq>
  384. ]]></example>
  385. <p>If it would be either impossible or exceptionally resource intensive for the responding entity to derive the first UID from the specified index with reasonable accuracy then the responding entity MAY return a &e501; error.</p>
  386. <example caption='Returning a Feature-not-Implemented Error'><![CDATA[
  387. <iq type='error' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='index10'>
  388. <query xmlns='jabber:iq:search'>
  389. <nick>Pete</nick>
  390. <set xmlns='http://jabber.org/protocol/rsm'>
  391. <max>10</max>
  392. <index>371</index>
  393. </set>
  394. </query>
  395. <error type='cancel'>
  396. <feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>
  397. </error>
  398. </iq>
  399. ]]></example>
  400. </section2>
  401. <section2 topic='Getting the Item Count' anchor='count'>
  402. <p>In order to get the item count of a result set without retrieving the items themselves, the requesting entity simply specifies zero for the maximum size of the result set page:</p>
  403. <example caption='Requesting the Item Count'><![CDATA[
  404. <iq type='set' from='stpeter@jabber.org/roundabout' to='users.jabber.org' id='count1'>
  405. <query xmlns='jabber:iq:search'>
  406. <nick>Pete</nick>
  407. <set xmlns='http://jabber.org/protocol/rsm'>
  408. <max>0</max>
  409. </set>
  410. </query>
  411. </iq>
  412. ]]></example>
  413. <p>The responding entity then returns the item count, which MAY be approximate rather than precise if determining the exact number of items would be resource-intensive:</p>
  414. <example caption='Returning the Item Count'><![CDATA[
  415. <iq type='result' from='users.jabber.org' to='stpeter@jabber.org/roundabout' id='count1'>
  416. <query xmlns='jabber:iq:search'>
  417. <set xmlns='http://jabber.org/protocol/rsm'>
  418. <count>800</count>
  419. </set>
  420. </query>
  421. </iq>
  422. ]]></example>
  423. <p>Note: The &lt;count/&gt; element MAY be omitted, but <em>only</em> if it would be either impossible or exceptionally resource intensive to calculate reasonably accurate values.</p>
  424. <p>Note: If there are no items in the <em>full</em> result set then the responding entity MUST return a response that adheres to the definition of the wrapper protocol (see <link url='#forwards'>Paging Forwards Through a Result Set</link>).</p>
  425. </section2>
  426. </section1>
  427. <section1 topic='Examples' anchor='examples'>
  428. <p>The foregoing examples show the use of result set management in the context of <cite>Jabber Search</cite>. In the following examples we show the use of this protocol in the context of <cite>Service Discovery</cite>. <cite>XEP-0136</cite> ("Message Archiving") includes more examples. A future version of this document may also include examples from <cite>Publish-Subscribe</cite> and other XMPP protocol extensions.</p>
  429. <example caption='Requesting a Limit to the Result Set'><![CDATA[
  430. <iq type='get' from='stpeter@jabber.org/roundabout' to='conference.jabber.org' id='ex2'>
  431. <query xmlns='http://jabber.org/protocol/disco#items'>
  432. <set xmlns='http://jabber.org/protocol/rsm'>
  433. <max>20</max>
  434. </set>
  435. </query>
  436. </iq>
  437. ]]></example>
  438. <example caption='Returning a Limited Result Set'><![CDATA[
  439. <iq type='result' from='conference.jabber.org' to='stpeter@jabber.org/roundabout' id='ex2'>
  440. <query xmlns='http://jabber.org/protocol/disco#items'>
  441. <item jid='12@conference.jabber.org'/>
  442. <item jid='adium@conference.jabber.org'/>
  443. <item jid='airhitch@conference.jabber.org'/>
  444. <item jid='alphaville@conference.jabber.org'/>
  445. <item jid='apache@conference.jabber.org'/>
  446. <item jid='argia@conference.jabber.org'/>
  447. <item jid='armagetron@conference.jabber.org'/>
  448. <item jid='atticroom123@conference.jabber.org'/>
  449. <item jid='banquise@conference.jabber.org'/>
  450. <item jid='bar_paradise@conference.jabber.org'/>
  451. <item jid='beer@conference.jabber.org'/>
  452. <item jid='blondie@conference.jabber.org'/>
  453. <item jid='bpnops@conference.jabber.org'/>
  454. <item jid='brasileiros@conference.jabber.org'/>
  455. <item jid='bulgaria@conference.jabber.org'/>
  456. <item jid='cantinalivre@conference.jabber.org'/>
  457. <item jid='casablanca@conference.jabber.org'/>
  458. <item jid='chinortpcrew@conference.jabber.org'/>
  459. <item jid='coffeetalk@conference.jabber.org'/>
  460. <item jid='council@conference.jabber.org'/>
  461. <set xmlns='http://jabber.org/protocol/rsm'>
  462. <first index='0'>acc3594e844c77696f7a7ba9367ae324b6b958ad</first>
  463. <last>4da91d4b330112f683dddaebf93180b1bd25e95f</last>
  464. <count>150</count>
  465. </set>
  466. </query>
  467. </iq>
  468. ]]></example>
  469. <example caption='Requesting a Page Beginning After the Last Item Received'><![CDATA[
  470. <iq type='set' from='stpeter@jabber.org/roundabout' to='conference.jabber.org' id='ex3'>
  471. <query xmlns='http://jabber.org/protocol/disco#items'>
  472. <set xmlns='http://jabber.org/protocol/rsm'>
  473. <max>20</max>
  474. <after>4da91d4b330112f683dddaebf93180b1bd25e95f</after>
  475. </set>
  476. </query>
  477. </iq>
  478. ]]></example>
  479. </section1>
  480. <section1 topic='Determining Support' anchor='support'>
  481. <p>In order for a requesting entity to determine if a responding entity supports result set management, it SHOULD send a <cite>Service Discovery</cite> information request to the responding entity:</p>
  482. <example caption='Requesting entity queries responding entity regarding protocol support'><![CDATA[
  483. <iq from='stpeter@jabber.org/roundabout'
  484. to='conference.jabber.org'
  485. type='get'
  486. id='disco1'>
  487. <query xmlns='http://jabber.org/protocol/disco#info'/>
  488. </iq>
  489. ]]></example>
  490. <example caption='Responding entity communicates protocol support'><![CDATA[
  491. <iq from='conference.jabber.org'
  492. to='stpeter@jabber.org/roundabout'
  493. type='result'
  494. id='disco1'>
  495. <query xmlns='http://jabber.org/protocol/disco#info'>
  496. <feature var='http://jabber.org/protocol/rsm'/>
  497. </query>
  498. </iq>
  499. ]]></example>
  500. <p>An entity SHOULD NOT include the result set management extensions defined in this document in its requests if it does not have positive knowledge that the responding entity supports the protocol defined herein. If the responding entity does not understand result set management, it MUST ignore such extensions.</p>
  501. <p>Note: Even if a responding entity understands the result set management protocol, its support for result set management in the context of any given "using protocol" is OPTIONAL (e.g., an implementation could support it in the context of the 'jabber:iq:search' namespace but not in the context of the 'http://jabber.org/protocol/disco#items' namespace). Currently the only way for a requesting entity to determine if a responding entity supports result set management in the context of a given "using protocol" is to include result set management extensions in its request. If the responding entity does not include result set management extensions in its response, then the requesting entity SHOULD NOT include such extensions in future requests wrapped by the "using protocol" namespace.</p>
  502. </section1>
  503. <section1 topic='Security Considerations' anchor='security'>
  504. <p>Security considerations are the responsibility of the using ("wrapper") protocol, such as <cite>XEP-0030</cite> for the 'http://jabber.org/protocol/disco#items' namespace, <cite>XEP-0055</cite> for the 'jabber:iq:search' namespace, and <cite>XEP-0136</cite> for the 'http://jabber.org/protocol/archive' namespace.</p>
  505. </section1>
  506. <section1 topic='IANA Considerations' anchor='iana'>
  507. <p>This document requires no interaction with &IANA;.</p>
  508. </section1>
  509. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  510. <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
  511. <p>The &REGISTRAR; includes 'http://jabber.org/protocol/rsm' in its registry of protocol namespaces.</p>
  512. </section2>
  513. </section1>
  514. <section1 topic='XML Schema' anchor='schema'>
  515. <code><![CDATA[
  516. <?xml version='1.0' encoding='UTF-8'?>
  517. <xs:schema
  518. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  519. targetNamespace='http://jabber.org/protocol/rsm'
  520. xmlns='http://jabber.org/protocol/rsm'
  521. elementFormDefault='qualified'>
  522. <xs:annotation>
  523. <xs:documentation>
  524. The protocol documented by this schema is defined in
  525. XEP-0059: http://www.xmpp.org/extensions/xep-0059.html
  526. </xs:documentation>
  527. </xs:annotation>
  528. <xs:element name='set'>
  529. <xs:complexType>
  530. <xs:sequence>
  531. <xs:element name='after' type='xs:string' minOccurs='0' maxOccurs='1'/>
  532. <xs:element name='before' type='xs:string' minOccurs='0' maxOccurs='1'/>
  533. <xs:element name='count' type='xs:int' minOccurs='0' maxOccurs='1'/>
  534. <xs:element ref='first' minOccurs='0' maxOccurs='1'/>
  535. <xs:element name='index' type='xs:int' minOccurs='0' maxOccurs='1'/>
  536. <xs:element name='last' type='xs:string' minOccurs='0' maxOccurs='1'/>
  537. <xs:element name='max' type='xs:int' minOccurs='0' maxOccurs='1'/>
  538. </xs:sequence>
  539. </xs:complexType>
  540. </xs:element>
  541. <xs:element name='first'>
  542. <xs:complexType>
  543. <xs:simpleContent>
  544. <xs:extension base='xs:string'>
  545. <xs:attribute name='index' type='xs:int' use='optional'/>
  546. </xs:extension>
  547. </xs:simpleContent>
  548. </xs:complexType>
  549. </xs:element>
  550. </xs:schema>
  551. ]]></code>
  552. </section1>
  553. <section1 topic='Acknowledgements' anchor='ack'>
  554. <p>Thanks to Olivier Goffart, Jon Perlow, and Andrew Plotkin for their feedback.</p>
  555. </section1>
  556. </xep>