<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep xmlns="">
<header>
  <title>Data Forms Validation</title>
  <abstract>This specification defines a backwards-compatible extension to the XMPP Data Forms protocol that enables applications to specify additional validation guidelines related to a form, such as validation of standard XML datatypes, application-specific datatypes, value ranges, and regular expressions.</abstract>
  
<legal>
<copyright>This XMPP Extension Protocol is copyright © 1999 – 2024 by the <link url="https://xmpp.org/">XMPP Standards Foundation</link> (XSF).</copyright>
<permissions>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.</permissions>
<warranty>## 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. ##</warranty>
<liability>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.</liability>
<conformance>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 &lt;<link url="https://xmpp.org/about/xsf/ipr-policy">https://xmpp.org/about/xsf/ipr-policy</link>&gt; or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).</conformance>
</legal>
  <number>0122</number>
  <status>Draft</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
    <spec>XEP-0004</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>xdata-validate</shortname>
  <schemaloc>
    <url>http://www.xmpp.org/schemas/xdata-validate.xsd</url>
  </schemaloc>
  <registry/>
  
  <author>
    <firstname>Matthew</firstname>
    <surname>Miller</surname>
    <email>linuxwolf@outer-planes.net</email>
    <jid>linuxwolf@outer-planes.net</jid>
  </author>

  <revision>
    <version>1.0.2</version>
    <date>2018-03-21</date>
    <initials>fs</initials>
    <remark>Remove text about element emptiness.</remark>
  </revision>
 <revision>
    <version>1.0.1</version>
    <date>2018-03-05</date>
    <initials>fs</initials>
    <remark>Move normative language from footnote into text.</remark>
  </revision>
  <revision>
    <version>1.0</version>
    <date>2004-09-22</date>
    <initials>psa</initials>
    <remark>Per a vote of the Jabber Council, advanced status to Draft.</remark>
  </revision>
  <revision>
    <version>0.8</version>
    <date>2004-09-20</date>
    <initials>lw</initials>
    <remark>Synchronized descriptive text with schema.</remark>
  </revision>
  <revision>
    <version>0.7</version>
    <date>2004-08-23</date>
    <initials>lw</initials>
    <remark>Replaced method attribute with dedicated elements; removed Formal Definition section in favor of defining requirements within the use-cases and XML schema; included display considerations; added reference to XEP-0115.</remark>
  </revision>
  <revision>
    <version>0.6</version>
    <date>2004-07-23</date>
    <initials>lw/psa</initials>
    <remark>Replaced &lt;text-list/&gt; with specific interpretations for other validation methods; Further clarified use of validation methods (other than "basic") with "list-single", "list-multi", and "text-multi"; Fixed errors in some examples; initial datatype registrations.</remark>
  </revision>
  <revision>
    <version>0.5</version>
    <date>2004-05-27</date>
    <initials>lw</initials>
    <remark>Added &lt;text-list/&gt; ("text as a list") support; Clarified &lt;list-range/&gt; expanded discussion on datatype registries.</remark>
  </revision>
  <revision>
    <version>0.4</version>
    <date>2004-01-29</date>
    <initials>lw</initials>
    <remark>Removed "std" datatypes; Added references to XML Schema built-in datatypes.</remark>
  </revision>
  <revision>
    <version>0.3</version>
    <date>2003-12-10</date>
    <initials>lw</initials>
    <remark>Added "open" method; Added "list-range" validation.</remark>
  </revision>
  <revision>
    <version>0.2</version>
    <date>2003-10-15</date>
    <initials>lw</initials>
    <remark>Added consideration about "unvalidated" submits; Reworked introduction.</remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2003-10-06</date>
    <initials>lw</initials>
    <remark>Initial version.</remark>
  </revision>
</header>
<section1 topic="Introduction" anchor="intro">
  <p><span class="ref"><link url="https://xmpp.org/extensions/xep-0004.html">Data Forms (XEP-0004)</link></span> <note>XEP-0004: Data Forms &lt;<link url="https://xmpp.org/extensions/xep-0004.html">https://xmpp.org/extensions/xep-0004.html</link>&gt;.</note> ("x:data") provides a simple and interoperable way to request and present information for both applications and humans. However, the simple nature of "x:data" requires the form interpreter at times to guess as to exactly what type of information is being requested or provided. This document builds upon "x:data" to provide this additional validation.</p>
