The following useful datatypes are either part of the XForms specification, or included from XML Schema. For each datatype, this section describes where it is defined, what conformance level of XForms it applies to, how the datatype is useful, caveats, and one or more examples.
Defined in: XML Schema part 2 As the least-restricted datatype, xs:string is the default datatype that XForms will use, unless the author specifies otherwise. Caveatsxs:string punts on all whitespace processing, so all tab characters and newline characters pass through unchanged. If this is undesired, it is better to use a more restricted datatype such as xs:normalizedString or xforms:listItem. Example
Defined in: XML Schema part 2 The only difference between this datatype and xs:string is that all whitespace characters are converted into space (0x20) characters. CaveatsWhitespace is normalized, but not collapsed. Thus, it is still possible for multiple consecutive whitespace characters to exist. Example
Defined in: XML Schema part 2 If a form collects the name of a human language, this is the datatype to use. CaveatsThe actual values that represent languages are subject to change over time. Examples
Defined in: XML Schema part 2 Simple on/off controls, such as a single checkbox, are naturally represented by a boolean datatype. CaveatsThe lexical space allows multiple representations, so any script or XPath function that reads a value of this datatype should be prepared to see either a string ("true" or "false") or a number (1 or 0). Examples
Defined in: XML Schema part 2 Any decimal number can be exactly represented by this datatype. CaveatsThe definition of this datatype defines no restrictions whatsoever on the size of numbers permissible under this datatype. Unless your form processing is prepared to deal with a number thousands of digits long (or even longer), you should use a restriction on the allowed upper and lower limits, and number of digits past the decimal point, as shown here: <xs:simpleType name="restrictedInteger"> <xs:restriction base="xs:decimal"> <xs:maxExclusive value="1000000"/> <xs:minInclusive value="-1000000"/> <xs:fractionDigits value='2'/> </xs:restriction> </xs:simpleType> Examples
Defined in: XML Schema part 2 This datatype is derived from xs:decimal, with the restriction that only whole numbers are permitted. CaveatsAs with xs:decimal, there is no inherent upper bound on the size of this datatype. Examples
Defined in: XML Schema part 2 This datatype is derived from xs:integer, with the restriction that positive values are not allowed. CaveatsThe same warnings about length of the lexical representation from xs:integer apply here. Examples
Defined in: XML Schema part 2 This datatype is derived from xs:integer, with the restriction that only negative values are allowed. CaveatsThe same warnings about length of the lexical representation from xs:integer apply here. Examples
Defined in: XML Schema part 2 This datatype is derived from xs:integer, with the restriction that negative values are not allowed. CaveatsThe same warnings about length of the lexical representation from xs:integer apply here. Examples
Defined in: XML Schema part 2 This datatype is derived from xs:integer, with the restriction that only positive values are allowed. CaveatsThe same warnings about length of the lexical representation from xs:integer apply here. Examples
Defined in: XML Schema part 2 This datatype maps directly to the XPath concept of number, and thus can be useful in situations where data flows back and forth between XPath and the XML instance data. CaveatsUnlike the decimal datatypes, xs:double is based on an internal binary representation, so many operations (particularly comparisons) are only approximations. The lexical space of this datatype allows scientific notation, so you need to be careful not to assume that any particular representation will always be used. Also, special values of NaN (not a number), INF (infinity), -INF (negative infinity), as well as negative zero, are possible. NaN in particular behaves strangely in comparisons, being equal to itself and greater than all other numbers, even INF! Examples
Defined in: XML Schema part 2 This datatype identifies a specific moment in time. CaveatsHaving our planet divided into time zones complicates matters, since one xs:dateTime with a time zone can't always be reliably compared to another without time zone information. Example
Defined in: XML Schema part 2 This datatype identifies a recurring point in time each day. CaveatsThe same time zone warnings apply as with other date and time datatypes. Additionally, keep in mind that this format is not useful for representing a duration. Example
Defined in: XML Schema part 2 This datatype identifies a particular period of time one day long. CaveatsAn optional time zone identifier on the end complicates matters, as is the case with xs:dateTime. Example
Defined in: XML Schema part 2 This datatype allows characters, including control characters, that otherwise aren't representable in XML. CaveatsBase64 encoding increases the size of any encoded data. Example
Defined in: XML Schema part 2 This datatype represents a URI, which includes web page addresses (commonly called URLs). CaveatsThe allowed characters in anyURI include spaces and other characters not usually found in URI syntax. Examples
Defined in: XForms 1.0 This datatype represents a duration of a certain number of months (and therefore years also). CaveatsIt's not possible to combine smaller durations, such as days, with xforms:yearMonthDuration without introducing ambiguity. For instance, a month and a day could be anywhere between 29 and 32 days. Examples
Defined in: XForms 1.0 This datatype represents a duration of a certain number of seconds (and from that, a number of days, hours, and minutes can be determined). CaveatsIt's not possible to combine larger durations, such as years, with xforms:dayTimeDuration without introducing ambiguity. Examples
Defined in: XForms 1.0 This datatype represents only non-whitespace characters, and thus makes an excellent base type for a whitespace-separated list datatype (namely xforms:listItems). CaveatsNone Examples
This datatype represents a space-separated list, and can be used directly with XForms list form controls. CaveatsNone. Examples
|