Presentation settings

Presentation settings control the output of the text. For example, you can specify that the text should include a currency symbol or that it should round all numbers up. There is no limit to the number of presentation settings that you can set for an item.

Presentation settings follow this syntax:

   <format>
      <presentation>
         <settingname1>setting</settingname1>
         ...
         <settingnamen>setting</settingnamen>
      </presentation>
   </format>

The following list defines the valid settings:

calendar
This sets which calendar is used for formatting dates. It supports the following settings:
  • gregorian – A solar calendar. The primary calendar for North America.
  • japanese – A Japanese era calendar (based on the reign of the current emperor). Used in Japan, along with Gregorian calendar. The calendar identifies the year by the combination of the emperor name and the year number within the era (For example 2008 is Heisei 20). For more information see style under).

Using this setting forces the calendar to be type selected, regardless of the locale of the form. This setting is only valid for date types, such as date, time, and so on.

Default for en_US locale: gregorian.

Default for other locales:gregorian.

casetype
Forces the value to be set to a particular case. Valid settings are:
  • upper – Sets all letters to uppercase.
  • lower – Sets all letters to lowercase.
  • title – Capitalizes the first letter of each word.
  • none – Leaves the capitalization unchanged.

This setting is only valid for string and date (date, time, and so on) data types.

Default: none.

currencylocale
Allows you to set a different locale for a particular currency field. For example, you could set one field to use US dollars and another field to use British pounds.

Valid settings include all valid locales. For a complete list of locales and their corresponding codes, see Locale Specification for XFDL.

Note that this setting does not convert currencies in any way.

Default: the locale of the form.

decimalseparator
The symbol(s) used to separate the decimal place. This is often a period, as shown:
   100.00

You can use any string. This setting is only valid for int, float, and currency data types.

Default for en_US locale: a period.

Default for other locales: refer to the Locale Specification for XFDL.

fractiondigits
Sets the number of digits shown after the decimal place. For example, a setting of 3 would allow three digits after the decimal place, as shown:
   13.764

All values are rounded according to the round setting. If no round setting is specified, all values are rounded up. (See the round setting for an explanation of rounding up.)

Fractiondigits is only valid for float and currency data types. Note that setting both fractiondigits and significantdigits may cause conflicting formats. In this case, significantdigits takes precedence.

Default: the maximum number of digits allowed for the data type.

groupingseparator
The symbol(s) used to separate groups of numbers (for example, thousands in North America). This is often a comma, as shown:
   1,000,000

You can use any string, with the keyword none representing no separators at all. However, you should not use strings that already have a meaning, such as the period.

This setting is only valid for int, float, and currency data types.

Default for en_US locale: a comma.

Default for other locales: refer to the Locale Specification for XFDL.

keepformatindata
Sets whether formatting, such as dollar signs and other “decoration”, is maintained when the value is copied to the XForms model. Valid values are:
  • on – maintain all formatting.
  • off – strip all formatting.

Default: off.

negativeindicator
Sets the symbols that are used to indicate a negative value. You can place symbols both before and after the number by setting a prefix and a suffix. To do this, you must include the <prefix> and <suffix> tags in your definition, as shown:
   <negativeindicator>
      <prefix>prefix</prefix>
      <suffix>suffix</suffix>
   </negativeindicator>

The prefix and suffix are defined as strings. For example, if you set the prefix to an open bracket and the suffix to a close bracket, you will get a bracket negative. The following shows the bracket notation for negative 100:

   (100)

You can also leave either the prefix or suffix blank, so long as the other setting has a value.

Note:
  • The pattern setting overrides the negativeindicator setting.
  • Do not use this setting with currency data types.
  • Do not use symbols that already have meanings, such as the period.

Default for en_US locale: minus sign (-).

Default for other locales: refer to the Locale Specification for XFDL.

pad
Sets the number of digits to show, regardless of the value. For example, setting a pad of 5 would result in all numbers having five digits, as shown:
   00002
   00100

If the value has more characters than dictated by the pad setting, the value is not changed and is displayed as entered.

Pad is only valid for integer, float, and currency data types. Use the padcharacter setting to control which character is used to pad the value.

Default : 0 (no padding imposed).

