Stylus Studio XML Editor

Table of contents

Appendices

4.3 Constraining Facets

Constraining Facets

length[top]

length

length is the number of units of length, where units of length varies depending on the type that is being derived from. The value of length must be a [nonNegativeInteger].

For [string] and datatypes derived from [string], length is measured in units of characters as defined in [XML]. For [anyURI], length is measured in units of characters (as for [string]). For [hexBinary] and [base64Binary] and datatypes derived from them, length is measured in octets (8 bits) of binary data. For datatypes derived by list, length is measured in number of list items.

NOTE: 

For [string] and datatypes derived from [string], length will not always coincide with "string length" as perceived by some users or with the number of storage units in some digital representation. Therefore, care should be taken when specifying a value for length and in attempting to infer storage requirements from a given value for length.

length provides for:

  • Constraining a value space to values with a specific number of units of length, where units of length varies depending on [defn-basetype].

NOTE: 

The following is the definition of a user-derived datatype to represent product codes which must be exactly 8 characters in length. By fixing the value of the length facet we ensure that types derived from productCode can change or set the values of other facets, such as pattern, but cannot change the length.

<simpleType name='productCode'>
   <restriction base='string'>
     <length value='8' fixed='true'/>
   </restriction>
</simpleType>

The length Schema Component[top]

The length Schema Component [ ]

If [length-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The length Schema Component] other than [length-value].

XML Representation of length Schema Components[top]

XML Representation of length Schema Components

The XML representation for a [The length Schema Component] schema component is a [length] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The fractionDigits Schema Component]

length Validation Rules[top]

length Validation Rules Length Valid

A value in a value space is facet-valid with respect to length, determined as follows:

  1. if the [defn-variety] is atomic then

    1. if [defn-primitive] is [string], then the length of the value, as measured in characters must be equal to [length-value];

    2. if [defn-primitive] is [hexBinary] or [base64Binary], then the length of the value, as measured in octets of the binary data, must be equal to [length-value];

  2. if the [defn-variety] is list, then the length of the value, as measured in list items, must be equal to [length-value]

Constraints on length Schema Components[top]

Constraints on length Schema Components length and minLength or maxLength

It is an error for both [The length Schema Component] and either of [The minLength Schema Component] or [The maxLength Schema Component] to be members of [defn-facets].

length valid restriction

It is an error if [The length Schema Component] is among the members of [defn-facets] of [defn-basetype] and [length-value] is not equal to the [length-value] of the parent [The length Schema Component].

minLength[top]

minLength

minLength is the minimum number of units of length, where units of length varies depending on the type that is being derived from. The value of minLength  must be a [nonNegativeInteger].

For [string] and datatypes derived from [string], minLength is measured in units of characters as defined in [XML]. For [hexBinary] and [base64Binary] and datatypes derived from them, minLength is measured in octets (8 bits) of binary data. For datatypes derived by list, minLength is measured in number of list items.

NOTE: 

For [string] and datatypes derived from [string], minLength will not always coincide with "string length" as perceived by some users or with the number of storage units in some digital representation. Therefore, care should be taken when specifying a value for minLength and in attempting to infer storage requirements from a given value for minLength.

minLength provides for:

  • Constraining a value space to values with at least a specific number of units of length, where units of length varies depending on [defn-basetype].

NOTE: 

The following is the definition of a user-derived datatype which requires strings to have at least one character (i.e., the empty string is not in the value space of this datatype).

<simpleType name='non-empty-string'>
  <restriction base='string'>
    <minLength value='1'/>
  </restriction>
</simpleType>

The minLength Schema Component[top]

The minLength Schema Component [ ]

If [minLength-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The minLength Schema Component] other than [minLength-value].

XML Representation of minLength Schema Component[top]

XML Representation of minLength Schema Component

The XML representation for a [The minLength Schema Component] schema component is a [minLength] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The fractionDigits Schema Component]

minLength Validation Rules[top]

minLength Validation Rules minLength Valid

A value in a value space is facet-valid with respect to minLength, determined as follows:

  1. if the [defn-variety] is atomic then

    1. if [defn-primitive] is [string], then the length of the value, as measured in characters must be greater than or equal to [minLength-value];

    2. if [defn-primitive] is [hexBinary] or [base64Binary], then the length of the value, as measured in octets of the binary data, must be greater than or equal to [minLength-value];

  2. if the [defn-variety] is list, then the length of the value, as measured in list items, must be greater than or equal to [minLength-value]

