Abstract: | This specification defines how to publish fields in data forms that take color values. Color values are best edited using a color picker dialog, rather than manual input. |
Author: | Peter Waher |
Copyright: | © 1999 - 2015 XMPP Standards Foundation. SEE LEGAL NOTICES. |
Status: | Experimental |
Type: | Standards Track |
Version: | 0.2 |
Last Updated: | 2014-03-10 |
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. Publishing a Color Field in a Data Form
3. Publishing a Color Field with Alpha channel in a Data Form
4. XMPP Registrar Considerations
4.1. Color datatype prefix: xdc
4.2. Color datatype
4.3. ColorAlpha datatype
5. XML Schema
6. Acknowledgements
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
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:
<field var='color' type='text-single' label='Color:'> <desc>Choose a color.</desc> <xdv:validate xmlns:xdv='http://jabber.org/protocol/xdata-validate' xmlns:xdc='urn:xmpp:xdata:color' datatype='xdc:Color'> <xdv:regex>^[0-9a-fA-F]{6}$</xdv:regex> </xdv:validate> <value>9400D3</value> </field>
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:
<field var='color' type='text-single' label='Color:'> <desc>Choose a color.</desc> <xdv:validate xmlns:xdv='http://jabber.org/protocol/xdata-validate' xmlns:xdc='urn:xmpp:xdata:color' datatype='xdc:ColorAlpha'> <xdv:regex>^[0-9a-fA-F]{8}$</xdv:regex> </xdv:validate> <value>9400D3C0</value> </field>
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:
<datatype-prefix> <prefix>xdc</prefix> <desc>defines the Color data type</desc> <doc>http://xmpp.org/extensions/xep-0331.html</doc> </datatype-prefix>
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:
<datatype> <name>xdc:Color</name> <desc>a color value represented as an RGB value, expressed using 6 hexadecimal digits, with each pair of the hexadecimal digits representing the values of the Red, Green and Blue channel, respectively</desc> <methods>basic regex</methods> <min>N/A</min> <max>N/A</max> </datatype>
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:
<datatype> <name>xdc:ColorAlpha</name> <desc>a color value represented as an RGBA value, expressed using 8 hexadecimal digits, with each pair of the hexadecimal digits representing the values of the Red, Green, Blue and Alpha channel, respectively</desc> <methods>basic regex</methods> <min>N/A</min> <max>N/A</max> </datatype>
<?xml version='1.0' encoding='UTF-8'?> <xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' targetNamespace='urn:xmpp:xdata:color' xmlns='urn:xmpp:xdata:color' elementFormDefault='qualified'> <xs:simpleType name='Color'> <xs:restriction base='xs:string'> <xs:pattern value='^[0-9a-fA-F]{6}$'/> </xs:restriction> </xs:simpleType> <xs:simpleType name='ColorAlpha'> <xs:restriction base='xs:string'> <xs:pattern value='^[0-9a-fA-F]{8}$'/> </xs:restriction> </xs:simpleType> </xs:schema>
Thanks to Karin Forsell for all valuable feedback.
Series: XEP
Number: 0331
Publisher: XMPP Standards Foundation
Status:
Experimental
Type:
Standards Track
Version: 0.2
Last Updated: 2014-03-10
Approving Body: XMPP Council
Dependencies: XMPP Core, XEP-0001, XEP-0004, XEP-0030, XEP-0122
Supersedes: None
Superseded By: None
Short Name: color-parameter
Source Control:
HTML
This document in other formats:
XML
PDF
Email:
peter.waher@clayster.com
JabberID:
peter.waher@jabber.org
URI:
http://www.linkedin.com/in/peterwaher
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 <http://xmpp.org/extensions/xep-0004.html>.
2. XEP-0122: Data Forms Validation <http://xmpp.org/extensions/xep-0122.html>.
Note: Older versions of this specification might be available at http://xmpp.org/extensions/attic/
Namespace changed to urn:xmpp:xdata:color.
(pw)Initial published version approved by the XMPP Council.
(psa)Added the ColorAlpha data type.
(pw)First draft.
(pw)END