padcharacter
Sets the character to use for padding. For example, if you set the padcharacter to a zero and the pad setting was 5, numbers would be displayed as follows:
   00010
   01245

You may only specify a single character as the pad character. Furthermore, you must use a pad character that is valid for your data type. For example, you cannot use a Z in an integer value.

Padcharacter is only valid for integer, float, and currency data types. Use the pad setting to control how many pad characters are used.

Default for en_US locale: 0.

Default for other locales: refer to the Locale Specification for XFDL.

pattern
Allows you to set a pattern for number and date data types. This pattern is used to display the data. For example, you might want all numbers to be formatted with two digits after the decimal place.

To learn how to represent number and date patterns, refer to Date patterns.

Note that the pattern setting overrides both the style and negativeindicator settings.

patternrefs
Allows you to set one or more patterns for string data types that are used to display the data. For example, you may want to ensure that all phone numbers are displayed with dashes, as shown: 250-604-8734.

You must define each pattern in its own <patternref> tag, as shown:

   <patternrefs>
      <patternref1>pattern</patternref1>
      ...
      <patternrefn>pattern</patternrefn>
   </patternrefs>

If you define only one pattern, that pattern is used for all input regardless of the number of constraints you define.

If you define more than one patternref, you must define an equal number of patterns in the constraints. Each pattern is then matched to the corresponding constraint. For example, the first pattern is matched to the first constraint, the second pattern is matched to the second constraint, and so on. This allows you to define a different pattern for each constraint.

To learn how to represent string patterns, refer to String patterns.

Note that the patternrefs setting overrides the style setting.

Default: as dictated by the style setting.

round
Determines how values are rounded. Valid settings are:
  • floor – Always rounds down, towards negative infinity. For example, $45.687 becomes $45.68. -$45.687 becomes -$45.69
  • ceiling – Always rounds up, towards positive infinity. For example, $45.687 becomes $45.69. -$45.687 becomes -$45.68.
  • up – Rounds away from zero. For example, $45.687 becomes $45.69 and -$45.687 becomes -$45.69.
  • down – Rounds towards zero. For example, $45.687 becomes $45.68 and -$45.687 becomes -$45.68.
  • half_up – Rounds values greater than 5 up, and values less than 5 down. For values equal to 5, it rounds up. For example, 46.5 becomes 47, while 46.4 becomes 46; -46.5 becomes -47 and -46.4 becomes -46.
  • half_down – Rounds values greater than 5 up, and values less than 5 down. For values equal to 5, it rounds down. For example, 46.5 becomes 46, while 46.6 becomes 47; -46.5 becomes -46, while -46.6 becomes -47.
  • half_even – Rounds values greater than 5 up, and values less than 5 down. For values equal to 5, rounds up if the preceding digit is odd, and down if the preceding digit is even. For example, 46.5 becomes 46, and 47.5 becomes 48; -46.5 becomes -47, and -47.5 becomes -47.

Round is only valid for integer, float, and currency data types.

Default: half_even.

showcurrency
Sets whether the appropriate currency symbol is shown. This is only valid for a currency data type. Valid settings are on, which shows the symbol, and off, which does not.

The symbol used is determined by the currencylocale setting. If there is no currencylocale setting, it defaults to normal currency symbol for the current locale.

Default: on.

significantdigits
Sets the number of significant digits allowed. This is generally the total number of digits allowed in the number. For example, 134.56 has five significant digits.

If the data entered exceeds the number of significant digits allowed, then only the least significant digits are shown. For example, if you allow five significant digits and 12,345.56 is entered, then only 12,345 is shown. If you allow five significant digits and 1,234,543.21 is entered, then only 1,234,500 is shown.

significantdigits is only valid for integer, float, and currency data types.

Note that setting both fractiondigits and significantdigits may cause conflicting formats. In this case, significantdigits takes precedence.

Default: the maximum number of digits allowed for the data type.

style
Sets how various data types are displayed. For example, you can use the style to set whether times include seconds, and whether dates are spelled out or numeric.

Valid settings are:

  • numeric
  • short
  • medium
  • long
  • full

For more information about how the styles affect the different data types, see Data type styles.

Note that both the pattern and patternrefs settings override the style setting.

Default: medium.