Constraints on minLength Schema Components[top]

Constraints on minLength Schema Components minLength <= maxLength

If both [The minLength Schema Component] and [The maxLength Schema Component] are members of [defn-facets], then the [minLength-value] of [The minLength Schema Component]  must be less than or equal to the [maxLength-value] of [The maxLength Schema Component].

minLength valid restriction

It is an error if [The minLength Schema Component] is among the members of [defn-facets] of [defn-basetype] and [minLength-value] is less than the [minLength-value] of the parent [The minLength Schema Component].

maxLength[top]

maxLength

maxLength is the maximum number of units of length, where units of length varies depending on the type that is being derived from. The value of maxLength  must be a [nonNegativeInteger].

For [string] and datatypes derived from [string], maxLength is measured in units of characters as defined in [XML]. For [hexBinary] and [base64Binary] and datatypes derived from them, maxLength is measured in octets (8 bits) of binary data. For datatypes derived by list, maxLength is measured in number of list items.

NOTE: 

For [string] and datatypes derived from [string], maxLength will not always coincide with "string length" as perceived by some users or with the number of storage units in some digital representation. Therefore, care should be taken when specifying a value for maxLength and in attempting to infer storage requirements from a given value for maxLength.

maxLength provides for:

  • Constraining a value space to values with at most a specific number of units of length, where units of length varies depending on [defn-basetype].

NOTE: 

The following is the definition of a user-derived datatype which might be used to accept form input with an upper limit to the number of characters that are acceptable.

<simpleType name='form-input'>
  <restriction base='string'>
    <maxLength value='50'/>
  </restriction>
</simpleType>

The maxLength Schema Component[top]

The maxLength Schema Component [ ]

If [maxLength-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The maxLength Schema Component] other than [maxLength-value].

XML Representation of maxLength Schema Components[top]

XML Representation of maxLength Schema Components

The XML representation for a [The maxLength Schema Component] schema component is a [maxLength] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The fractionDigits Schema Component]

maxLength Validation Rules[top]

maxLength Validation Rules maxLength Valid

A value in a value space is facet-valid with respect to maxLength, determined as follows:

  1. if the [defn-variety] is atomic then

    1. if [defn-primitive] is [string], then the length of the value, as measured in characters must be less than or equal to [maxLength-value];

    2. if [defn-primitive] is [hexBinary] or [base64Binary], then the length of the value, as measured in octets of the binary data, must be less than or equal to [maxLength-value];

  2. if the [defn-variety] is list, then the length of the value, as measured in list items, must be less than or equal to [maxLength-value]

Constraints on maxLength Schema Components[top]

Constraints on maxLength Schema Components maxLength valid restriction

It is an error if [The maxLength Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxLength-value] is greater than the [maxLength-value] of the parent [The maxLength Schema Component].

pattern[top]

pattern

pattern is a constraint on the value space of a datatype which is achieved by constraining the lexical space to literals which match a specific pattern. The value of pattern  must be a regular expression.

pattern provides for:

NOTE: 

The following is the definition of a user-derived datatype which is a better representation of postal codes in the United States, by limiting strings to those which are matched by a specific regular expression.

<simpleType name='better-us-zipcode'>
  <restriction base='string'>
    <pattern value='[0-9]{5}(-[0-9]{4})?'/>
  </restriction>
</simpleType>

The pattern Schema Component[top]

The pattern Schema Component [ ]

XML Representation of pattern Schema Components[top]

XML Representation of pattern Schema Components

The XML representation for a [The pattern Schema Component] schema component is a [pattern] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The fractionDigits Schema Component]

Constraints on XML Representation of pattern[top]

Constraints on XML Representation of pattern Multiple patterns

If multiple [pattern] element information items appear as  [children] of a [simpleType], the  [value]s should be combined as if they appeared in a single regular expression as separate branches.

NOTE: 

It is a consequence of the schema representation constraint [Multiple patterns] and of the rules for restriction that pattern facets specified on the same step in a type derivation are ORed together, while pattern facets specified on different steps of a type derivation are ANDed together.

Thus, to impose two pattern constraints simultaneously, schema authors may either write a single pattern which expresses the intersection of the two patterns they wish to impose, or define each pattern on a separate type derivation step.

pattern Validation Rules[top]

pattern Validation Rules pattern valid

A literal in a lexical space is facet-valid with respect to pattern if:

  1. the literal is among the set of character sequences denoted by the regular expression specified in [pattern-value].

