No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

xep-0331.xml 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <?xml version='1.0' encoding='UTF-8'?>
  2. <!DOCTYPE xep SYSTEM 'xep.dtd' [
  3. <!ENTITY % ents SYSTEM 'xep.ent'>
  4. %ents;
  5. ]>
  6. <?xml-stylesheet type='text/xsl' href='xep.xsl'?>
  7. <xep>
  8. <header>
  9. <title>Data Forms - Color Field Types</title>
  10. <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.</abstract>
  11. &LEGALNOTICE;
  12. <number>0331</number>
  13. <status>Deferred</status>
  14. <type>Standards Track</type>
  15. <sig>Standards</sig>
  16. <approver>Council</approver>
  17. <dependencies>
  18. <spec>XMPP Core</spec>
  19. <spec>XEP-0001</spec>
  20. <spec>XEP-0004</spec>
  21. <spec>XEP-0030</spec>
  22. <spec>XEP-0122</spec>
  23. </dependencies>
  24. <supersedes/>
  25. <supersededby/>
  26. <shortname>color-parameter</shortname>
  27. &peterwaher;
  28. <revision>
  29. <version>0.3</version>
  30. <date>2015-11-09</date>
  31. <initials>pw</initials>
  32. <remark>
  33. <p>Updated contact information.</p>
  34. <p>Updated example JIDs to example.org</p>
  35. </remark>
  36. </revision>
  37. <revision>
  38. <version>0.2</version>
  39. <date>2014-03-10</date>
  40. <initials>pw</initials>
  41. <remark>
  42. <p>Namespace changed to urn:xmpp:xdata:color.</p>
  43. </remark>
  44. </revision>
  45. <revision>
  46. <version>0.1</version>
  47. <date>2013-06-26</date>
  48. <initials>psa</initials>
  49. <remark>
  50. <p>Initial published version approved by the XMPP Council.</p>
  51. </remark>
  52. </revision>
  53. <revision>
  54. <version>0.0.2</version>
  55. <date>2013-06-11</date>
  56. <initials>pw</initials>
  57. <remark>
  58. <p>Added the ColorAlpha data type.</p>
  59. </remark>
  60. </revision>
  61. <revision>
  62. <version>0.0.1</version>
  63. <date>2013-05-27</date>
  64. <initials>pw</initials>
  65. <remark>
  66. <p>First draft.</p>
  67. </remark>
  68. </revision>
  69. </header>
  70. <section1 topic='Introduction' anchor='intro'>
  71. <p>
  72. Some applications require configuration of color values. Examples can be what colors to use for different situations in control applications.
  73. There's up to this point no good way to publish color values in a &xep0004;.
  74. </p>
  75. <p>
  76. 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
  77. to select from a small amount of colors, and doesn't provide any visual feedback of the actual color chosen.
  78. </p>
  79. <p>
  80. Editing color values as color components or encoded strings is both impractical and unintuitive.
  81. </p>
  82. <p>
  83. 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
  84. instead of forcing the user to enter an encoded color value. For clients not supporting this extensions, the color value will still be editable
  85. as an encoded color string.
  86. </p>
  87. <p>
  88. This extension also relies on &xep0122; as a fallback mechanism so clients not recognizing the color data types can handle them as
  89. strings with a regular expressions validating user input.
  90. </p>
  91. </section1>
  92. <section1 topic='Publishing a Color Field in a Data Form'>
  93. <p>
  94. The following example shows how to publish a Color Field parameter in a Data Form:
  95. </p>
  96. <example caption='Publishing a Color Field in a Data Form'>
  97. <![CDATA[
  98. <field var='color' type='text-single' label='Color:'>
  99. <desc>Choose a color.</desc>
  100. <xdv:validate xmlns:xdv='http://jabber.org/protocol/xdata-validate'
  101. xmlns:xdc='urn:xmpp:xdata:color'
  102. datatype='xdc:Color'>
  103. <xdv:regex>^[0-9a-fA-F]{6}$</xdv:regex>
  104. </xdv:validate>
  105. <value>9400D3</value>
  106. </field>]]>
  107. </example>
  108. <p>
  109. The color value is represented by a string consisting of six case-insensitive hexadecimal digits. The first two represent the red component,
  110. the next two the green component and the last two the blue component.
  111. </p>
  112. <p>
  113. If the client does not support XEP-0122 (Data Form Validation), it will interpret the field as a normal <strong>text-single</strong> field. It is
  114. up to the server to validate user input. But the user can still enter a color.
  115. </p>
  116. <p>
  117. A client that supports XEP-0122 (Data Form Validation), but not this extension, will not understand the data type <strong>xdc:Color</strong>.
  118. It will thus default to a normal string (xs:string). However, the client still supports the <strong>regex</strong> validation rule,
  119. making sure the client only allows user input that forms valid color values.
  120. </p>
  121. <p>
  122. A client supporting this specification will recognize the <strong>xdc:Color</strong> data type, and choose to show a color picker dialog instead
  123. 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
  124. directly by the user. However, it is still available implicitly in the xdc:Color data type.
  125. </p>
  126. </section1>
  127. <section1 topic='Publishing a Color Field with Alpha channel in a Data Form'>
  128. <p>
  129. The following example shows how to publish a Color Field parameter including an Alpha channel in a Data Form:
  130. </p>
  131. <example caption='Publishing a Color Field in a Data Form'>
  132. <![CDATA[
  133. <field var='color' type='text-single' label='Color:'>
  134. <desc>Choose a color.</desc>
  135. <xdv:validate xmlns:xdv='http://jabber.org/protocol/xdata-validate'
  136. xmlns:xdc='urn:xmpp:xdata:color'
  137. datatype='xdc:ColorAlpha'>
  138. <xdv:regex>^[0-9a-fA-F]{8}$</xdv:regex>
  139. </xdv:validate>
  140. <value>9400D3C0</value>
  141. </field>]]>
  142. </example>
  143. <p>
  144. The color value is represented by a string consisting of eight case-insensitive hexadecimal digits. The first two represent the red component,
  145. the next two the green component and the last two the blue component. The last two represents the alpha channel, where 00 means completely
  146. transparent and FF means completely opaque.
  147. </p>
  148. <p>
  149. 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
  150. normal <strong>text-single</strong> field. It is up to the server to validate user input. But the user can still enter a color.
  151. </p>
  152. <p>
  153. A client that supports XEP-0122 (Data Form Validation), but not this extension, will not understand the data type <strong>xdc:ColorAlpha</strong>.
  154. It will thus default to a normal string (xs:string). However, the client still supports the <strong>regex</strong> validation rule,
  155. making sure the client only allows user input that forms valid color values.
  156. </p>
  157. <p>
  158. A client supporting this specification will recognize the <strong>xdc:ColorAlpha</strong> data type, and choose to show a color picker dialog instead
  159. 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
  160. directly by the user. However, it is still available implicitly in the xdc:ColorAlpha data type.
  161. </p>
  162. </section1>
  163. <section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  164. <section2 topic='Color datatype prefix: xdc'>
  165. <p>
  166. As defined in <link url='http://xmpp.org/extensions/xep-0122.html#registar-reg-prefixes'>XEP-0122 §7.2.1</link>, following is the submission
  167. to the XMPP Registrar of a new datatype prefix for use in data forms:
  168. </p>
  169. <code caption='Color datatype prefix: xdc'>
  170. <![CDATA[
  171. <datatype-prefix>
  172. <prefix>xdc</prefix>
  173. <desc>defines the Color data type</desc>
  174. <doc>http://xmpp.org/extensions/xep-0331.html</doc>
  175. </datatype-prefix>]]>
  176. </code>
  177. </section2>
  178. <section2 topic='Color datatype'>
  179. <p>
  180. As defined in <link url='http://xmpp.org/extensions/xep-0122.html#registar-reg-datatypes'>XEP-0122 §7.2.2</link>, following is the submission
  181. to the XMPP Registrar of a new datatype representing color values for use in data forms:
  182. </p>
  183. <code caption='Color datatype'>
  184. <![CDATA[
  185. <datatype>
  186. <name>xdc:Color</name>
  187. <desc>a color value represented as an RGB value, expressed using 6 hexadecimal digits, with each pair of
  188. the hexadecimal digits representing the values of the Red, Green and Blue channel, respectively</desc>
  189. <methods>basic regex</methods>
  190. <min>N/A</min>
  191. <max>N/A</max>
  192. </datatype>]]>
  193. </code>
  194. </section2>
  195. <section2 topic='ColorAlpha datatype'>
  196. <p>
  197. As defined in <link url='http://xmpp.org/extensions/xep-0122.html#registar-reg-datatypes'>XEP-0122 §7.2.2</link>, following is the submission
  198. to the XMPP Registrar of a new datatype representing color values with alpha channel for use in data forms:
  199. </p>
  200. <code caption='ColorAlpha datatype'>
  201. <![CDATA[
  202. <datatype>
  203. <name>xdc:ColorAlpha</name>
  204. <desc>a color value represented as an RGBA value, expressed using 8 hexadecimal digits, with each pair of
  205. the hexadecimal digits representing the values of the Red, Green, Blue and Alpha channel, respectively</desc>
  206. <methods>basic regex</methods>
  207. <min>N/A</min>
  208. <max>N/A</max>
  209. </datatype>]]>
  210. </code>
  211. </section2>
  212. </section1>
  213. <section1 topic='XML Schema' anchor='schema'>
  214. <code>
  215. <![CDATA[
  216. <?xml version='1.0' encoding='UTF-8'?>
  217. <xs:schema
  218. xmlns:xs='http://www.w3.org/2001/XMLSchema'
  219. targetNamespace='urn:xmpp:xdata:color'
  220. xmlns='urn:xmpp:xdata:color'
  221. elementFormDefault='qualified'>
  222. <xs:simpleType name='Color'>
  223. <xs:restriction base='xs:string'>
  224. <xs:pattern value='^[0-9a-fA-F]{6}$'/>
  225. </xs:restriction>
  226. </xs:simpleType>
  227. <xs:simpleType name='ColorAlpha'>
  228. <xs:restriction base='xs:string'>
  229. <xs:pattern value='^[0-9a-fA-F]{8}$'/>
  230. </xs:restriction>
  231. </xs:simpleType>
  232. </xs:schema>]]>
  233. </code>
  234. </section1>
  235. <section1 topic='Acknowledgements' anchor='ack'>
  236. <p>Thanks to Karin Forsell for all valuable feedback.</p>
  237. </section1>
  238. </xep>