Examples

This example specifies a field containing integer data with a range of values from 10 to 1,000 inclusive, and formatted with commas separating the thousands:

   <format>
      <datatype>integer</datatype>
      <presentation>
         <groupingseparator>,<groupingseparator>
      </presentation>
      <constraints>
         <range>
            <min>10</min>
            <max>1000</max>
         </range>
      </constraints>
   </format>

This example specifies a field that contains currency data that is mandatory. An error message appears if the data is not entered correctly.

   <format>
      <datatype>currency</datatype>
      <constraints>
         <mandatory>on</mandatory>
         <message>Entry incorrect -- try again.</message>
      </constraints>
   </format>

This example specifies a field in which date data will be formatted as month, day-of-month, and year (for example, November 23, 2004):

   <format>
      <datatype>date</datatype>
      <presentation>
         <style>long</style>
      </presentation>
   </format>

This example sets up a template and patterns for both presentation and constraints. The template sets up a format of (###) ###-#### for a telephone number. This means that when the field is first displayed, it will show the parentheses and the dash to the user. The constraint pattern uses a regular expression to create the same pattern, thereby limiting the input to match the template. Finally, the presentation patternref uses a regular expression to define how the input should be formatted when displayed on the screen. This expression refers to the groups defined in the constraint pattern.

   <format>
      <datatype>string</datatype>
      <constraints>
         <template>(...) ...-....</template>
         <patterns>
            <pattern>\((\d{3})\)\s(\d{3})-(\d{4})</pattern>
         </patterns>
      </constraints>
      <presentation>
         <patternrefs>
            <patternref>($1) $2-$3</patternref>
         </patternrefs>
      </presentation>
   </format>