enumeration[top]

enumeration

enumeration constrains the value space to a specified set of values.

enumeration does not impose an order relation on the value space it creates; the value of the ordered property of the derived datatype remains that of the datatype from which it is derived.

enumeration provides for:

  • Constraining a value space to a specified set of values.

NOTE: 

The following example is a datatype definition for a user-derived datatype which limits the values of dates to the three US holidays enumerated. This datatype definition would appear in a schema authored by an "end-user" and shows how to define a datatype by enumerating the values in its value space. The enumerated values must be type-valid literals for the base type.

<simpleType name='holidays'>
    <annotation>
        <documentation>some US holidays</documentation>
    </annotation>
    <restriction base='gMonthDay'>
      <enumeration value='--01-01'>
        <annotation>
            <documentation>New Year's day</documentation>
        </annotation>
      </enumeration>
      <enumeration value='--07-04'>
        <annotation>
            <documentation>4th of July</documentation>
        </annotation>
      </enumeration>
      <enumeration value='--12-25'>
        <annotation>
            <documentation>Christmas</documentation>
        </annotation>
      </enumeration>
    </restriction>  
</simpleType>

The enumeration Schema Component[top]

The enumeration Schema Component [ ]

XML Representation of enumeration Schema Components[top]

XML Representation of enumeration Schema Components

The XML representation for an [The enumeration Schema Component] schema component is an [enumeration] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The enumeration Schema Component]

Constraints on XML Representation of enumeration[top]

Constraints on XML Representation of enumeration Multiple enumerations

If multiple [enumeration] element information items appear as  [children] of a [simpleType] the [enumeration-value] of the [The enumeration Schema Component] component should be the set of all such  [value]s.

enumeration Validation Rules[top]

enumeration Validation Rules enumeration valid

A value in a value space is facet-valid with respect to enumeration if the value is one of the values specified in [enumeration-value]

Constraints on enumeration Schema Components[top]

Constraints on enumeration Schema Components enumeration valid restriction

It is an error if any member of [enumeration-value] is not in the value space of [defn-basetype].

whiteSpace[top]

whiteSpace

whiteSpace constrains the value space of types derived from [string] such that the various behaviors specified in [Attribute Value Normalization] in [XML] are realized. The value of whiteSpace must be one of {preserve, replace, collapse}.

preserve

No normalization is done, the value is not changed (this is the behavior required by [XML] for element content)

replace

All occurrences of #x9 (tab), #xA (line feed) and #xD (carriage return) are replaced with #x20 (space)

collapse

After the processing implied by replace, contiguous sequences of #x20's are collapsed to a single #x20, and leading and trailing #x20's are removed.

NOTE: 

The notation #xA used here (and elsewhere in this specification) represents the Universal Character Set (UCS) code point hexadecimal A (line feed), which is denoted by U+000A. This notation is to be distinguished from &#xA;, which is the XML character reference to that same UCS code point.

whiteSpace is applicable to all atomic and list datatypes. For all atomic datatypes other than [string] (and types derived by restriction from it) the value of whiteSpace is collapse and cannot be changed by a schema author; for [string] the value of whiteSpace is preserve; for any type derived by restriction from [string] the value of whiteSpace can be any of the three legal values. For all datatypes derived by list the value of whiteSpace is collapse and cannot be changed by a schema author. For all datatypes derived by union  whiteSpace does not apply directly; however, the normalization behavior of union types is controlled by the value of whiteSpace on that one of the memberTypes against which the union is successfully validated.

NOTE: 

For more information on whiteSpace, see the discussion on white space normalization in [Schema Component Details] in [structural-schemas].

whiteSpace provides for:

  • Constraining a value space according to the white space normalization rules.

NOTE: 

The following example is the datatype definition for the [token] built-in  derived datatype.

<simpleType name='token'>
    <restriction base='normalizedString'>
      <whiteSpace value='collapse'/>
    </restriction>  
</simpleType>

The whiteSpace Schema Component[top]

The whiteSpace Schema Component [ ]

If [whiteSpace-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The whiteSpace Schema Component] other than [whiteSpace-value].

XML Representation of whiteSpace Schema Components[top]

XML Representation of whiteSpace Schema Components

The XML representation for a [The whiteSpace Schema Component] schema component is a [whiteSpace] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The whiteSpace Schema Component]

whiteSpace Validation Rules[top]

