Abstract: | Standardizes behavior of <iq/> <query/> actions for generic query behavior. |
Author: | Iain Shigeoka |
Copyright: | © 1999 – 2018 XMPP Standards Foundation. SEE LEGAL NOTICES. |
Status: | Deferred |
Type: | Standards Track |
Version: | 0.1.1 |
Last Updated: | 2018-11-03 |
WARNING: This document has been automatically Deferred after 12 months of inactivity in its previous Experimental state. Implementation of the protocol described herein is not recommended for production systems. However, exploratory implementations are encouraged to resume the standards process.
1. Introduction
2. <query/> Action Protocol
2.1. Description
2.2. Actions
2.3. Elements
2.4. Error Codes
3. Create Action
3.1. Description
3.2. Error Codes
3.3. Examples
4. Read Action
4.1. Description
4.2. Error Codes
4.3. Examples
5. Update Action
5.1. Description
5.2. Error Codes
5.3. Examples
6. Delete Action
6.1. Description
6.2. Error Codes
6.3. Examples
7. Defining an Action Protocol
7.1. Description
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
There is a need for consistent query behavior amongst XMPP <iq/> protocols. Currently each protocol invents its own, slightly different behavior for conducting query behavior to create, read, update, and delete (CRUD) recipient node data. This document defines a generic query acton protocol to standardize behavior across <iq/> protocols. In addition, we hope this standard will make other protocols easier to understand and implement by using a common core protocol.
The existing XMPP core protocol defines four <iq/> types (get, set, result, and error). Unfortunately, these four types don't include a 'delete' type, and the 'set' type must do double duty for 'create' and 'update'. Many protocols can benefit from a clear separation of create and update paralleling other query languages such as SQL.
Protocols complying with the <query/> action protocol use <iq/> 'set' to initiate all request-response interactions. The particular action to be taken MUST be set as an "action" attribute in the <iq/> <query/> sub-element. The action attribute MUST have a value of 'create', 'read', 'update', or 'delete'. Responses use the standard <iq/> 'result' and 'error' types. For backward compatibility, an <iq/> 'get' query is treated as equivalent to an <iq/> 'set' query with action of 'read'. Action protocols may require all or just a subset of these actions depending on the desired outcome.
In addition to the action attribute an optional "strict" attribute may be set in the <iq/> <query/> sub-element. The only valid values for strict is "true" or "false" (case sensitive). The strict behavior of actions causes more errors to be returned which tends to make protocols more robust but also more complex. Action protocols MUST define the default value of the "strict" attribute in the context of that protocol. In addition, some protocols may not wish to allow changing the strict default, so action protocols MUST declare whether the strict behavior of the protocol may be set in the <iq/> <query/> sub-element.
The root element is query which is in a namespace defining the protocol in use. The query element MUST have an attribute named 'action' with values given in the previous table.
The following error codes apply to all action codes.
The create action inserts new data on the recipient node. If the strict attribute is 'true' the create action fails if colliding data already exists on the recipient node. If the strict attribute is false, the create action will insert new data on the recipient node overwriting existing colliding data if it exists (e.g. equivalent to update).
Creating new data on the server using iq:private, and strict actions when no existing data is on the server.
Example 1. Client Stores New Private Data
SENDER: <iq type="set" id="1001"> <query xmlns="jabber:iq:private" action="create" strict="true"> <exodus xmlns="exodus:prefs"> <defaultnick>Hamlet</defaultnick> </exodus> </query> </iq> RECIPIENT: <iq type="result" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1001"/>
With strict actions enabled, conflict data will cause the create action to fail when existing data is on the recipient node. Here we show iq:private, and strict actions with existing data on the server.
Example 2. Client Stores New Private Data but Conflicts
SENDER: <iq type="set" id="1002"> <query xmlns="jabber:iq:private" action="create" strict="true"> <exodus xmlns="exodus:prefs"> <defaultnick>Hamlet</defaultnick> </exodus> </query> </iq> RECIPIENT: <iq type="error" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1002"> <error code="409">Conflict</error> <exodus xmlns="exodus:prefs"> <defaultnick>Hamlet</defaultnick> </exodus> </query> </iq>
The read action retrieves data on the recipient node. If the strict attribute is 'true' the read action fails if no appropriate data exists on the recipient node. If the strict attribute is false, the read action will always return with a 'result', sending an empty result in place of a 'not found' error.
Reading data on the server using iq:private, and strict actions when data is on the server.
Example 3. Client Reads Private Data
SENDER: <iq type="set" id="1001"> <query xmlns="jabber:iq:private" action="read" strict="true"> <exodus xmlns="exodus:prefs"/> <defaultnick>Hamlet</defaultnick> </exodus> </query> </iq> RECIPIENT: <iq type="result" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1001"> <query xmlns="jabber:iq:private" action="read" strict="true"> <exodus xmlns="exodus:prefs"/> <defaultnick>Hamlet</defaultnick> </exodus> </query> </iq>
With strict actions enabled, the absence of matching data will cause the read action to fail. Here we show iq:private, and strict actions with no matching data on the server.
Example 4. Client Reads Private Data but Not Found (strict)
SENDER: <iq type="set" id="1002"> <query xmlns="jabber:iq:private" action="read" strict="true"> <data xmlns="imaginary"/> </query> </iq> RECIPIENT: <iq type="error" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1002"> <error code="404">Not Found</error> <data xmlns="imaginary"/> </query> </iq>
With strict actions disabled, the absence of matching data will cause the read action to return an 'empty' result. Here we show iq:private, and strict actions disabled with no matching data on the server.
Example 5. Client Reads Private Data but Not Found (not strict)
SENDER: <iq type="set" id="1003"> <query xmlns="jabber:iq:private" action="read" strict="false"> <data xmlns="imaginary"/> </query> </iq> RECIPIENT: <iq type="result" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1003"> <data xmlns="imaginary"/> </query> </iq>
The update action edits existing data on the recipient node. If the strict attribute is 'true' the update action fails if matching data does not already exists on the recipient node. If the strict attribute is false, the update action will edit existing data, inserting the data on the recipient node if necessary.
Updating existing new data on the server using iq:private, and strict actions when existing data is on the server.
Example 6. Client Updates Existing Private Data
SENDER: <iq type="set" id="1001"> <query xmlns="jabber:iq:private" action="update" strict="true"> <exodus xmlns="exodus:prefs"> <defaultnick>Hamlet</defaultnick> </exodus> </query> </iq> RECIPIENT: <iq type="result" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1001"/>
With strict actions enabled, the absence of existing data will cause the update action to fail. Here we show iq:private, and strict actions with no existing data on the server.
Example 7. Client Updates Private Data but None Found
SENDER: <iq type="set" id="1002"> <query xmlns="jabber:iq:private" action="update" strict="true"> <exodus xmlns="exodus:prefs"> <defaultnick>Hamlet</defaultnick> </exodus> </query> </iq> RECIPIENT: <iq type="error" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1002"> <error code="404">Not Found</error> <exodus xmlns="exodus:prefs"> <defaultnick>Hamlet</defaultnick> </exodus> </query> </iq>
The delete action deletes existing data on the recipient node. If the strict attribute is 'true' the delete action fails if matching data does not already exists on the recipient node. If the strict attribute is false, the delete action will delete any existing data on the recipient node (if any) and return successful..
Deleting existing new data on the server using iq:private, and strict actions when existing data is on the server.
Example 8. Client Deletes Existing Private Data
SENDER: <iq type="set" id="1001"> <query xmlns="jabber:iq:private" action="delete" strict="true"> <exodus xmlns="exodus:prefs"/> </query> </iq> RECIPIENT: <iq type="result" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1001"/>
With strict actions enabled, the absence of existing data will cause the delete action to fail. Here we show iq:private, and strict actions with no existing data on the server.
Example 9. Client Deletes Private Data but None Found (strict)
SENDER: <iq type="set" id="1002"> <query xmlns="jabber:iq:private" action="delete" strict="true"> <data xmlns="imaginary"/> </query> </iq> RECIPIENT: <iq type="error" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1002"> <error code="404">Not Found</error> <data xmlns="imaginary"/> </query> </iq>
With strict actions disabled, the absence of existing data will not cause the delete action to fail. Here we show iq:private, and strict actions with no existing data on the server.
Example 10. Client Deletes Private Data but None Found (not strict)
SENDER: <iq type="set" id="1003"> <query xmlns="jabber:iq:private" action="delete" strict="false"> <data xmlns="imaginary"/> </query> </iq> RECIPIENT: <iq type="result" from="hamlet@shakespeare.lit/denmark" to="hamlet@shakespeare.lit/denmark" id="1003"/>
In order to define an action protocol that uses the <query/> behavior defined in this document, you must specify the following:
Series: XEP
Number: 0099
Publisher: XMPP Standards Foundation
Status:
Deferred
Type:
Standards Track
Version: 0.1.1
Last Updated: 2018-11-03
Approving Body: XMPP Council
Dependencies: None
Supersedes: None
Superseded By: None
Short Name: Not yet assigned
Source Control:
HTML
This document in other formats:
XML
PDF
Email:
iain@jivesoftware.com
JabberID:
smirk@jabber.com
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".
Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/
END