Interface SchemaType

All Superinterfaces:
SchemaAnnotated, SchemaComponent
All Known Implementing Classes:
SchemaTypeImpl

public interface SchemaType
extends SchemaComponent, SchemaAnnotated
Represents a schema type.

SchemaType is the metadata "type" class for XmlObject, and it plays the analogous role for XmlObject that Class plays for Object.

Every XML Bean class corresponds to a singleton SchemaType object obtainable by ClassName.type (e.g., XmlNonPositiveInteger.type), and every XML Bean instance has an actual SchemaType, obtainable by XmlObject.schemaType(). The ClassName.type and schemaType() mechanisms are analogous to the ordinary Java ClassName.class and obj.getClass() mechanisms.

All schema types are represented by a SchemaType, this includes all types regardless of whether they are built-in or user-defined, compiled or uncompiled, simple or complex.

In addition, a compiled XML Bean type system includes special "document" schema types each representing a document containing nothing but a single element for each global element, and special "attribute" schema types each representing a fragment containing nothing but a single global attribute for global attribute.

Do not confuse Schema Types with other types of Schema Components such as Global Elements, Global Attributes, Named Model Groups, or Attribute Groups. SchemaType represents a Type component, not any of the other kinds of components. There are different kinds of metadata objects for the different Schema components.

The space of SchemaTypes is divided as follows:

  • First, there is the universal base type and the universal subtype. These are XmlObject.type (corresponding to xs:anyType) and XmlBeans.NO_TYPE, respectively. The first type is a base type of all other types. The other type indicates the absence of type information and, at least in set-theoretic terms, is a subtype of all other types.
  • There is another universal base type that is the base type for all simple types. This is the XmlAnySimpleType.type, corresponding to xs:anySimpleType. Only XmlObject.type and XmlAnySimpleType.type return true for isURType(), and only XmlBeans.NO_TYPE returns true for isNoType().
  • The two "special" kinds of types that are generated that do not formally exist in the actual Schema specification are document types and global attribute types (corresponding to documents that contain a global element, or fragments that contain a global attribute). They can be detected using isDocumentType() and isAttributeType(). Other than their anonymity (lack of a type name) and their appearance only at the root of an instance, they are otherwise just like ordinary complex types.
  • Simple types can be detected using isSimpleType(). Complex types are considered to be all the types that are not simple.
  • Simple types are divided into three varieties: atomic types, list types, and union types. Which variety of simple type you have can be discoverd using getSimpleVariety(). It will return either ATOMIC, LIST, or UNION.
  • An ATOMIC simple type is always based on one of the 20 built-in primitive schema types. You can determine the underlying primitive type for an atomic simple type by calling getPrimitiveType(). An atomic type may add facet restrictions on top of the primitive type, and these facets can be explored using getFacet(int), getWhiteSpaceRule(), matchPatternFacet(java.lang.String), getEnumerationValues(), and related methods.
  • A LIST simple type is always based on another non-list simple type. The underlying list item type can be obtained by using getListItemType().
  • A UNION simple type is always composed out of a number of other simple types. The direct members of the union can be obtained by getUnionMemberTypes(). When unions consist of other unions, it is useful to know useful to know the "leaves of the union tree", so the set of non-union types making up the union can be obtained by getUnionConstituentTypes(). The closure of the entire "union tree" is getUnionSubTypes() (this includes the type itself). For simple unions that do not consist of other unions, all three of these sets are the same.
  • Complex types have nested structure. They are divided into four content types: empty content, simple content, element-only content, and mixed content. All kinds of complex types may have attributes. The content type for a complex type can be dermined using getContentType(). This will return EMPTY_CONTENT, SIMPLE_CONTENT, ELEMENT_CONTENT, or MIXED_CONTENT.
  • If a complex type has EMPTY_CONTENT, the content model will be null.
  • If a complex type has SIMPLE_CONTENT, then it will extend the simple type that describes the content. In addition, the type may impose additional simple type facet restrictions; these can be determined in the same way they are for a simple type.
  • If a complex type has ELEMENT_CONTENT or MIXED_CONTENT, then the detailed content model can be determined by examining the particle tree (which may be null for MIXED_CONTENT). The particle tree can be obtained via getContentModel().
  • When working with a complex type, most users will find it sufficient to discover the summarized shape of the content model and attribute model using getElementProperties(), getAttributeProperties(), and related methods rather than examining the particle tree and attribute model directly.
See Also:
SchemaTypeLoader, XmlObject.schemaType(), SimpleValue.instanceType()