whiteSpace Validation Rules
NOTE: 

There are no Validation Rules associated whiteSpace. For more information, see the discussion on white space normalization in [Schema Component Details] in [structural-schemas].

Constraints on whiteSpace Schema Components[top]

Constraints on whiteSpace Schema Components whiteSpace valid restriction

It is an error if [The whiteSpace Schema Component] is among the members of [defn-facets] of [defn-basetype] and any of the following conditions is true:

  1. [whiteSpace-value] is replace or preserve and the [whiteSpace-value] of the parent [The whiteSpace Schema Component] is collapse

  2. [whiteSpace-value] is preserve and the [whiteSpace-value] of the parent [The whiteSpace Schema Component] is replace

maxInclusive[top]

maxInclusive

maxInclusive is the inclusive upper bound of the value space for a datatype with the ordered property. The value of maxInclusive must be in the value space of the base type.

maxInclusive provides for:

NOTE: 

The following is the definition of a user-derived datatype which limits values to integers less than or equal to 100, using maxInclusive.

<simpleType name='one-hundred-or-less'>
  <restriction base='integer'>
    <maxInclusive value='100'/>
  </restriction>
</simpleType>

The maxInclusive Schema Component[top]

The maxInclusive Schema Component [ ]

If [maxInclusive-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The maxInclusive Schema Component] other than [maxInclusive-value].

XML Representation of maxInclusive Schema Components[top]

XML Representation of maxInclusive Schema Components

The XML representation for a [The maxInclusive Schema Component] schema component is a [maxInclusive] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[ ]

maxInclusive Validation Rules[top]

maxInclusive Validation Rules maxInclusive Valid

A value in an ordered value space is facet-valid with respect to maxInclusive, determined as follows:

  1. if the numeric property in [defn-fund-facets] is true, then the value must be numerically less than or equal to [maxInclusive-value];

  2. if the numeric property in [defn-fund-facets] is false (i.e., [defn-basetype] is one of the date and time related datatypes), then the value must be chronologically less than or equal to [maxInclusive-value];

Constraints on maxInclusive Schema Components[top]

Constraints on maxInclusive Schema Components minInclusive <= maxInclusive

It is an error for the value specified for minInclusive to be greater than the value specified for maxInclusive for the same datatype.

maxInclusive valid restriction

It is an error if any of the following conditions is true:

  1. [The maxInclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxInclusive-value] is greater than the [maxInclusive-value] of the parent [The maxInclusive Schema Component]

  2. [The maxExclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxInclusive-value] is greater than or equal to the [maxExclusive-value] of the parent [The maxExclusive Schema Component]

  3. [The minInclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxInclusive-value] is less than the [minInclusive-value] of the parent [The minInclusive Schema Component]

  4. [The minExclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxInclusive-value] is less than or equal to the [minExclusive-value] of the parent [The minExclusive Schema Component]

maxExclusive[top]

maxExclusive

maxExclusive is the exclusive upper bound of the value space for a datatype with the ordered property. The value of maxExclusive  must be in the value space of the base type.

maxExclusive provides for:

NOTE: 

The following is the definition of a user-derived datatype which limits values to integers less than or equal to 100, using maxExclusive.

<simpleType name='less-than-one-hundred-and-one'>
  <restriction base='integer'>
    <maxExclusive value='101'/>
  </restriction>
</simpleType>

Note that the value space of this datatype is identical to the previous one (named 'one-hundred-or-less').

The maxExclusive Schema Component[top]

The maxExclusive Schema Component [ ]

If [maxExclusive-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The maxExclusive Schema Component] other than [maxExclusive-value].

XML Representation of maxExclusive Schema Components[top]

XML Representation of maxExclusive Schema Components

The XML representation for a [The maxExclusive Schema Component] schema component is a [maxExclusive] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[ ]

maxExclusive Validation Rules[top]

maxExclusive Validation Rules maxExclusive Valid

A value in an ordered value space is facet-valid with respect to maxExclusive, determined as follows:

  1. if the numeric property in [defn-fund-facets] is true, then the value must be numerically less than [maxExclusive-value];

  2. if the numeric property in [defn-fund-facets] is false (i.e., [defn-basetype] is one of the date and time related datatypes), then the value must be chronologically less than [maxExclusive-value];

Constraints on maxExclusive Schema Components[top]

Constraints on maxExclusive Schema Components maxInclusive and maxExclusive

