Where the XML Schema provides information about the allowed values of an element or attribute (and therefore of the corresponding field in the template), the field generated will include a JavaScript validate script that verifies that the value is one allowed by the schema declaration. Such information can be provided by way of the data type of the element or attribute and also by restriction facets applied to the base type. Consider the following example:The mapping will result in a Numeric field named “Number”, which has a validation script that validates that any value is an integer between 4 and 9.Many of the restriction facets provided by XML Schema provide information that might be used to generate a validation script. This information will only be used to generate validation scripts in cases where the information cannot be mapped directly to a property; for example, mapping the maxLength facet for a string type to <text maxChars=””>.All numeric types in XML Schema are mapped to a single numeric field. However, the additional restrictions imposed by an XML Schema numeric type are maintained by generating validate scripts to ensure that a number value is the range allowed for the original XML Schema type. An “unsigned byte” type in the XML Schema will generate a numeric field with a script to validate that the value is an unsigned byte value; that is, this is the generated script:
•
•
• When a numeric type specifies min or max inclusion and/or exclusion values, a script will be generated to test that the value entered is within the range defined by these restriction facets. For a
field that already has a numeric range script as defined in Numeric type scripts, the script will test the range according to the most restrictive of the datatype range or the inclusion/exclusion range.An XML Schema string type may specify a length restriction facet or a minLength and/or a maxLength restriction facet. If the schema node is mapped to a text field, values specified for length and minLength restriction facets will be used to generate a validate script to test that the text field length is the value specified by length or is at least the value specified by minLength.When a string datatype maps to a pop-up list (because of the enumerated values), and length or min/maxLength, values will result in the validate script to check that the value selected in the list has a length that is valid according to the length, minLength, and maxLength facets.The totalDigits facet specifies the maximum number of digits that can be used for a decimal or any integer type (that is, decimal, integer, positive integer, negative integer, non-positive integer, non-negative integer, long, int, short, byte, unsigned long, unsigned int, unsigned short, and unsigned byte datatypes). The fractionDigits facet is applicable for the decimal datatype only and specifies the maximum number of fractional digits that may be used.If totalDigits or fractionDigits are specified for an element or attribute that is mapped to a numeric field, a validate script will be generated to test that the total number of digits and/or number of fraction digits are allowed by the restriction facets.