</section1>
<section1 topic="Requirements" anchor="reqs">
  <p>The requirements for this document are:</p>
  <ul>
    <li>Backwards compatible with the existing "x:data" protocol.</li>
    <li>Provide extended datatypes (such as dates, times, and numbers).</li>
    <li>Allow for multiple validation methods.</li>
    <li>Allow for user-defined datatypes.</li>
    <li>Accommodate value ranges.</li>
    <li>Accommodate regular expression matching.</li>
  </ul>
</section1>
<section1 topic="Use Cases" anchor="usecases">
  <p>This document defines a new namespace, "http://jabber.org/protocol/xdata-validate". The root element for this namespace is &lt;validate/&gt;, and MUST be contained within a &lt;field/&gt; element (qualified by the 'jabber:x:data' namespace) for each <cite>Data Forms</cite> field that possesses additional validation information.</p>
  <section2 topic="Datatype Validation" anchor="usecases-datatypes">
    <p>The simplest usage is to provide a more-granular datatype for a &lt;field/&gt; element used in <cite>Data Forms</cite>. To provide this datatype information, a &lt;validate/&gt; element is included whose 'datatype' attribute specifies the data type of any &lt;value/&gt; contained within the &lt;field/&gt; element:</p>
    <example caption="Field with extended datatype"><![CDATA[
<field var='evt.date' type='text-single' label='Event Date/Time'>
  <validate xmlns='http://jabber.org/protocol/xdata-validate'
            datatype='xs:dateTime'/>
  <value>2003-10-06T11:22:00-07:00</value>
</field>
]]></example>
    <p>The preceding example demonstrates a field that is expected to contain a date/time value.</p>
    <p>The 'datatype' attribute specifies the datatype. This attribute is OPTIONAL, and defaults to "xs:string". It MUST meet one of the following conditions:</p>
    <ul>
      <li>Start with "xs:", and be one of the "built-in" datatypes defined in <span class="ref"><link url="http://www.w3.org/TR/xmlschema11-2/">XML Schema Part 2</link></span> <note>XML Schema Part 2: Datatypes &lt;<link url="http://www.w3.org/TR/xmlschema11-2/">http://www.w3.org/TR/xmlschema11-2/</link>&gt;.</note></li>
      <li>Start with a prefix registered with the <span class="ref"><link url="https://xmpp.org/registrar/">XMPP Registrar</link></span> <note>The XMPP Registrar maintains a list of reserved protocol namespaces as well as registries of parameters used in the context of XMPP extension protocols approved by the XMPP Standards Foundation. For further information, see &lt;<link url="https://xmpp.org/registrar/">https://xmpp.org/registrar/</link>&gt;.</note></li>
      <li>Start with "x:", and specify a user-defined datatype.</li>
    </ul>
	<p>Note that while "x:" allows for ad-hoc definitions, its use is NOT RECOMMENDED.</p>
  </section2>
  <section2 topic="Validation Methods" anchor="usecases-validation">
    <p>In addition to datatypes, the validation method can also be provided. The method is specified via a child element. The validation methods defined in this document are:</p>
    <ul>
      <li>&lt;basic/&gt; for validation only against the datatype itself</li>
      <li>&lt;open/&gt; for open-ended validation against the datatype</li>
      <li>&lt;range/&gt; for validation against a given min/max and the datatype</li>
      <li>&lt;regex/&gt; for validation against a given regular expression and the datatype</li>
    </ul>
    <p>If no validation method is specified, form processors MUST assume &lt;basic/&gt; validation. The &lt;validate/&gt; element SHOULD include one of the above validation method elements, and MUST NOT include more than one.</p>
    <p>Any validation method applied to a field of type "list-multi", "list-single", or "text-multi" (other than &lt;basic/&gt;) MUST imply the same behavior as &lt;open/&gt;, with the additional constraints defined by that method.</p>
    <section3 topic="&lt;basic/&gt; Validation" anchor="usercases-validation.basic">
      <p>Building upon the earlier example, to indicate that the value(s) should simply match the field type and datatype constraints, the &lt;validate/&gt; element shall contain a &lt;basic/&gt; child element.</p>
      <example caption="Basic validation"><![CDATA[
<field var='evt.date' type='text-single' label='Event Date/Time'>
  <validate xmlns='http://jabber.org/protocol/xdata-validate'
            datatype='xs:dateTime'>
    <basic/>
  </validate>
  <value>2003-10-06T11:22:00-07:00</value>
</field>
]]></example>
      <p>Using &lt;basic/&gt; validation, the form interpreter MUST follow the validation rules of the datatype (if understood) and the field type.</p>
    </section3>
    <section3 topic="&lt;open/&gt; Validation" anchor="usercases-validation.open">
      <p>For "list-single" or "list-multi", to indicate that the user may enter a custom value (matching the datatype constraints) or choose from the predefined values, the &lt;validate/&gt; element shall contain an &lt;open/&gt; child element:</p>
      <example caption="Open validation"><![CDATA[
<field var='evt.category'
       type='list-single'
       label='Event Category'>
  <validate xmlns='http://jabber.org/protocol/xdata-validate'
            datatype='xs:string'>
    <open/>
  </validate>
  <option><value>holiday</value></option>
  <option><value>reminder</value></option>
  <option><value>appointment</value></option>
</field>
]]></example>
      <p>The &lt;open/&gt; validation method applies to "text-multi" differently; it hints that each value for a "text-multi" field shall be validated separately. This effectively turns "text-multi" fields into an open-ended "list-multi", with no options and all values automatically selected.</p>
    </section3>
    <section3 topic="&lt;range/&gt; Validation" anchor="usercases-validation.range">
      <p>To indicate that the value should fall within a certain range, the &lt;validate/&gt; element shall contain a &lt;range/&gt; child element:</p>
      <example caption="Range validation"><![CDATA[
<field var='evt.date' type='text-single' label='Event Date/Time'>
  <validate xmlns='http://jabber.org/protocol/xdata-validate'
            datatype='xs:dateTime'>
    <range min='2003-10-05T00:00:00-07:00'
           max='2003-10-24T23:59:59-07:00'/>
  </validate>
  <value>2003-10-06T11:22:00-07:00</value>
</field>
]]></example>
      <p>The 'min' and 'max' attributes of the &lt;range/&gt; element specify the minimum and maximum values allowed, respectively.</p>
      <p>The 'max' attribute specifies the maximum allowable value. This attribute is OPTIONAL. The value depends on the datatype in use.</p>
      <p>The 'min' attribute specifies the minimum allowable value. This attribute is OPTIONAL. The value depends on the datatype in use.</p>
      <p>The &lt;range/&gt; element SHOULD possess either a 'min' or 'max' attribute, and MAY possess both. If neither attribute is included, the processor MUST assume that there are no range constraints.</p>
    </section3>
    <section3 topic="&lt;regex/&gt; Validation" anchor="usercases-validatoin.regex">
      <p>To indicate that the value should be restricted to a regular expression, the &lt;validate/&gt; element shall contain a &lt;regex/&gt; child element:</p>
      <example caption="Regular expression validation"><![CDATA[
<field var='ssn' type='text-single' label='Social Security Number'>
  <desc>This field should be your SSN, including '-' (e.g. 123-12-1234)</desc>
  <validate xmlns='http://jabber.org/protocol/xdata-validate'
            datatype='xs:string'>
    <regex>([0-9]{3})-([0-9]{2})-([0-9]{4})</regex>
  </validate>
</field>
]]></example>
      <p>The XML character data of this element is the pattern to apply. The syntax of this content MUST be that defined for POSIX extended regular expressions<note>The "best" definition of this syntax can be found in the <link url="http://www.gsp.com/cgi-bin/man.cgi?section=7&amp;topic=re_format">re_format(7) man page</link></note>, including support for Unicode<note>Guidelines for adapting regular expressions to support Unicode is defined at <link url="http://www.unicode.org/reports/tr18/">http://www.unicode.org/reports/tr18/</link></note>.</p>
      <p>The &lt;regex/&gt; element MUST contain character data only.</p>
    </section3>
  </section2>
  <section2 topic="Selection Ranges in &quot;list-multi&quot;" anchor="usecases-ranges">
    <p>For "list-multi", validation can indicate (via the &lt;list-range/&gt; element) that a minimum and maximum number of options should be selected and/or entered. This selection range MAY be combined with the other methods to provide more flexibility.</p>
    <example caption="Selection Range validation"><![CDATA[
<field var='evt.notify-methods'
       type='list-multi'
       label='Notify me by'>
  <validate xmlns='http://jabber.org/protocol/xdata-validate'
            datatype='xs:string'>
    <basic/>
    <list-range min='1' max='3'/>
  </validate>
  <option><value>e-mail</value></option>
  <option><value>jabber/xmpp</value></option>
  <option><value>work phone</value></option>
  <option><value>home phone</value></option>
  <option><value>cell phone</value></option>
</field>
]]></example>
    <p>The &lt;list-range/&gt; element SHOULD be included only when the &lt;field/&gt; is of type "list-multi" and SHOULD be ignored otherwise.</p>
    <p>The 'max' attribute specifies the maximum allowable number of selected/entered values. This attribute is OPTIONAL. The value MUST be a positive integer.</p>
    <p>The 'min' attribute specifies the minimum allowable number of selected/entered values. This attribute is OPTIONAL. The value MUST be a positive integer.</p>
    <p>The &lt;list-range/&gt; element SHOULD possess either a 'min' or 'max' attribute, and MAY possess both. If neither attribute is included, the processor MUST assume that there are no selection constraints.</p>
  </section2>