It is an error for both maxInclusive and maxExclusive to be specified in the same derivation step of a datatype definition.

minExclusive <= maxExclusive

It is an error for the value specified for minExclusive to be greater than the value specified for maxExclusive for the same datatype.

maxExclusive valid restriction

It is an error if any of the following conditions is true:

  1. [The maxExclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxExclusive-value] is greater than the [maxExclusive-value] of the parent [The maxExclusive Schema Component]

  2. [The maxInclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxExclusive-value] is greater than the [maxInclusive-value] of the parent [The maxInclusive Schema Component]

  3. [The minInclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxExclusive-value] is less than or equal to the [minInclusive-value] of the parent [The minInclusive Schema Component]

  4. [The minExclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxExclusive-value] is less than or equal to the [minExclusive-value] of the parent [The minExclusive Schema Component]

minExclusive[top]

minExclusive

minExclusive is the exclusive lower bound of the value space for a datatype with the ordered property. The value of minExclusive must be in the value space of the base type.

minExclusive provides for:

NOTE: 

The following is the definition of a user-derived datatype which limits values to integers greater than or equal to 100, using minExclusive.

<simpleType name='more-than-ninety-nine'>
  <restriction base='integer'>
    <minExclusive value='99'/>
  </restriction>
</simpleType>

Note that the value space of this datatype is identical to the previous one (named 'one-hundred-or-more').

The minExclusive Schema Component[top]

The minExclusive Schema Component [ ]

If [minExclusive-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The minExclusive Schema Component] other than [minExclusive-value].

XML Representation of minExclusive Schema Components[top]

XML Representation of minExclusive Schema Components

The XML representation for a [The minExclusive Schema Component] schema component is a [minExclusive] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[ ]

minExclusive Validation Rules[top]

minExclusive Validation Rules minExclusive Valid

A value in an ordered value space is facet-valid with respect to minExclusive if:

  1. if the numeric property in [defn-fund-facets] is true, then the value must be numerically greater than [minExclusive-value];

  2. if the numeric property in [defn-fund-facets] is false (i.e., [defn-basetype] is one of the date and time related datatypes), then the value must be chronologically greater than [minExclusive-value];

Constraints on minExclusive Schema Components[top]

Constraints on minExclusive Schema Components minInclusive and minExclusive

It is an error for both minInclusive and minExclusive to be specified for the same datatype.

minExclusive < maxInclusive

It is an error for the value specified for minExclusive to be greater than or equal to the value specified for maxInclusive for the same datatype.

minExclusive valid restriction

