Abstract: | This specification allows to change order of items retrieval in a Pubsub or MAM query |
Author: | Jérôme Poisson |
Copyright: | © 1999 – 2018 XMPP Standards Foundation. SEE LEGAL NOTICES. |
Status: | Experimental |
Type: | Standards Track |
Version: | 0.1.0 |
Last Updated: | 2019-02-04 |
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.
1. Introduction
2. Requirements
3. Glossary
4. Use Cases
4.1. Retrieve Items By Date of Creation
4.2. Retrieve Items By Date of Modification
4.3. Use with MAM
4.4. Reversing the Order
4.5. Extending this Specification
5. Discovering Support
6. Business Rules
7. Implementation Notes
8. Security Considerations
9. IANA Considerations
10. XMPP Registrar Considerations
10.1. Protocol Namespaces
10.2. Protocol Versioning
11. XML Schema
Appendices
A: Document Information
B: Author Information
C: Legal Notices
D: Relation to XMPP
E: Discussion Venue
F: Requirements Conformance
G: Notes
H: Revision History
Publish-Subscribe (XEP-0060) [1] §6.5.7 allows to retrieve the "most recent items" and Message Archive Management (XEP-0313) [2] state in §3.1 that archives are ordered in "chrnological order". While this order is straighforward in general use cases, it is sometimes desirable to use a different order, for instance while using Microblogging Over XMPP (XEP-0277) [3]: a spell mistake correction should not bring an old blog post to the top of retrieved items.
This specification allows to explicitly change business logic to retrieve the items in a different order, in a similar way as the "ORDER BY" clause in SQL.
In XEP-0060, there is no such thing as "updated item". This XEP changes the business logic as follow:
Juliet wants to retrieve plays of his favorite writer, William Shakespeare. She wants to retrieve the 3 most recent ones by date of creation.
To do so, her client do a regular Pubsub request, but add the <order> element as a children of the <pubsub> element with a namespace of "urn:xmpp:order-by:0" and with a 'by' attribute equal to "creation".
<iq type='get' from='juliet@capulet.lit/balcony' to='pubsub.shakespeare.lit' id=''> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <items node='plays' max_items='3'/> <order xmlns='urn:xmpp:order-by:0' by='creation'/> </pubsub> </iq>
Pubsub service then returns the 3 plays created the most recently, first one being the most recent
<iq type='result' from='pubsub.shakespeare.lit' to='juliet@capulet.lit/balcony' id=''> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <items node='plays'> <item id='153214214'> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Henry VIII</title> </entry> </item> <item id='623423544'> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Tempest</title> </entry> </item> <item id='452432423'> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Wintter's Tale</title> </entry> </item> </items> </pubsub> </iq>
Juliet realize that there is a spelling mistake, it's "Winter's Tale" and not "Wintter's Tale". She fixes it by overwritting the item:
<iq type='set' from='juliet@capulet.lit/balcony' to='pubsub.shakespeare.lit' id='orderby2'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='plays'> <item id='452432423'> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Winter's Tale</title> </entry> </item> </publish> </pubsub> </iq>
To check that everything is alright, she request again the last 3 items, but this time by date of modification. To do so, he client proceed the same way as for date of creation, except that it uses the value "modification" for the 'by' attribute
<iq type='get' from='juliet@capulet.lit/balcony' to='pubsub.shakespeare.lit' id='orderby3'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <items node='plays' max_items='3'/> <order xmlns='urn:xmpp:order-by:0' by='modification'/> </pubsub> </iq>
Pubsub service returns again the 3 plays but the "Winter Tales" item has been overwritten recently, while the 2 others have never been overwritten, so it returns the items in the following order, with most recently modified item on top:
<iq type='result' from='pubsub.shakespeare.lit' to='juliet@capulet.lit/balcony' id='orderby3'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <items node='plays'> <item id='452432423'> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Winter's Tale</title> </entry> </item> <item id='153214214'> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Henry VIII</title> </entry> </item> <item id='623423544'> <entry xmlns='http://www.w3.org/2005/Atom'> <title>Tempest</title> </entry> </item> </items> </pubsub> </iq>
With Message Archive Management (XEP-0313) [2] the logic is the same, but the <order> element is added as a child of the <query> element:
<iq to='pubsub.shakespeare.lit' type='set' id='orderby4'> <query xmlns='urn:xmpp:mam:2' queryid='123' node='plays'> <order xmlns='urn:xmpp:order-by:0' by='creation'/> </query> </iq>
This way, filters can be used with specific ordering
The ordering can be reversed by using the mechanisms already provided by Result Set Management (XEP-0059) [4]
This specification can be extended by further XEPs, proposing other kind of ordering in the 'by' attribute (e.g. ordering by filename for a file sharing service). But this is beyond the scope of this XEPs, and a client should not assume that other ordering than "creation" and "modification" are available without negociation.
In a similar way, the semantic described here could be re-used in other use cases as for Pubsub or MAM, but this would need to be detailed in a separate specification.
If a server supports the "order by" protocol, it MUST report that fact by including a service discovery feature of "urn:xmpp:order-by:0" (see Protocol Namespaces regarding issuance of one or more permanent namespaces) in response to a Service Discovery (XEP-0030) [5] information request:
<iq from='example.org' id='disco1' to='example.com' type='get'> <query xmlns='http://jabber.org/protocol/disco#info'/> </iq>
<iq from='example.com' id='disco1' to='example.org' type='result'> <query xmlns='http://jabber.org/protocol/disco#info'> ... <feature var='urn:xmpp:order-by:0'/> ... </query> </iq>
Several ordering elements may be used, this allow to solve next levels of ordering in case of conflicts. In this case, the first ordering (i.e. the top most <order> element) is the main one, the the second <order> element is used in case of conflict, then the next one if a new conflict happen and so on.
In case of conflict, if no new <order> element is specified, the item order is not guarented and is up to the implementation
For implementations based on SQL databases, the "ORDER BY" clause can be used to easily implement this specification. Other kind of databases should have similar mechanisms
This document introduces no additional security considerations above and beyond those defined in the documents on which it depends.
This document requires no interaction with the Internet Assigned Numbers Authority (IANA) [6].
This specification defines the following XML namespace:
If the protocol defined in this specification undergoes a revision that is not fully backwards-compatible with an older version, the XMPP Registrar shall increment the protocol version number found at the end of the XML namespaces defined herein, as described in Section 4 of XEP-0053.
<?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:xmpp:order-by:0' xmlns='urn:xmpp:order-by:0' elementFormDefault='qualified'> <xs:element name='order' maxOccurs='unbounded'> <xs:complexType> <xs:attribute name='by' type='xs:string' use='required'/> </xs:complexType> </xs:element> </xs:schema>
Series: XEP
Number: 0413
Publisher: XMPP Standards Foundation
Status:
Experimental
Type:
Standards Track
Version: 0.1.0
Last Updated: 2019-02-04
Approving Body: XMPP Council
Dependencies: XMPP Core, XEP-0060, XEP-0313
Supersedes: None
Superseded By: None
Short Name: NOT_YET_ASSIGNED
Source Control:
HTML
This document in other formats:
XML
PDF
Email:
goffi@goffi.org
JabberID:
goffi@jabber.fr
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.
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>.
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".
1. XEP-0060: Publish-Subscribe <https://xmpp.org/extensions/xep-0060.html>.
2. XEP-0313: Message Archive Management <https://xmpp.org/extensions/xep-0313.html>.
3. XEP-0277: Microblogging over XMPP <https://xmpp.org/extensions/xep-0277.html>.
4. XEP-0059: Result Set Management <https://xmpp.org/extensions/xep-0059.html>.
5. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.
6. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.
Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/
First draft.
(jp)END