</section1>
<section1 topic="Implementation Notes" anchor="impl">
  <section2 topic="Required to Support" anchor="impl-req">
    <p>At a minimum, implementations MUST support the following:</p>
    <ul>
      <li>Datatype validation</li>
      <li>The &lt;basic/&gt; validation method</li>
    </ul>
    <p>If an implementation does not understand the specified datatype, it MUST validate according to the default "xs:string" datatype. If an implementation does not understand the specified method, it MUST validate according to the &lt;basic/&gt; method.</p>
  </section2>
  <section2 topic="Namespacing" anchor="impl-ns">
    <p>While all elements associated with this document MUST be qualified by the 'http://jabber.org/protocol/xdata-validate' namespace, explicitly declaring the default namespace for each instance can be overly verbose. However, Jabber/XMPP implementations have historically been very lax regarding namespacing, thus requiring some careful use of prefixes.</p>
    <p>The use of namespace prefixes is RECOMMENDED for large forms, to reduce the data size. To maintain the highest level of compatibility, implementations sending the form using prefixes SHOULD use the namespace prefix "xdv", and SHOULD declare the namespace prefix mapping in the ancestor &lt;x xmlns='jabber:x:data'/&gt; element:</p>
    <example caption="Example of recommended namespace prefixing"><![CDATA[
<x xmlns='jabber:x:data'
   xmlns:xdv='http://jabber.org/protocol/xdata-validate'
   type='form'>
  <title>Sample Form</title>
  <instructions>
    Please provide information for the following fields...
  </instructions>
  <field type='text-single' var='name' label='Event Name'/>
  <field type='text-single' var='date/start' label='Starting Date'>
    <xdv:validate datatype='xs:date'>
      <basic/>
    </xdv:validate>
  </field>
  <field type='text-single' var='date/end' label='Ending Date'>
    <xdv:validate datatype='xs:date'>
      <basic/>
    </xdv:validate>
  </field>
</x>
]]></example>
  </section2>
  <section2 topic="Internationalization/Localization" anchor="impl-i18n">
    <p>This document relies on the internationalization/localization mechanisms provided by <span class="ref"><link url="http://tools.ietf.org/html/rfc6120">XMPP Core</link></span> <note>RFC 6120: Extensible Messaging and Presence Protocol (XMPP): Core &lt;<link url="http://tools.ietf.org/html/rfc6120">http://tools.ietf.org/html/rfc6120</link>&gt;.</note>. As much as possible, all datatype formats MUST be locale-independent.</p>
  </section2>
  <section2 topic="Form Submissions" anchor="impl-submit">
    <p>Form processors MUST NOT assume that a form with validation has actually been validated when submitted. There is no realistic expectation that form interpreters honor validation.</p>
  </section2>
  <section2 topic="Existing Protocols" anchor="impl-proto">
    <p>While this document is compatible with the existing "x:data" definition, form providers SHOULD first determine support for it, using either <span class="ref"><link url="https://xmpp.org/extensions/xep-0115.html">Entity Capabilities (XEP-0115)</link></span> <note>XEP-0115: Entity Capabilities &lt;<link url="https://xmpp.org/extensions/xep-0115.html">https://xmpp.org/extensions/xep-0115.html</link>&gt;.</note> if presence-aware or <span class="ref"><link url="https://xmpp.org/extensions/xep-0030.html">Service Discovery (XEP-0030)</link></span> <note>XEP-0030: Service Discovery &lt;<link url="https://xmpp.org/extensions/xep-0030.html">https://xmpp.org/extensions/xep-0030.html</link>&gt;.</note>. This is especially important for limited-connection and/or limited-capabilities devices, such as cell phones.</p>
  </section2>
  <section2 topic="Display Considerations" anchor="impl-display">
    <p>Although primarily intended for validating form submission, validation MAY have an impact on display, and MAY be applied to data forms that are not submitted (e.g. 'result' type forms). The following table outlines which field types a particular validation method is or is not appropriate for, and how a display SHOULD interpret the validation methods if considered<note>If a particular field type is not listed, the display MAY include validation support, but is not expected to do so.</note>:</p>
    <table caption="Validation Methods and Field Types">
      <tr>
        <th>Validation Method</th>
        <th>SHOULD be Allowed</th>
        <th>SHOULD NOT be Allowed</th>
        <th>Display Suggestions</th>
      </tr>

      <tr>
        <td>basic</td>
        <td><ul>
          <li>fixed</li>
          <li>list-multi</li>
          <li>list-single</li>
          <li>text-multi</li>
          <li>text-single</li>
        </ul></td>
        <td><ul>
          <li>hidden</li>
          <li>jid-multi</li>
          <li>jid-single</li>
        </ul></td>
        <td>Display the datatype appropriate to the locale</td>
      </tr>

      <tr>
        <td>open</td>
        <td><ul>
          <li>jid-multi</li>
          <li>jid-single</li>
          <li>list-multi</li>
          <li>list-single</li>
          <li>text-multi</li>
          <li>text-single</li>
        </ul></td>
        <td><ul>
          <li>hidden</li>
        </ul></td>
        <td>Display the datatype appropriate to the locale. For "text-multi" treat each value as a discrete entry (e.g. a user-entered list). For "list-multi" or "list-single", allow user to add/remove entries to select.</td>
      </tr>

      <tr>
        <td>range</td>
        <td><ul>
          <li>text-single</li>
        </ul></td>
        <td><ul>
          <li>hidden</li>
          <li>jid-multi</li>
          <li>list-multi</li>
          <li>text-multi</li>
        </ul></td>
        <td>Display the datatype appropriate to the locale. For "text-single", allow user to increment/decrement through possible values. For "text-multi" treat each value as a discrete entry (e.g. a user-entered list). For "list-multi" or "list-single", allow user to add/remove entries to select.</td>
      </tr>

      <tr>
        <td>regex</td>
        <td><ul>
          <li>text-single</li>
        </ul></td>
        <td><ul>
          <li>hidden</li>
          <li>jid-multi</li>
          <li>list-multi</li>
          <li>text-multi</li>
        </ul></td>
        <td>Display the datatype appropriate to the locale. If possible, display a valid example. For "text-multi" treat each value as a discrete entry (e.g. a user-entered list). For "list-multi" or "list-single", allow user to add/remove entries to select.</td>
      </tr>
    </table>
  </section2>
  <section2 topic="Validation Ranges" anchor="impl-ranges">
    <p>The &lt;range/&gt; validation method MUST be used only with datatypes that have finite quantities.  Within the standard datatype set, it MUST NOT be used with "xs:string".</p>
  </section2>