It is an error if any of the following conditions is true:

  1. [The minExclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [minExclusive-value] is less than the [minExclusive-value] of the parent [The minExclusive Schema Component]

  2. [The maxInclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [minExclusive-value] is greater the [maxInclusive-value] of the parent [The maxInclusive Schema Component]

  3. [The minInclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [minExclusive-value] is less than the [minInclusive-value] of the parent [The minInclusive Schema Component]

  4. [The maxExclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [maxExclusive-value] is greater than or equal to the [maxExclusive-value] of the parent [The maxExclusive Schema Component]

minInclusive[top]

minInclusive

minInclusive is the inclusive lower bound of the value space for a datatype with the ordered property. The value of minInclusive  must be in the value space of the base type.

minInclusive provides for:

NOTE: 

The following is the definition of a user-derived datatype which limits values to integers greater than or equal to 100, using minInclusive.

<simpleType name='one-hundred-or-more'>
  <restriction base='integer'>
    <minInclusive value='100'/>
  </restriction>
</simpleType>

The minInclusive Schema Component[top]

The minInclusive Schema Component [ ]

If [minInclusive-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The minInclusive Schema Component] other than [minInclusive-value].

XML Representation of minInclusive Schema Components[top]

XML Representation of minInclusive Schema Components

The XML representation for a [The minInclusive Schema Component] schema component is a [minInclusive] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[ ]

minInclusive Validation Rules[top]

minInclusive Validation Rules minInclusive Valid

A value in an ordered value space is facet-valid with respect to minInclusive if:

  1. if the numeric property in [defn-fund-facets] is true, then the value must be numerically greater than or equal to [minInclusive-value];

  2. if the numeric property in [defn-fund-facets] is false (i.e., [defn-basetype] is one of the date and time related datatypes), then the value must be chronologically greater than or equal to [minInclusive-value];

Constraints on minInclusive Schema Components[top]

Constraints on minInclusive Schema Components minInclusive < maxExclusive

It is an error for the value specified for minInclusive to be greater than or equal to the value specified for maxExclusive for the same datatype.

minInclusive valid restriction

It is an error if any of the following conditions is true:

  1. [The minInclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [minInclusive-value] is less than the [minInclusive-value] of the parent [The minInclusive Schema Component]

  2. [The maxInclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [minInclusive-value] is greater the [maxInclusive-value] of the parent [The maxInclusive Schema Component]

  3. [The minExclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [minInclusive-value] is less than or equal to the [minExclusive-value] of the parent [The minExclusive Schema Component]

  4. [The maxExclusive Schema Component] is among the members of [defn-facets] of [defn-basetype] and [minInclusive-value] is greater than or equal to the [maxExclusive-value] of the parent [The maxExclusive Schema Component]

totalDigits[top]

totalDigits

totalDigits is the maximum number of digits in values of datatypes derived from [decimal]. The value of totalDigits must be a [positiveInteger].

totalDigits provides for:

  • Constraining a value space to values with a specific maximum number of decimal digits (#x30-#x39).

NOTE: 

The following is the definition of a user-derived datatype which could be used to represent monetary amounts, such as in a financial management application which does not have figures of $1M or more and only allows whole cents. This definition would appear in a schema authored by an "end-user" and shows how to define a datatype by specifying facet values which constrain the range of the base type in a manner specific to the base type (different than specifying max/min values as before).

<simpleType name='amount'>
  <restriction base='decimal'>
    <totalDigits value='8'/>
    <fractionDigits value='2' fixed='true'/>
  </restriction>
</simpleType>

The totalDigits Schema Component[top]

The totalDigits Schema Component [ ]

If [totalDigits-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The totalDigits Schema Component] other than [totalDigits-value].

XML Representation of totalDigits Schema Components[top]

XML Representation of totalDigits Schema Components

The XML representation for a [The totalDigits Schema Component] schema component is a [totalDigits] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The totalDigits Schema Component]

totalDigits Validation Rules[top]

totalDigits Validation Rules totalDigits Valid

A value in a value space is facet-valid with respect to totalDigits if:

  1. the number of decimal digits in the value is less than or equal to [totalDigits-value];

Constraints on totalDigits Schema Components[top]

Constraints on totalDigits Schema Components totalDigits valid restriction

It is an error if [The totalDigits Schema Component] is among the members of [defn-facets] of [defn-basetype] and [totalDigits-value] is greater than the [totalDigits-value] of the parent [The totalDigits Schema Component]

fractionDigits[top]

fractionDigits

fractionDigits is the maximum number of digits in the fractional part of values of datatypes derived from [decimal]. The value of fractionDigits  must be a [nonNegativeInteger] .

fractionDigits provides for:

  • Constraining a value space to values with a specific maximum number of decimal digits in the fractional part.

NOTE: 

The following is the definition of a user-derived datatype which could be used to represent the magnitude of a person's body temperature on the Celsius scale. This definition would appear in a schema authored by an "end-user" and shows how to define a datatype by specifying facet values which constrain the range of the base type.

<simpleType name='celsiusBodyTemp'>
  <restriction base='decimal'>
    <totalDigits value='4'/>
    <fractionDigits value='1'/>
    <minInclusive value='36.4'/>
    <maxInclusive value='40.5'/>
  </restriction>
</simpleType>

The fractionDigits Schema Component[top]

The fractionDigits Schema Component [ ]

If [fractionDigits-fixed] is true, then types for which the current type is the [defn-basetype] cannot specify a value for [The fractionDigits Schema Component] other than [fractionDigits-value].

XML Representation of fractionDigits Schema Components[top]

XML Representation of fractionDigits Schema Components

The XML representation for a [The fractionDigits Schema Component] schema component is a [fractionDigits] element information item. The correspondences between the properties of the information item and properties of the component are as follows:

[The fractionDigits Schema Component]

fractionDigits Validation Rules[top]

fractionDigits Validation Rules fractionDigits Valid

A value in a value space is facet-valid with respect to fractionDigits if:

  1. the number of decimal digits in the fractional part of the value is less than or equal to [fractionDigits-value];

Constraints on fractionDigits Schema Components[top]

Constraints on fractionDigits Schema Components fractionDigits less than or equal to totalDigits

It is an error for fractionDigits to be greater than totalDigits.