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-0284.xml 44KB

  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>Shared XML Editing</title>
  10. <abstract>This specification defines a protocol that enables two or more endpoints to collaboratively edit an XML object. The protocol is intended for use mainly over the Extensible Messaging and Presence Protocol (XMPP), either by existing instant messaging clients or by specialized editing clients. However, the protocol could also be used over a direct TCP connection rather than over XMPP.</abstract>
  12. <number>0284</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XMPP IM</spec>
  20. </dependencies>
  21. <supersedes/>
  22. <supersededby/>
  23. <shortname>NOT YET ASSIGNED</shortname>
  24. <author>
  25. <firstname>Joonas</firstname>
  26. <surname>Govenius</surname>
  27. <email></email>
  28. <jid></jid>
  29. </author>
  30. &stpeter;
  31. <author>
  32. <firstname>Tom</firstname>
  33. <surname>Pusateri</surname>
  34. <email></email>
  35. </author>
  36. <revision>
  37. <version>0.1</version>
  38. <date>2010-07-02</date>
  39. <initials>psa</initials>
  40. <remark><p>Initial published version.</p></remark>
  41. </revision>
  42. <revision>
  43. <version>0.0.10</version>
  44. <date>2010-06-08</date>
  45. <initials>tp/psa</initials>
  46. <remark><p>Updated Jingle namespaces, transport definitions, reason codes, and other syntax; improved feature discovery and session advertisement; updated namespace to be urn:xmpp:sxe:0 for future-compatibility.</p></remark>
  47. </revision>
  48. <revision>
  49. <version>0.0.9</version>
  50. <date>2009-12-04</date>
  51. <initials>psa</initials>
  52. <remark><p>Added session signalling via presence.</p></remark>
  53. </revision>
  54. <revision>
  55. <version>0.0.8</version>
  56. <date>2008-01-29</date>
  57. <initials>psa/jg</initials>
  58. <remark>
  59. <ul>
  60. <li>Modified negotiation protocol to use Jingle.</li>
  61. <li>Defined Jingle transport method.</li>
  62. </ul>
  63. </remark>
  64. </revision>
  65. <revision>
  66. <version>0.0.7</version>
  67. <date>2008-01-24</date>
  68. <initials>jg</initials>
  69. <remark>
  70. <ul>
  71. <li>Added the "Example Session" section.</li>
  72. <li>Clarification of the 'last-sender' and 'last-id' attributes.</li>
  73. <li>Changed the definition of the "state".</li>
  74. <li>Changed "SHOULD [abort the negotiation with others who offered the state]" to a "MUST" after one offer has been accepted.</li>
  75. </ul>
  76. </remark>
  77. </revision>
  78. <revision>
  79. <version>0.0.6</version>
  80. <date>2008-01-20</date>
  81. <initials>jg</initials>
  82. <remark>
  83. <ul>
  84. <li>Wording changes.</li>
  85. <li>Added a paragraph about "maintaining an unordered set of records" to the introduction.</li>
  86. <li>Renamed "node id" to "record id".</li>
  87. <li>Renamed "metadata" to "record".</li>
  88. <li>Renamed &lt;configure/&gt; to &lt;set/&gt;.</li>
  89. <li>Renamed "node edits" to non-commutative edits.</li>
  90. <li>Simplified the explanation of processing edits by creating a section "Mapping the Records to the DOM Document" and concentrating on the changes to the records in section "Commutative and Non-commutative edits".</li>
  91. <li>Added the description of the &lt;prolog/&gt; element.</li>
  92. <li>Replaced the &lt;last-sxde/&gt; element with 'last-sender' and 'last-id' attributes.</li>
  93. <li>Added the 'replacefrom' and 'replacen' attributes.</li>
  94. <li>Replaced the &lt;in-session/&gt; element with the &lt;alternative-session/&gt; element.</li>
  95. </ul>
  96. </remark>
  97. </revision>
  98. <revision>
  99. <version>0.0.5</version>
  100. <date>2007-08-30</date>
  101. <initials>jg</initials>
  102. <remark>
  103. <ul>
  104. <li>Renamed 'z' to 'weight'.</li>
  105. <li>Moved the metadata (node id, primary-weight) out of the DOM. I.e. they are no longer attributes of elements; it is up to the implementation to how the metadata is stored.</li>
  106. <li>Changed "element edits" to "node edits". Now each DOM node is required to have a GUID and can be modified separately. All nodes are arranged by their weight which removes the previous problems with mixed content.</li>
  107. <li>Modified the examples accordingly.</li>
  108. <li>Improved the glossary definitions.</li>
  109. </ul>
  110. </remark>
  111. </revision>
  112. <revision>
  113. <version>0.0.4</version>
  114. <date>2007-03-26</date>
  115. <initials>jg</initials>
  116. <remark><p>Wording changes. Changes to how set content/move element conflict is handled.</p></remark>
  117. </revision>
  118. <revision>
  119. <version>0.0.3</version>
  120. <date>2007-01-09</date>
  121. <initials>jg</initials>
  122. <remark>
  123. <ul>
  124. <li>Simplified the process for joining a session. Removed the notion of history being different from state in the context of joining.</li>
  125. <li>Moved responsibility of undoing other users' conflicting edits to the server if one exists.</li>
  126. <li>Added "XML Document Requirements" section.</li>
  127. <li>Added that changes should be checked against the XSD of the document.</li>
  128. <li>Renamed 'hash' attribute as 'id'.</li>
  129. <li>Changed the format of the &lt;feature/&gt; elements.</li>
  130. <li>Modified negotiation abortion reason.</li>
  131. <li>Removed the XSD for now.</li>
  132. <li>Removed the "Security Considerations" for now.</li>
  133. <li>JEP to XEP.</li>
  134. </ul>
  135. </remark>
  136. </revision>
  137. <revision>
  138. <version>0.0.2</version>
  139. <date>2006-08-28</date>
  140. <initials>jg</initials>
  141. <remark><p>Initial version of the SXdE proposal after splitting the previous whiteboarding proposal.</p></remark>
  142. </revision>
  143. <revision>
  144. <version>0.0.1</version>
  145. <date>2006-06-19</date>
  146. <initials>jg</initials>
  147. <remark><p>Initial version.</p></remark>
  148. </revision>
  149. </header>
  150. <section1 topic='Introduction' anchor='intro'>
  151. <p>This specification defines a protocol for collaboratively editing XML data. Essentially, this protocol provides a simple way of synchronizing an unordered set of records across several endpoints. Additionally, this protocol defines a mapping between such a set of records and the Document Object Model (DOM).</p>
  152. <p>A special feature of this protocol compared to most other collaborative editing tools is that no master or server entity is required. A &xep0045; component or specialized editing component can be used for sessions that have a large number of participants, that need to be persistent, or that require more granular access control. However, the client implementation is minimally different whether such a specialized component is used or whether the session is one-to-one or multi-user.</p>
  153. </section1>
  154. <section1 topic='Requirements' anchor='reqs'>
  155. <p>Requirements for shared editing are provided in &xep0228;.</p>
  156. </section1>
  157. <section1 topic='Glossary' anchor='glossary'>
  158. <p>GUID: a Globally Unique Indentifier, used as the identifier for a shared editing session.</p>
  159. <p>Host: The JID to which the SXE messages are sent for relaying to other members of the session; this can be the initiator of the session (e.g., in a one-to-one session or small multi-user session) or a multi-user chat room or specialized shared editing component.</p>
  160. <p>RID: the Record ID given to a record when it is created.</p>
  161. <p>State: In the context of a new user joining, the state refers to the set of records that describes the edited object, including all previous versions of each record. All entities involved in the session are REQUIRED to keep this state unless a specialized component handles user joins.</p>
  162. <p>Weight: Primarily, the weight of a node is represented by the 'primary-weight' field of the corresponding record. Secondarily, if the values of the 'primary-weight' of two records are equal, the first differing characters of the rids are compared by their Unicode values. The higher the character the higher the weight of the node is.</p>
  163. </section1>
  164. <section1 topic='Session Management' anchor='jingle'>
  165. <p>When used in the context of XMPP, Shared XML Editing relies on &xep0166; for overall session management. In Jingle terms, SXE defines a "transport method" that can be used for multiple "application types" such as XHTML documents, SVG whiteboards, &xep0204;, or any other XML data format.</p>
  166. <section2 topic='Initiation' anchor='jingle-initiate'>
  167. <p>In order to initiate a shared editing session, one party sends a Jingle session-initiate request to another party. Here the &lt;transport/&gt; element indicates support for exchanging SXE information over XMPP and the &lt;description/&gt; element indicates support for editing of XHTML documents (this application type has not been defined yet and is used here only as an example). The &lt;transport/&gt; element MUST include at least one &lt;host/&gt; element that specifies the entity that serves as the host for the session. The host can be the initiator of the session (and must be for a one-to-one session) or a multi-user chat room or specialized reflector where the session is hosted.</p>
  168. <example caption="Initiator sends session-initiate"><![CDATA[
  169. <iq from='kingclaudius@shakespeare.lit/castle'
  170. id='jingle1'
  171. to='laertes@shakespeare.lit/castle'
  172. type='set'>
  173. <jingle xmlns='urn:xmpp:jingle:1'
  174. action='session-initiate'
  175. initiator='kingclaudius@shakespeare.lit/castle'
  176. sid='851ba2'>
  177. <content creator='initiator' name='this-is-the-editing-content'>
  178. <description xmlns='urn:xmpp:jingle:apps:xhtml'/>
  179. <transport xmlns='urn:xmpp:jingle:transports:sxe'>
  180. <host>kingclaudius@shakespeare.lit</host>
  181. </transport>
  182. </content>
  183. </jingle>
  184. </iq>
  185. ]]></example>
  186. <p>The responder immediately acknowledges receipt of the session-initiate.</p>
  187. <example caption="Responder acknowledges session-initiate"><![CDATA[
  188. <iq from='laertes@shakespeare.lit/castle'
  189. id='jingle1'
  190. to='kingclaudius@shakespeare.lit/castle'
  191. type='result'/>
  192. ]]></example>
  193. </section2>
  194. <section2 topic='Session Acceptance' anchor='jingle-accept'>
  195. <p>In order to definitively accept the session, the responder sends a session-accept to the initiator.</p>
  196. <example caption="Responder sends session-accept"><![CDATA[
  197. <iq from='laertes@shakespeare.lit/castle'
  198. id='jingle2'
  199. to='kingclaudius@shakespeare.lit/castle'
  200. type='set'>
  201. <jingle xmlns='urn:xmpp:jingle:1'
  202. action='session-accept'
  203. initiator='kingclaudius@shakespeare.lit/castle'
  204. sid='851ba2'>
  205. <content creator='initiator' name='this-is-the-editing-content'>
  206. <description xmlns='urn:xmpp:jingle:apps:xhtml'/>
  207. <transport xmlns='urn:xmpp:jingle:transports:sxe'>
  208. <host>kingclaudius@shakespeare.lit</host>
  209. </transport>
  210. </content>
  211. </jingle>
  212. </iq>
  213. ]]></example>
  214. <p>The initiator immediately acknowledges receipt of the session-accept.</p>
  215. <example caption="Initiator acknowledges session-accept"><![CDATA[
  216. <iq from='kingclaudius@shakespeare.lit/castle'
  217. id='jingle2'
  218. to='laertes@shakespeare.lit/castle'
  219. type='result'/>
  220. ]]></example>
  221. </section2>
  222. <section2 topic='Session Refusal' anchor='jingle-decline'>
  223. <p>In order to decline the session, the responder sends a session-terminate to the initiator.</p>
  224. <example caption="Responder sends session-terminate"><![CDATA[
  225. <iq from='laertes@shakespeare.lit/castle'
  226. id='jingle3'
  227. to='kingclaudius@shakespeare.lit/castle'
  228. type='set'>
  229. <jingle xmlns='urn:xmpp:jingle:1'
  230. action='session-terminate'
  231. host='chamber@conference.shakespeare.lit'
  232. initiator='kingclaudius@shakespeare.lit/castle'
  233. sid='851ba2'>
  234. <reason>
  235. <unsupported-applications/>
  236. </reason>
  237. </jingle>
  238. </iq>
  239. ]]></example>
  240. <p>The responder indiciates the reason for refusing the session by including a "reason" element. The following reasons are suggested (see also <cite>XEP-0166</cite>):</p>
  241. <ul>
  242. <li>alternative-session -- the responder already has an active session with the initiator and wishes to use that session instead.</li>
  243. <li>decline -- the responder formally declines the session.</li>
  244. <li>unsupported-applications -- the responder supports none of the offered the application types.</li>
  245. </ul>
  246. <p>The initiator immediately acknowledges receipt of the session-terminate.</p>
  247. <example caption="Initiator acknowledges session-terminate"><![CDATA[
  248. <iq from='kingclaudius@shakespeare.lit/castle'
  249. id='jingle3'
  250. to='laertes@shakespeare.lit/castle'
  251. type='result'/>
  252. ]]></example>
  253. </section2>
  254. </section1>
  255. <section1 topic='Determining the features of the Host' anchor='host'>
  256. <p>Before connecting to a session, a party MUST determine the &xep0030; identity and supported features of the host. In many situations the party already knows this information (e.g., if the host is the initiator of the Jingle session). In other situations the party will need to send a service discovery information request to the host.</p>
  257. <example caption='Service Discovery Request'><![CDATA[
  258. <iq from='laertes@shakespeare.lit/castle'
  259. to='kingclaudius@shakespeare.lit/castle'
  260. id='disco1'>
  261. type='get'>
  262. <query xmlns=''/>
  263. </iq>
  264. ]]></example>
  265. <p>If the host supports Shared XML Editing over XMPP, it MUST return features of "urn:xmpp:sxe:0" and "urn:xmpp:jingle:transports:sxe" &NSNOTE;:</p>
  266. <example caption='Service discovery response'><![CDATA[
  267. <iq from='laertes@shakespeare.lit/castle' to='kingclaudius@shakespeare.lit/castle' type='result' id='disco1'>
  268. <query xmlns=''>
  269. <identity category='client' type='pc'/>
  270. ...
  271. <feature var='urn:xmpp:sxe:0'/>
  272. <feature var='urn:xmpp:jingle:transports:sxe'/>
  273. ...
  274. </query>
  275. </iq>
  276. ]]></example>
  277. </section1>
  278. <section1 topic='Advertising a Session' anchor='advertise'>
  279. <p>An entity that is engaged in a session can advertise that fact by including the session id and descriptive name in its XMPP presence.</p>
  280. <example caption='Advertising a session'><![CDATA[
  281. <presence from='laertes@shakespeare.lit/castle'>
  282. <sxe xmlns='urn:xmpp:sxe:0' session='851ba2' name='Marketing Materials'/>
  283. </presence>
  284. ]]></example>
  285. <p>Such presence can be broadcast or can be sent in the context of a multi-user chat room (see <cite>XEP-0045</cite>).</p>
  286. <p>However, presence is not sent when operating in a serverless messaging environment (see <cite>XEP-0174</cite>). Instead, DNS TXT records are published. Two new key-value pairs are used to advertise a session id ("sxe_id") and session name ("sxe_name") when using serverless messaging.</p>
  287. </section1>
  288. <section1 topic='Connecting to a Session' anchor='connect'>
  289. <p>In order to synchronize its local state with the existing state of the edited object, an entity sends a connection request to the host. The identity learned through service discovery determines what kind of message the joining party sends (e.g., type='groupchat' if the host is a MUC room).</p>
  290. <p>To connect to a session, the joiner MUST send an SXE &lt;connect/&gt; element to the host.</p>
  291. <example caption='Connecting to a session'><![CDATA[
  292. <message
  293. from='laertes@shakespeare.lit/castle'
  294. to='kingclaudius@shakespeare.lit/castle'>
  295. <sxe xmlns='urn:xmpp:sxe:0' id='e' session='851ba2'>
  296. <connect/>
  297. </sxe>
  298. </message>
  299. ]]></example>
  300. </section1>
  301. <section1 topic='Initial State Synchronization'>
  302. <section2 topic='Making a State Offer'>
  303. <p>When a joining user sends a connect request, the joiner must retrieve the state of the session from an existing participant. The following ruules apply:</p>
  304. <ol>
  305. <li>In a one-to-one session, the initiator MUST offer to send the state.</li>
  306. <li>In a multi-user session, both the host and the invitor (initiator) MUST offer to send the state. However, other participants MAY offer to send the state. The joiner SHOULD prefer to receive the state from the host or initiator.</li>
  307. </ol>
  308. <p>The state offer MUST contain the &lt;description/&gt; element or elements that were included in the Jingle session-initiate request.</p>
  309. <example caption='A state offer'><![CDATA[
  310. <message
  311. from='kingclaudius@shakespeare.lit/castle'
  312. to='laertes@shakespeare.lit/castle'>
  313. <sxe xmlns='urn:xmpp:sxe:0'
  314. session='851ba2'
  315. id='f'>
  316. <state-offer>
  317. <description xmlns='urn:xmpp:jingle:apps:xhtml'/>
  318. </state-offer>
  319. </sxe>
  320. </message>
  321. ]]></example>
  322. </section2>
  323. <section2 topic='Accepting a State Offer'>
  324. <p>The joiner accepts a state offer by sending an &lt;accept-state/&gt; element to one of the entities that offer to send the state. The joiner MUST store all the &lt;sxe/&gt; elements it receives after the &lt;state-offer/&gt; element it decides to accept. It MUST also abort the negotiation with the other users that offered to send the state.</p>
  325. <p>Once the other entity receives the &lt;accept-state/&gt; element it MUST proceed sending the state as described in the next section.</p>
  326. <example caption='Accepting a state offer'><![CDATA[
  327. <message
  328. from='laertes@shakespeare.lit/castle'
  329. to='kingclaudius@shakespeare.lit/castle'>
  330. <sxe xmlns='urn:xmpp:sxe:0'
  331. session='851ba2'
  332. id='g'>
  333. <accept-state/>
  334. </sxe>
  335. </message>
  336. ]]></example>
  337. </section2>
  338. <section2 topic='Refusing a State Offer'>
  339. <p>If a multiple state offers were received, one should be accepted and the others should be refused by sending a &lt;refuse-state/&gt; element.</p>
  340. <example caption='Refusing a state offer'><![CDATA[
  341. <message
  342. from='laertes@shakespeare.lit/castle'
  343. to='kingclaudius@shakespeare.lit/castle'>
  344. <sxe xmlns='urn:xmpp:sxe:0'
  345. session='851ba2'
  346. id='g'>
  347. <refuse-state/>
  348. </sxe>
  349. </message>
  350. ]]></example>
  351. </section2>
  352. <section2 topic='Sending the State of the Document' >
  353. <p>The process of sending the state is following:</p>
  354. <ol>
  355. <li>The sender sends a &lt;document-begin/&gt; element and simultaneously takes a "snapshot" of the document's state. The &lt;document-begin/&gt; element SHOULD have a 'prolog' attribute. The 'prolog' attribute should contain the XML prolog of the document encoded using the data: URI scheme (RFC 2397).</li>
  356. <li>The sender sends the state as it was at the time of sending &lt;document-begin/&gt;.</li>
  357. <li>The sender sends a &lt;document-end/&gt; element.</li>
  358. </ol>
  359. <p>The state can be sent in any number of &lt;sxe/&gt; elements but the user sending the state MUST NOT send any new &lt;sxe/&gt; elements between sending the &lt;document-begin/&gt; (i.e. taking the snapshot) and the &lt;document-end/&gt; element.</p>
  360. <p>The state SHOULD include a version of each element that was synchronized, and hence won't be undone, as well as all the later versions. In practice this can often be impossible to know in a session without a specialized MUC component so it may be safest to send version 0 and all the later edits to each element. Version 0 is implied if the version element is missing.</p>
  361. <example caption='Sending the state of a blank document (only prolog)'><![CDATA[
  362. <message
  363. from='kingclaudius@shakespeare.lit/castle'
  364. to='laertes@shakespeare.lit/castle'>
  365. <sxe xmlns='urn:xmpp:sxe:0'
  366. session='851ba2'
  367. id='b'>
  368. <state>
  369. <document-begin
  370. prolog='data:text/xml,%3C%3Fxml%20version%3D%271.\
  371. 0%27%20standalone%3D%27no%27%3F%3E%0A%3C%21DOCTYPE%20svg%\
  372. 20PUBLIC%20%27-%2F%2FW3C%2F%2FDTD%20SVG%201.1%2F%2FEN%27%\
  374. %2Fsvg11.dtd%27%3E%0A'/>
  375. <document-end last-sender='' last-id='' />
  376. </state>
  377. </sxe>
  378. </message>
  379. ]]></example>
  380. <p>If the session is already in progress, the entity sends the snapshot.</p>
  381. <example caption='Sending the state of an existing document'><![CDATA[
  382. <message
  383. from='kingclaudius@shakespeare.lit/castle'
  384. to='laertes@shakespeare.lit/castle'>
  385. <sxe xmlns='urn:xmpp:sxe:0'
  386. session='851ba2'
  387. id='bxyz'>
  388. <state>
  389. <document-begin
  390. prolog='data:text/xml,%3C!DOCTYPE%20html%0D%0APUBLIC%20%22-\
  391. %2F%2FW3C%2F%2FDTD%20XHTML%201.0%20Strict%2F%2FEN%22%0D%0A%22htt\
  393. E%0D%0A'/>
  394. <new type='processinginstruction'
  395. pitarget='xml-stylesheet'
  396. pidata='href="style.xsl" type="text/xsl"'
  397. rid='GUID0'
  398. primary-weight='0.4' />
  399. <new type='element'
  400. ns=''
  401. name='html'
  402. rid='GUID1'
  403. primary-weight='3' />
  404. <new type='attr'
  405. ns='xml'
  406. name='lang'
  407. chdata='fi'
  408. parent='GUID1'
  409. rid='GUID2' />
  410. <set target='GUID2'
  411. version='1'
  412. chdata='en' />
  413. <new type='element'
  414. name='head'
  415. parent='GUID1'
  416. rid='GUID3' />
  417. <new type='element'
  418. name='title'
  419. parent='GUID3'
  420. rid='GUID4' />
  421. <new type='text'
  422. chdata='Royal Musings'
  423. rid='GUID5'
  424. parent='GUID4'
  425. primary-weight='0'/>
  426. <new type='comment'
  427. chdata='The title of the document goes here.'
  428. rid='GUID6'
  429. parent='GUID4'
  430. primary-weight='-2.43'/>
  431. <new type='element'
  432. name='title'
  433. parent='GUID3'
  434. rid='GUID4' />
  435. <new type='element'
  436. name='body'
  437. parent='GUID1'
  438. rid='GUID7'
  439. primary-weight='23' />
  440. <document-end
  441. last-sender='jid3'
  442. last-id='abc'/>
  443. </state>
  444. </sxe>
  445. </message>
  446. ]]></example>
  447. </section2>
  448. </section1>
  449. <section1 topic='Subsequent State Changes'>
  450. <p>Once a participant has received initial state, he can participate in the editing session.</p>
  451. <example caption='An edit'><![CDATA[
  452. <message
  453. to='laertes@shakespeare.lit/castle'
  454. from='kingclaudius@shakespeare.lit/castle'>
  455. <sxe xmlns='urn:xmpp:sxe:0'
  456. session='851ba2'
  457. id='4'>
  458. <state>
  459. <new type='element'
  460. name='p'
  461. parent='GUID7'
  462. rid='GUID8' />
  463. <new type='text'
  464. chdata='It&apos;s good to be the king!'
  465. parent='GUID8'
  466. rid='GUID9'/>
  467. <set target='GUID5'
  468. version='1'
  469. chdata='It&apos;s good to be the king!'/>
  470. </state>
  471. </sxe>
  472. </message>
  473. ]]></example>
  474. <p>Here is another edit in the session.</p>
  475. <example caption='Another edit'><![CDATA[
  476. <message
  477. from='kingclaudius@shakespeare.lit/castle'
  478. to='laertes@shakespeare.lit/castle'>
  479. <sxe xmlns='urn:xmpp:sxe:0'
  480. session='851ba2'
  481. id='4'>
  482. <new type='element'
  483. name='p'
  484. parent='GUID7'
  485. rid='GUID10' />
  486. <new type='text'
  487. chdata='It certainly is!'
  488. parent='GUID10'
  489. rid='GUID11' />
  490. <set target='GUID5'
  491. version='1'
  492. chdata='It certainly is' />
  493. <set target='GUID6'
  494. version='1'
  495. replacefrom='9'
  496. replacen='16'
  497. chdata='' />
  498. <set target='GUID6'
  499. version='2'
  500. replacefrom='3'
  501. replacen='0'
  502. chdata='document'/>
  503. </sxe>
  504. </message>
  505. ]]></example>
  506. <p>This basic editing session results in the following XML.</p>
  507. <example caption='Resulting XHTML document (with additional whitespace nodes for clarity)'><![CDATA[
  508. <!DOCTYPE html
  509. PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  510. "">
  511. <?xml-stylesheet href="style.xsl" type="text/xsl"?>
  512. <html>
  513. <head>
  514. <!--The document title goes here.-->
  515. <title>Royal Musings</title>
  516. </head>
  517. <body>
  518. <p>It&apos;s good to be the king!</p>
  519. <p>It certainly is!</p>
  520. </body>
  521. </html>
  522. ]]></example>
  523. </section1>
  524. <section1 topic='Formal Definition' anchor='def'>
  525. <section2 topic='SXE Element' anchor='def-sxe'>
  526. <p>All SXE elements MUST be contained in a &lt;sxe/&gt; element. This element MUST posess the following attributes:</p>
  527. <table caption="Attributes of &lt;sxe/&gt; element">
  528. <tr>
  529. <th>Attribute</th>
  530. <th>Description</th>
  531. </tr>
  532. <tr>
  533. <td>xmlns</td>
  534. <td>REQUIRED and MUST be "urn:xmpp:sxe:0"</td>
  535. </tr>
  536. <tr>
  537. <td>session</td>
  538. <td>REQUIRED and MUST be a GUID of the session.</td>
  539. </tr>
  540. <tr>
  541. <td>id</td>
  542. <td>REQUIRED and MUST be unique within the set of &lt;sxe/&gt; elements sent by the user to the session.</td>
  543. </tr>
  544. </table>
  545. </section2>
  546. <section2 topic="XML Document Requirements">
  547. <p>The prolog of the XML document cannot be edited after the session has been established.</p>
  548. <p>If an XML Schema Definition is specified for the document and the processing of an &lt;sxe/&gt; element results in a noncompliant document, the receiving client SHOULD reply with edits that effectively undo the offending edits. TODO: the offending client should probably be notified.</p>
  549. </section2>
  550. <section2 topic="Mapping the Records to the DOM Document">
  551. <p>A record contains the following fields and corresponds to a single DOM node:</p>
  552. <table caption='The fields of a record'>
  553. <tr>
  554. <th>Field Name</th>
  555. <th>Mutable</th>
  556. <th>Applies to nodes of type</th>
  557. <th>Description</th>
  558. </tr>
  559. <tr>
  560. <td>rid</td>
  561. <td>no</td>
  562. <td>all</td>
  563. <td>The GUID of the record.</td>
  564. </tr>
  565. <tr>
  566. <td>type</td>
  567. <td>no</td>
  568. <td>all</td>
  569. <td>The type of DOM node (element, attr, etc.).</td>
  570. </tr>
  571. <tr>
  572. <td>version</td>
  573. <td>Indirectly</td>
  574. <td>all</td>
  575. <td>The current version of the record.</td>
  576. </tr>
  577. <tr>
  578. <td>parent</td>
  579. <td>yes</td>
  580. <td>all</td>
  581. <td>The record id of the record corresponding to the parent node.</td>
  582. </tr>
  583. <tr>
  584. <td>primary-weight</td>
  585. <td>yes</td>
  586. <td>all</td>
  587. <td>The primary weight used to determine the order of sibling nodes corresponding to the records.</td>
  588. </tr>
  589. <tr>
  590. <td>ns</td>
  591. <td>yes (TODO: is this reasonable?)</td>
  592. <td>element, attr</td>
  593. <td>The namespace of the element or attribute</td>
  594. </tr>
  595. <tr>
  596. <td>name</td>
  597. <td>yes (TODO: is this reasonable?)</td>
  598. <td>element, attr</td>
  599. <td>The name of the element or attribute.</td>
  600. </tr>
  601. <tr>
  602. <td>chdata</td>
  603. <td>yes</td>
  604. <td>text, attr, comment</td>
  605. <td>The content of a text node or a comment or the value of the attribute.</td>
  606. </tr>
  607. <tr>
  608. <td>pitarget</td>
  609. <td>yes (TODO: is this reasonable?)</td>
  610. <td>proccessinginstruction</td>
  611. <td>The target of the processing instruction.</td>
  612. </tr>
  613. <tr>
  614. <td>pidata</td>
  615. <td>yes</td>
  616. <td>proccessinginstruction</td>
  617. <td>The data of the processing instruction.</td>
  618. </tr>
  619. </table>
  620. <p>Whenever a record is added, modified, or removed, the client MUST ensure that the DOM nodes corresponding to the records meet the following criteria:</p>
  621. <ol>
  622. <li>The parent of each DOM node MUST be the node corresponding to the record specified by the 'record id' field of the record of the node. If no such record exists, the "orphan" record MUST be deleted. If the 'parent' field is empty, the node corresponding to the record MUST be a child of the DOM document itself. If two root nodes exist, the record with lower secondary weight MUST be removed. </li>
  623. <li>Each node MUST be located after the child node that has the greatest weight less than the weight of the node.</li>
  624. <li>The namespace of each DOM element and attribute MUST be equal to the 'name' field of the corresponding record.</li>
  625. <li>The name of each DOM element and attribute MUST be equal to the 'name' field of the corresponding record. If two records for attribute nodes specify the same 'name' and 'parent', the record with lower secondary weight MUST be removed.</li>
  626. <li>The value of each DOM attribute node MUST be equal to the 'chdata' field of the corresponding record.</li>
  627. <li>The content of each DOM text node MUST be equal to the 'chdata' field of the corresponding record.</li>
  628. <li>The content of each DOM comment node MUST be equal to the 'chdata' field of the corresponding record.</li>
  629. <li>The target of each DOM processing instruction MUST be equal to the 'pitarget' field of the corresponding record.</li>
  630. <li>The data of each DOM processing instruction MUST be equal to the 'pidata' field of the corresponding record.</li>
  631. <li>The DOM nodes do not offend the XML Schema. If they do, the client SHOULD send edits to correct the situation.</li>
  632. </ol>
  633. <table caption='Example set of records'>
  634. <tr>
  635. <th>rid</th>
  636. <th>type</th>
  637. <th>version</th>
  638. <th>parent</th>
  639. <th>primary-weight</th>
  640. <th>ns</th>
  641. <th>name</th>
  642. <th>chdata</th>
  643. <th>pitarget</th>
  644. <th>pidata</th>
  645. </tr>
  646. <tr>
  647. <td>GUID0</td>
  648. <td>element</td>
  649. <td>0</td>
  650. <td></td>
  651. <td>0</td>
  652. <td></td>
  653. <td>svg</td>
  654. <td>N/A</td>
  655. <td>N/A</td>
  656. <td>N/A</td>
  657. </tr>
  658. <tr>
  659. <td>GUID1</td>
  660. <td>element</td>
  661. <td>0</td>
  662. <td>GUID0</td>
  663. <td>0</td>
  664. <td></td>
  665. <td>path</td>
  666. <td>N/A</td>
  667. <td>N/A</td>
  668. <td>N/A</td>
  669. </tr>
  670. <tr>
  671. <td>GUID2</td>
  672. <td>attr</td>
  673. <td>0</td>
  674. <td>GUID1</td>
  675. <td>0</td>
  676. <td></td>
  677. <td>d</td>
  678. <td>M10 10L20 20L20 10Z</td>
  679. <td>N/A</td>
  680. <td>N/A</td>
  681. </tr>
  682. <tr>
  683. <td>GUID9</td>
  684. <td>element</td>
  685. <td>0</td>
  686. <td>GUID0</td>
  687. <td>3.4</td>
  688. <td></td>
  689. <td>g</td>
  690. <td>N/A</td>
  691. <td>N/A</td>
  692. <td>N/A</td>
  693. </tr>
  694. <tr>
  695. <td>GUID5</td>
  696. <td>element</td>
  697. <td>0</td>
  698. <td>GUID0</td>
  699. <td>3.4</td>
  700. <td></td>
  701. <td>circle</td>
  702. <td>N/A</td>
  703. <td>N/A</td>
  704. <td>N/A</td>
  705. </tr>
  706. <tr>
  707. <td>GUID6</td>
  708. <td>attr</td>
  709. <td>3</td>
  710. <td>GUID5</td>
  711. <td>0</td>
  712. <td></td>
  713. <td>cx</td>
  714. <td>10</td>
  715. <td>N/A</td>
  716. <td>N/A</td>
  717. </tr>
  718. <tr>
  719. <td>GUID7</td>
  720. <td>attr</td>
  721. <td>1</td>
  722. <td>GUID5</td>
  723. <td>1</td>
  724. <td></td>
  725. <td>cy</td>
  726. <td>20</td>
  727. <td>N/A</td>
  728. <td>N/A</td>
  729. </tr>
  730. <tr>
  731. <td>GUID8</td>
  732. <td>attr</td>
  733. <td>0</td>
  734. <td>GUID5</td>
  735. <td>2</td>
  736. <td></td>
  737. <td>r</td>
  738. <td>5</td>
  739. <td>N/A</td>
  740. <td>N/A</td>
  741. </tr>
  742. </table>
  743. <example caption='Corresponding XML document (without the XML prolog)'><![CDATA[
  744. <svg xmlns=''>
  745. <path d='M10 10L20 20L20 10Z' />
  746. <circle cx='10' cy='20' r='5' />
  747. <g />
  748. </svg>
  749. ]]></example>
  750. </section2>
  751. <section2 topic='Commutative and Non-commutative Edits'>
  752. <p>Changes to the records can be divided into two categories: commutative and non-commutative edits.</p>
  753. <p>Commutative edits are commutative with all edits and are never "undone" so keeping a history of them is NOT REQUIRED. Edits that add or remove records are commutative.</p>
  754. <p>An edit that changes an existing record is called non-commutative because it may not be commutative with edits that change the same record. Hence these changes may need to be undone so keeping a history of the changes caused by such edits is REQUIRED. The breadth of this required history depends on the role of the entity and on whether the session works through a server component:</p>
  755. <table caption='Matrix of required history'>
  756. <tr>
  757. <td></td>
  758. <th>By server</th>
  759. <th>By client</th>
  760. </tr>
  761. <tr>
  762. <th>Server exists</th>
  763. <td>All non-commutative edits, that have not been undone to records that have not been removed; must store the creator and last modifier of each node (to be included as 'creator' and 'last-modified-by' attributes in &lt;new/&gt; elements sent to joining clients).</td>
  764. <td>Non-commutative edits sent by the client itself. May be removed once a further non-commutative edits to the same record from another entity is received.</td>
  765. </tr>
  766. <tr>
  767. <th>Server does not exists</th>
  768. <td>---</td>
  769. <td>All non-commutative edits, that have not been undone, to records that have not been removed.</td>
  770. </tr>
  771. </table>
  772. <section3 topic='Requirements for the Server Component' anchor='serverrequirements'>
  773. <p>The server MUST apply commutatative edits to its local copy like a client and pass on the edits without changes.</p>
  774. <p>The server component intercepts and modifies non-commutative edits in order to reduce the history requirements of the clients as indicated above. Once it receives a non-commutative edit, it MUST take the following action depending on whether the version number of the edit is "in-order" (one higher than the current version) or "out-of-order":</p>
  775. <ol>
  776. <li>The server receives an in-order non-commutative edit: the server does not modify the edit, applies it locally, and passes it on normally.</li>
  777. <li>The server receives an out-of-order non-commutative edit: it processes the edit like a client would in order to locally undo conflicting edits; then, instead of passing on the out-of-order edit, the server replaces the edit by an in-order non-commutative edit that results in a record identical to what the server has locally after the (possible) undos. Note that this edit may be a "no-op" that merely increases the version of the target.</li>
  778. </ol>
  779. </section3>
  780. </section2>
  781. <section2 topic='Commutative Edits' anchor='commutativeedits'>
  782. <section3 topic='Creating New Nodes' anchor='newnode'>
  783. <p>A client can add a new node to the document by adding a record with the &lt;new/&gt; element.</p>
  784. <table caption="Attributes of the &lt;new/&gt; element">
  785. <tr>
  786. <th>Attribute</th>
  787. <th>Description</th>
  788. </tr>
  789. <tr>
  790. <td>rid</td>
  791. <td>REQUIRED. MUST be a GUID.</td>
  792. </tr>
  793. <tr>
  794. <td>version</td>
  795. <td>OPTIONAL. MUST be a non-negative integer. Assumed to be 0 if not present.</td>
  796. </tr>
  797. <tr>
  798. <td>parent</td>
  799. <td>REQUIRED (Except at top level.)</td>
  800. </tr>
  801. <tr>
  802. <td>primary-weight</td>
  803. <td>OPTIONAL. MUST be a float. Assumed to be 0 if not present.</td>
  804. </tr>
  805. <tr>
  806. <td>type</td>
  807. <td>REQUIRED. MUST be 'element', 'attr', 'text', 'comment', or 'processinginstruction'</td>
  808. </tr>
  809. <tr>
  810. <td>ns</td>
  811. <td>OPTIONAL if 'type' is 'element' or 'attr'. Not allowed otherwise.</td>
  812. </tr>
  813. <tr>
  814. <td>name</td>
  815. <td>REQUIRED if 'type' is 'element' or 'attr'. Not allowed otherwise.</td>
  816. </tr>
  817. <tr>
  818. <td>chdata</td>
  819. <td>REQUIRED if 'type' is 'attr', 'text', or 'comment'. Not allowed otherwise.</td>
  820. </tr>
  821. <tr>
  822. <td>pitarget</td>
  823. <td>REQUIRED if 'type' is 'processinginstruction'. Not allowed otherwise.</td>
  824. </tr>
  825. <tr>
  826. <td>pidata</td>
  827. <td>REQUIRED if 'type' is 'processinginstruction'. Not allowed otherwise.</td>
  828. </tr>
  829. <tr>
  830. <td>creator</td>
  831. <td>OPTIONAL. MUST be the JID or room nick of the creator of the node.</td>
  832. </tr>
  833. <tr>
  834. <td>last-modified-by</td>
  835. <td>OPTIONAL. MUST be the JID or room nick of the user who last modified the node.</td>
  836. </tr>
  837. </table>
  838. <example caption='Sending new nodes'><![CDATA[
  839. <message
  840. from='kingclaudius@shakespeare.lit/castle'
  841. to='laertes@shakespeare.lit/castle'>
  842. <sxe xmlns='urn:xmpp:sxe:0'
  843. session='851ba2'
  844. id='11'>
  845. <new type='element'
  846. name='path'
  847. parent='GUID1'
  848. rid='GUID4' />
  849. <new type='attr'
  850. name='d'
  851. parent='GUID4'
  852. rid='GUID5'
  853. chdata='M10 10L30 50L50 10Z' />
  854. </sxe>
  855. </message>
  856. ]]></example>
  857. <p>To process a &lt;new/&gt; element the client MUST create a new record with the values of the attributes stored in the corresponding fields.</p>
  858. </section3>
  859. <section3 topic='Removing Nodes' anchor='editelement'>
  860. <p>A client can remove any node in the document by removing the corresponding record with the &lt;remove/&gt; element.</p>
  861. <table caption="Attributes of the &lt;remove/&gt; element">
  862. <tr>
  863. <th>Attribute</th>
  864. <th>Description</th>
  865. </tr>
  866. <tr>
  867. <td>target</td>
  868. <td>REQUIRED and MUST be the record id of the node to be removed.</td>
  869. </tr>
  870. </table>
  871. <p>A client MUST NOT send a &lt;remove/&gt; element that removes a node that has child nodes without explicitly removing the records of those nodes first.</p>
  872. <example caption='Removing an existing nodes.'><![CDATA[
  873. <message
  874. from='kingclaudius@shakespeare.lit/castle'
  875. to='laertes@shakespeare.lit/castle'>
  876. <sxe xmlns='urn:xmpp:sxe:0'
  877. session='851ba2'
  878. id='13'>
  879. <remove target='GUID5'/>
  880. <remove target='GUID4'/>
  881. </sxe>
  882. </message>
  883. ]]></example>
  884. <p>To processes a &lt;remove/&gt; element the client MUST remove the record specified by the 'target' attribute.</p>
  885. <p>If the node corresponding to the target record has child nodes, the receiver MUST send &lt;remove/&gt; elements for each of them as described above.</p>
  886. </section3>
  887. </section2>
  888. <section2 topic='Non-commutative Edits' anchor='noncommutativeedits'>
  889. <section3 topic='The set Element'>
  890. <p>The &lt;set/&gt; element is used to modify an existing record.</p>
  891. <table caption="Attributes of the &lt;set/&gt; element">
  892. <tr>
  893. <th>Attribute</th>
  894. <th>Description</th>
  895. </tr>
  896. <tr>
  897. <td>target</td>
  898. <td>REQUIRED and MUST be the record id of the node being modified.</td>
  899. </tr>
  900. <tr>
  901. <td>version</td>
  902. <td>REQUIRED and MUST be the current version of the node incremented by one.</td>
  903. </tr>
  904. <tr>
  905. <td>parent</td>
  906. <td>OPTIONAL.</td>
  907. </tr>
  908. <tr>
  909. <td>primary-weight</td>
  910. <td>OPTIONAL.</td>
  911. </tr>
  912. <tr>
  913. <td>ns</td>
  914. <td>OPTIONAL but only allowed if the target record is of type 'element' or 'attr'.</td>
  915. </tr>
  916. <tr>
  917. <td>name</td>
  918. <td>OPTIONAL but only allowed if the target record is of type 'element' or 'attr'.</td>
  919. </tr>
  920. <tr>
  921. <td>chdata</td>
  922. <td>OPTIONAL but only allowed if the target node is of type 'attr', 'text', or 'comment'.</td>
  923. </tr>
  924. <tr>
  925. <td>pitarget</td>
  926. <td>OPTIONAL but only allowed if the target record is of type 'processinginstruction'.</td>
  927. </tr>
  928. <tr>
  929. <td>pidata</td>
  930. <td>OPTIONAL but only allowed if the target record is of type 'processinginstruction'.</td>
  931. </tr>
  932. <tr>
  933. <td>replacefrom</td>
  934. <td>replace from position. OPTIONAL but only allowed if 'chdata' and 'replacen' attributes are also included. MUST be a non-negative integer.</td>
  935. </tr>
  936. <tr>
  937. <td>replacen</td>
  938. <td>replace n characters. OPTIONAL but only allowed if 'chdata' and 'replacefrom' attributes are also included. MUST be a non-negative integer.</td>
  939. </tr>
  940. </table>
  941. <example caption='set elements.'><![CDATA[
  942. <message
  943. from='kingclaudius@shakespeare.lit/castle'
  944. to='laertes@shakespeare.lit/castle'>
  945. <sxe xmlns='urn:xmpp:sxe:0'
  946. session='851ba2'
  947. id='14'>
  948. <set target='GUID14'
  949. version='1'
  950. chdata='10' />
  951. <set target='GUID8'
  952. version='1'
  953. parent='GUID1'
  954. primary-weight='8' />
  955. </sxe>
  956. </message>
  957. ]]></example>
  958. </section3>
  959. <section3 topic='Processing a set Element'>
  960. <p>To processes a &lt;set/&gt; element the client MUST follow the following steps:</p>
  961. <ol>
  962. <li>If the record specified by the 'target' attribute doesn't exist, the &lt;set/&gt; element MUST be ignored.</li>
  963. <li>If the client is receiving history, (i.e. edits sent between the &lt;document-begin/&gt; and &lt;document-end/&gt; elements), it MUST set the version of the target record to the value of the 'version' attribute. Otherwise, the client MUST increment the version of the target recordrecord by one</li>
  964. <li>
  965. <p>If the version of of the target record is now equal to the 'version' attribute of the &lt;set/&gt; element, the client MUST store the values of the attributes of the &lt;set/&gt; element as updated values of the corresponding fields in the record. The only exception occurs when 'chdata', 'replacefrom', and 'replacen' are specified: in that case, n characters starting from the f'th character of the existing 'chdata' field MUST be replaced by c, where n, f, and c are the values of the 'replacen', 'replacefrom', and 'chdata' attributes respectively.</p>
  966. <p>Otherwise all fields of the record, except for the 'version' field, must be reverted to version (v - 1), where v is the value of the 'version' attribute of the received &lt;set/&gt; element.</p>
  967. </li>
  968. </ol>
  969. </section3>
  970. </section2>
  971. </section1>
  972. <section1 topic='Implementation Notes' anchor='impl'>
  973. <section2 topic='MUC Roles' anchor='mucroles'>
  974. <p>It should be noted that given the MUC specification and the requirement of this protocol to send a connect request message to all room members in order to join an existing session, you effectively can not use the visitor role of MUC with a regular MUC server component. However, the specialized MUC component, if used, MUST accept and respond to the connection requests even if they come from users who do not have voice in the room.</p>
  975. </section2>
  976. </section1>
  977. <section1 topic='Security Considerations' anchor='security'>
  978. <p>To follow.</p>
  979. </section1>
  980. <section1 topic='IANA Considerations' anchor='iana'>
  981. <p>This XEP requires no interaction with &IANA;.</p>
  982. </section1>
  983. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  984. <section2 topic='Protocol Namespaces' anchor='ns'>
  985. <p>Until this specification advances to a status of Draft, its associated namespaces shall be:</p>
  986. <ul>
  987. <li>urn:xmpp:sxe:0</li>
  988. <li>urn:xmpp:jingle:transports:sxe</li>
  989. </ul>
  990. <p>Upon advancement of this specification, the &REGISTRAR; shall issue permanent namespaces in accordance with the process defined in Section 4 of &xep0053;.</p>
  991. <p>The following namespaces are requested, and are thought to be unique per the XMPP Registrar's requirements:</p>
  992. <ul>
  993. <li>urn:xmpp:sxe</li>
  994. <li>urn:xmpp:jingle:transport:sxe</li>
  995. </ul>
  996. </section2>
  997. <section2 topic='Service Discovery Identities' anchor='registrar-identity'>
  998. <p>The &amp;REGISTRAR; shall add the type of "sxe" to the "collaboration" category in its registry of service discovery identities.</p>
  999. </section2>
  1000. <section2 topic='Jingle Transport Methods' anchor='registrar-transports'>
  1001. <p>The XMPP Registrar shall include "sxe" in its registry of Jingle transport methods. The registry submission is as follows:</p>
  1002. <code><![CDATA[
  1003. <transport>
  1004. <name>sxe</name>
  1005. <desc>A method for exchanging Shared XML Editing data over XMPP.</desc>
  1006. <type>reliable</type>
  1007. <doc>XEP-xxxx</doc>
  1008. </transport>
  1009. ]]></code>
  1010. </section2>
  1011. </section1>
  1012. <section1 topic='XML Schema' anchor='schema'>
  1013. <p>To follow.</p>
  1014. </section1>
  1015. <section1 topic='Acknowledgements' anchor='acknowledgements'>
  1016. <p>The theory behind the synchronization of an individual entity (a record) was put forward by Mats Bengtsson ( He also provided other input that helped form this XEP. Thanks to Dmitriy Chervov for his feedback based on implementation experience.</p>
  1017. </section1>
  1018. </xep>