%ents; ]>
Data Forms - Color Field Types 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. &LEGALNOTICE; 0331 Experimental Standards Track Standards Council XMPP Core XEP-0001 XEP-0004 XEP-0030 XEP-0122 NOT_YET_ASSIGNED Peter Waher peter.waher@clayster.com peter.waher@jabber.org http://se.linkedin.com/pub/peter-waher/1a/71b/a29/ 0.1 2013-06-26 psa

Initial published version approved by the XMPP Council.

0.0.2 2013-06-11 pw

Added the ColorAlpha data type.

0.0.1 2013-05-27 pw

First draft.

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 &xep0004;.

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 &xep0122; 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:

Choose a color. ^[0-9a-fA-F]{6}$ 9400D3 ]]>

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:

Choose a color. ^[0-9a-fA-F]{8}$ 9400D3C0 ]]>

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:

xdc defines the Color data type color-parameter.html ]]>

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:

xdc:Color 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 basic regex N/A N/A ]]>

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:

xdc:ColorAlpha 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 basic regex N/A N/A ]]>
]]>

Thanks to Karin Forsell for all valuable feedback.