Secondary menu

Main menu

Q & A - Using XML Schema Facets with Simple Types

Q: With XML Schema, why do some facets work with some simple types and some don't?

A: The logic of XML Schema facets can only work on simple types that make sense. For example, you could ask XML Schema to constrain a number to be within a minimum or maximum, but you cannot ask it to do so for a word (there isn't a universal sense of min / max for a word).

Here is a list of facets, and the simple types with which they work:

  • minInclusive, maxInclusive, minExclusive, maxExclusive: date, time and numeric simple types
  • totalDigits, fractionDigits: any numeric simple type
  • length, minLength, maxLength: string and other string-based simple types, such as anyURI or hexBinary
  • enumeration: all simple types, except Boolean
  • pattern: all simple types

    Back to the Q & A page

    © 2009 - 2021 Kevin Howard Goldberg