XEP-0372: References

Abstract
This document defines a method for one XMPP stanza to provide references to another entity, such as mentioning users, HTTP resources, or other XMPP resources.
Author
Kevin Smith
Copyright
© 1999 – 2020 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

Experimental

WARNING: This Standards-Track document is Experimental. Publication as an XMPP Extension Protocol does not imply approval of this proposal by the XMPP Standards Foundation. Implementation of the protocol described herein is encouraged in exploratory implementations, but production systems are advised to carefully consider whether it is appropriate to deploy implementations of this protocol before it advances to a status of Draft.
Type
Standards Track
Version
0.4.0 (2020-12-08)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Draft
  4. Final

1. Introduction

It's often desirable to encode a reference to another entity within a chat message and to mark up the reference. Examples of this include HTTP URLs, 'mentions' (referring to another user), references to previous messages and references to Form Discovery and Publishing (XEP-0346) [1] (FDP) forms. This document provides a mechanism for marking up a section of a message body with information about the target of the reference.

2. Discovery

If a client implements references, it MUST specify the 'urn:xmpp:reference:0' feature in its service discovery information features as specified in Service Discovery (XEP-0030) [2] and the Entity Capabilities profile specified in Entity Capabilities (XEP-0115) [3].

Example 1. Client queries for contact's features
<iq type='get'
    id='disco1'
    from='romeo@montegue.lit/30d3d8'
    to='juliet@capulet.lit/sabo239'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
Example 2. Contact's client responds with features
<iq type='result'
    id='disco1'
    from='juliet@capulet.lit/sabo239'
    to='romeo@montegue.lit/30d3d8'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    ...
    <feature var='urn:xmpp:reference:0'/>
    ...
  </query>
</iq>

TODO: Individual discovery of reference types - FDP, Mentions, ...

3. Use Cases

3.1 Generics

References are provided in a 'reference' element of a message, with a namespace of 'urn:xmpp:reference:0'. The element MUST contain a 'type' attribute denoting the type of the reference and a 'uri' attribute of the thing that is referenced. It MAY contain 'begin', 'end' and 'anchor' elements.

The 'begin' and 'end' attributes are indexes denoting the beginning and end of the referenced substring in the message body. The Dijkstra convention of ranges [4] is used, which means that 'begin' is inclusive and 'end' is exclusive. In other words, the 'begin' attribute is the index of the first character (TODO: define character appropriately) in the referenced substring, with 0 being the index of the first character in the body, and the 'end' attribute is one higher than the index of the last character in the substring. This convention has three main advantages. It matches subsequence indexing in various programming languages, 'end' minus 'begin' equals the length of the substring, and when two substrings are adjacent, the 'end' attribute of the first one matches the 'begin' attribute of the second one. Where the reference is not a substring of the message body in the referring stanza, 'begin' and 'end' are not used.

An 'anchor' attribute is used when the referring message is not the one containing the reference element, and points to the previous message containing the reference (the referring message).

Note that the URIs of the reference and anchor do not need to refer to the same mechanism as that in which the reference was received. E.g., a service could listen for mentions in a MIX channels of users outside that channel, and send them messages containing a reference to let them know that they've been mentioned.

3.2 Mentions

Mentions are a reference to a user's bare JID, and have a type of 'mention'.

Example 3. Romeo sends a message mentioning Juliet
<message type='groupchat'
         id='sotehu-bthbtp32h3'
         to='balcony@channels.shakespeare.lit'>
  <body>But, soft! what light through yonder window breaks? It is the east, and Juliet is the sun.</body>
  <reference xmlns='urn:xmpp:reference:0'
             begin='72'
             end='78'
             type='mention'
             uri='xmpp:juliet@capulet.lit'/>
</message>

3.3 Data

Data references are a generic reference without additional information. The URI points to an 'item' that is able to be fetched. This is useful for, for example, fetching an item from pubsub, as in the example below. TODO: check URI syntax for refering to a pubsub item.

Example 4. A MIX Channel sends a message that a new FDP form has been submitted elsewhere
<message type='groupchat'
         id='sotehu-bthbtp32h4'
         from='balcony@channels.shakespeare.lit'
         to='romeo@montegue.lit/30d3d8'>
  <body>Form received</body>
  <reference xmlns='urn:xmpp:reference:0'
             type='data'
             uri='xmpp:fdp.shakespeare.lit?;node=fdp/submitted/stan.isode.net/accidentreport;item=ndina872be'/>
</message>

3.4 Previous messages

Sometimes it's desirable to annotate a reference in a previous message. An example of this might be where a MIX channel asynchronously adds information about references made in previous messages by users. In this case the message MUST NOT contain a body. Here the anchor attribute is used to provide a URI to the previous message. TODO: URI scheme for messages.

Example 5. A MIX Channel annotates a previous user message
<message type='groupchat'
         id='sotehu-bthbtp32h5'
         from='balcony@channels.shakespeare.lit'
         to='romeo@montegue.lit/30d3d8'>
  <reference xmlns='urn:xmpp:reference:0'
             type='data'
             anchor='xmpp:balcony@channels.shakespeare.lit?;node=messages;item=bnhob'
             begin='72'
             end='78'
             uri='xmpp:fdp.shakespeare.lit?;node=fdp/submitted/stan.isode.net/accidentreport;item=ndina872be'/>
</message>

4. Security Considerations

TODO.

5. IANA Considerations

None.

6. XMPP Registrar Considerations

Needs a namespace.

7. XML Schema

When advanced.


Appendices

Appendix A: Document Information

Series
XEP
Number
0372
Publisher
XMPP Standards Foundation
Status
Experimental
Type
Standards Track
Version
0.4.0
Last Updated
2020-12-08
Approving Body
XMPP Council
Dependencies
XMPP Core, XMPP IM, XEP-0030, XEP-0115
Supersedes
None
Superseded By
None
Short Name
Refs
Source Control
HTML

This document in other formats: XML  PDF

Appendix B: Author Information

Kevin Smith
Email
kevin.smith@isode.com
JabberID
kevin.smith@isode.com

Copyright

This XMPP Extension Protocol is copyright © 1999 – 2020 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <http://xmpp.org/about/discuss.shtml> for a complete list.

Errata can be sent to <editor@xmpp.org>.

Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".

Appendix G: Notes

1. XEP-0346: Form Discovery and Publishing <https://xmpp.org/extensions/xep-0346.html>.

2. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.

3. XEP-0115: Entity Capabilities <https://xmpp.org/extensions/xep-0115.html>.

4. Dijkstra convention of ranges <https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html>

Appendix H: Revision History

Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/

  1. Version 0.4.0 (2020-12-08)
    Specify that begin is inclusive, starts counting at zero, and that end is exclusive (Dijkstra-based convention)
    gh/jcbrand
  2. Version 0.3 (2019-09-04)
    Make Pubsub URIs in sections 3.3 and 3.4 conform to XEP-0147.
    (mb)
  3. Version 0.2 (2017-09-11)
    Defer due to lack of activity.
    XEP Editor (jwi)
  4. Version 0.1 (2016-03-22)

    Initial published version approved by the XMPP Council.

    XEP Editor (asw)
  5. Version 0.0.1 (2016-01-29)

    First draft.

    kis

END