Some applications require configuration of color values. Examples can be what colors to use for different situations in control applications. There's up to this point no good way to publish color values in a Data Forms (XEP-0004) [1].
Some applications provide parameters of type list-single enabling the user to choose a color from a list of colors. This only allows the user to select from a small amount of colors, and doesn't provide any visual feedback of the actual color chosen.
Editing color values as color components or encoded strings is both impractical and unintuitive.
This document proposes a method to publish color field parameters in a way that allows clients to show a color picker dialog for the parameter instead of forcing the user to enter an encoded color value. For clients not supporting this extensions, the color value will still be editable as an encoded color string.
This extension also relies on Data Forms Validation (XEP-0122) [2] as a fallback mechanism so clients not recognizing the color data types can handle them as strings with a regular expressions validating user input.
The following example shows how to publish a Color Field parameter in a Data Form:
The color value is represented by a string consisting of six case-insensitive hexadecimal digits. The first two represent the red component, the next two the green component and the last two the blue component.
If the client does not support XEP-0122 (Data Form Validation), it will interpret the field as a normal text-single field. It is up to the server to validate user input. But the user can still enter a color.
A client that supports XEP-0122 (Data Form Validation), but not this extension, will not understand the data type xdc:Color. It will thus default to a normal string (xs:string). However, the client still supports the regex validation rule, making sure the client only allows user input that forms valid color values.
A client supporting this specification will recognize the xdc:Color data type, and choose to show a color picker dialog instead of a string input field. In this case, the regular expression in the validation statement will not be used, as the string is not edited directly by the user. However, it is still available implicitly in the xdc:Color data type.
The following example shows how to publish a Color Field parameter including an Alpha channel in a Data Form:
The color value is represented by a string consisting of eight case-insensitive hexadecimal digits. The first two represent the red component, the next two the green component and the last two the blue component. The last two represents the alpha channel, where 00 means completely transparent and FF means completely opaque.
As with the xdc:Color type defined above, if the client does not support XEP-0122 (Data Form Validation), it will interpret the field as a normal text-single field. It is up to the server to validate user input. But the user can still enter a color.
A client that supports XEP-0122 (Data Form Validation), but not this extension, will not understand the data type xdc:ColorAlpha. It will thus default to a normal string (xs:string). However, the client still supports the regex validation rule, making sure the client only allows user input that forms valid color values.
A client supporting this specification will recognize the xdc:ColorAlpha data type, and choose to show a color picker dialog instead of a string input field. In this case, the regular expression in the validation statement will not be used, as the string is not edited directly by the user. However, it is still available implicitly in the xdc:ColorAlpha data type.
As defined in XEP-0122 §7.2.1, following is the submission to the XMPP Registrar of a new datatype prefix for use in data forms:
As defined in XEP-0122 §7.2.2, following is the submission to the XMPP Registrar of a new datatype representing color values for use in data forms:
As defined in XEP-0122 §7.2.2, following is the submission to the XMPP Registrar of a new datatype representing color values with alpha channel for use in data forms:
Thanks to Karin Forsell for all valuable feedback.
This document in other formats: XML PDF
This XMPP Extension Protocol is copyright © 1999 – 2020 by the XMPP Standards Foundation (XSF).
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.
## 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. ##
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.
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).
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.
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-0004: Data Forms <https://xmpp.org/extensions/xep-0004.html>.
2. XEP-0122: Data Forms Validation <https://xmpp.org/extensions/xep-0122.html>.
Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/
Updated contact information.
Updated example JIDs to example.org
Namespace changed to urn:xmpp:xdata:color.
Initial published version approved by the XMPP Council.
Added the ColorAlpha data type.
First draft.
END