- Simple Type Varieties
- Simple Type Definitions
- Facets
- Preventing Simple Type Derivation
Preventing Simple Type Derivation
XML Schema allows you to prevent derivation of other types from your type. By specifying the final attribute in your simple type definition, you may prevent derivation of any kind (restriction, extension, list, or union) by specifying a value of #all. If you want more specific control, the value of final can be a whitespace-separated list of any of the keywords restriction, extension, list, or union. Extension refers to the extension of simple types to derive complex types. Example 17 shows some valid values for final.
Example 17 Valid Values for the Final Attribute in Simple Type Definitions
final="#all" final="restriction list union" final="list restriction extension" final="union" final=""
Example 18 shows a simple type that cannot be restricted by any other type, or used as the item type of a list. With this definition of DressSizeType, it would have been illegal to define MediumDress-SizeType in Example 4 because it attempts to restrict DressSize-Type.
Example 18 Preventing Type Derivation
<xsd:simpleType name="DressSizeType" final="restriction list"> <xsd:restriction base="xsd:integer"> <xsd:minInclusive value="2"/> <xsd:maxInclusive value="18"/> </xsd:restriction> </xsd:simpleType>
If no final attribute is specified, it defaults to the value of the finalDefault attribute of the schema element. If neither final nor finalDefault are specified, there are no restrictions on derivation from that type. You can specify the empty string ("") for the final value if you want to override the finalDefault value.