</section1>
<section1 topic="Security Considerations" anchor="sec">
  <p>This document introduces no security concerns above and beyond those specified in <cite>XEP-0004: Data Forms</cite>.</p>
</section1>
<section1 topic="IANA Considerations" anchor="iana">
  <p>This document requires no interaction with the <span class="ref"><link url="http://www.iana.org/">Internet Assigned Numbers Authority (IANA)</link></span> <note>The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see &lt;<link url="http://www.iana.org/">http://www.iana.org/</link>&gt;.</note>.</p>
</section1>
<section1 topic="XMPP Registrar Considerations" anchor="registrar">
  <section2 topic="Protocol Namespaces" anchor="registrar-ns">
    <p>The XMPP Registrar includes 'http://jabber.org/protocol/xdata-validate' in its registry of protocol namespaces.</p>
  </section2>
  <section2 topic="Registries" anchor="registrar-reg">
    <section3 topic="Datatype Prefixes Registry" anchor="registrar-reg-prefixes">
      <p>The XMPP Registrar maintains a registry of datatype prefixes used in the context of Data Forms Validation (see &lt;<link url="https://xmpp.org/registrar/xdv-prefixes.html">https://xmpp.org/registrar/xdv-prefixes.html</link>&gt;), where each prefix denotes a group of related datatypes.</p>
      <section4 topic="Process" anchor="registrar-reg-prefixes-process">
        <p>In order to submit new values to this registry, the registrant shall define an XML fragment of the following form and either include it in the relevant XMPP Extension Protocol or send it to the email address &lt;registrar@xmpp.org&gt;:</p>
        <code><![CDATA[
<datatype-prefix>
  <prefix>the prefix token (e.g., "xs")</prefix>
  <desc>a natural-language description of the datatype family</desc>
  <doc>the document in which datatype family is specified</doc>
</datatype-prefix>
]]></code>
         <p>The registrant may register more than one prefix at a time, each contained in a separate &lt;datatype-prefix/&gt; element.</p>
       </section4>
       <section4 topic="Initial Submission" anchor="registrar-reg-prefixes-init">
         <p>As part of this document, the following datatype prefixes shall be registered:</p>
         <code><![CDATA[
<datatype-prefix>
  <prefix>x</prefix>
  <desc>An ad-hoc datatype</desc>
  <doc>XEP-0122</doc>
</datatype-prefix>
<datatype-prefix>
  <prefix>xs</prefix>
  <desc>A "standard" datatype as defined in XML Schema Part 2</desc>
  <doc>XML Schema Part 2</doc>
</datatype-prefix>
]]></code>
      </section4>
    </section3>
    <section3 topic="Datatypes Registry" anchor="registrar-reg-datatypes">
      <p>The XMPP Registrar maintains a registry of datatypes used in the context of Data Forms Validation (see &lt;<link url="https://xmpp.org/registrar/xdv-datatypes.html">https://xmpp.org/registrar/xdv-datatypes.html</link>&gt;), where each datatype name includes the relevant prefix (e.g., "xs:anyURI").</p>
      <section4 topic="Process" anchor="registrar-reg-datatypes-process">
        <p>In order to submit new values to this registry, the registrant shall define an XML fragment of the following form and either include it in the relevant XMPP Extension Protocol or send it to the email address &lt;registrar@xmpp.org&gt;:</p>
        <code><![CDATA[
<datatype>
  <name>the full datatype name (e.g., "xs:string")</name>
  <desc>a natural-language description of the datatype</desc>
  <methods>the validation methods that may apply to the datatype</methods>
  <min>the minimum value for the datatype (if any)</min>
  <max>the maximum value for the datatype (if any)</max>
</datatype>
]]></code>
        <p>The registrant may register more than one datatype at a time, each contained in a separate &lt;datatype/&gt; element.</p>
      </section4>
      <section4 topic="Initial Submission" anchor="registrar-reg-datatypes-init">
        <p>The following submission contains the built-in datatypes defined in <cite>XML Schema Part 2</cite> that are deemed mostly like to be useful in the context of the Data Forms protocol; additional datatypes defined therein, as well as other datatypes not defined in XML Schema Part 2, may be registered via separate submissions in the future.</p>
        <code><![CDATA[
<datatype>
  <name>xs:anyURI</name>
  <desc>a Uniform Resource Identifier Reference (URI)</desc>
  <methods>basic regex</methods>
  <min>N/A</min>
  <max>N/A</max>
</datatype>
<datatype>
  <name>xs:byte</name>
  <desc>an integer with the specified min/max</desc>
  <methods>basic range</methods>
  <min>-128</min>
  <max>127</max>
</datatype>
<datatype>
  <name>xs:date</name>
  <desc>a calendar date</desc>
  <methods>basic range regex</methods>
  <min>N/A</min>
  <max>N/A</max>
</datatype>
<datatype>
  <name>xs:dateTime</name>
  <desc>a specific instant of time</desc>
  <methods>basic range regex</methods>
  <min>N/A</min>
  <max>N/A</max>
</datatype>
<datatype>
  <name>xs:decimal</name>
  <desc>an arbitrary-precision decimal number</desc>
  <methods>basic range</methods>
  <min>none</min>
  <max>none</max>
</datatype>
<datatype>
  <name>xs:double</name>
  <desc>an IEEE double-precision 64-bit floating point type</desc>
  <methods>basic range</methods>
  <min>none</min>
  <max>none</max>
</datatype>
<datatype>
  <name>xs:int</name>
  <desc>an integer with the specified min/max</desc>
  <methods>basic range</methods>
  <min>-2147483648</min>
  <max>2147483647</max>
</datatype>
<datatype>
  <name>xs:integer</name>
  <desc>a decimal number with no fraction digits</desc>
  <methods>basic range</methods>
  <min>none</min>
  <max>none</max>
</datatype>
<datatype>
  <name>xs:language</name>
  <desc>a language identifier as defined by RFC 1766</desc>
  <methods>basic regex</methods>
  <min>N/A</min>
  <max>N/A</max>
</datatype>
<datatype>
  <name>xs:long</name>
  <desc>an integer with the specified min/max</desc>
  <methods>basic range</methods>
  <min>-9223372036854775808</min>
  <max>9223372036854775807</max>
</datatype>
<datatype>
  <name>xs:short</name>
  <desc>an integer with the specified min/max</desc>
  <methods>basic range</methods>
  <min>-32768</min>
  <max>32767</max>
</datatype>
<datatype>
  <name>xs:string</name>
  <desc>a character strings in XML</desc>
  <methods>basic regex</methods>
  <min>N/A</min>
  <max>N/A</max>
</datatype>
<datatype>
  <name>xs:time</name>
  <desc>an instant of time that recurs every day</desc>
  <methods>basic range regex</methods>
  <min>N/A</min>
  <max>N/A</max>
</datatype>
]]></code>
      </section4>
    </section3>
  </section2>
</section1>
<section1 topic="XML Schema" anchor="schema">
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='http://jabber.org/protocol/xdata-validate'
    xmlns='http://jabber.org/protocol/xdata-validate'
    elementFormDefault='qualified'>

  <xs:element name='validate'>
    <xs:complexType>
      <xs:sequence>
        <xs:choice minOccurs='0' maxOccurs='1'>
          <xs:element ref='basic'/>
          <xs:element ref='open'/>
          <xs:element ref='range'/>
          <xs:element ref='regex'/>
        </xs:choice>
        <xs:element ref='list-range' minOccurs='0' maxOccurs='1'/>
      </xs:sequence>
      <xs:attribute name='datatype'
                    type='xs:string'
                    use='optional'
                    default='xs:string'/>
    </xs:complexType>
  </xs:element>

  <xs:element name='basic' type='empty'/>

  <xs:element name='open' type='empty'/>

  <xs:element name='range'>
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base='empty'>
          <xs:attribute name='min' use='optional'/>
          <xs:attribute name='max' use='optional'/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:element name='regex' type='xs:string'/>

  <xs:element name='list-range'>
    <xs:complexType>
      <xs:simpleContent>
        <xs:extension base='empty'>
          <xs:attribute name='min'
                        type='xs:unsignedInt'
                        use='optional'/>
          <xs:attribute name='max'
                        type='xs:unsignedInt'
                        use='optional'/>
        </xs:extension>
      </xs:simpleContent>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name='empty'>
    <xs:restriction base='xs:string'>
      <xs:enumeration value=''/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>
]]></code>
</section1>
</xep>
