Restriction is done using the general facets, or the following object facets. For the moment, restriction can only be made on the topmost object type, but this will be relaxed later.
$content (object): the layout definition. Each pair in $content is called a field descriptor. The value in each field descriptor has the following properties.
$type (string or object) - required: the name of a Type (Qualified Name in a string) or the type itself (an object) that the value must match.
$optional (boolean) - optional: indicates that the pair is optional. Default is false.
$default (item) - optional: indicates a default value to be taken the value is missing in the Serialized Instance. $optional is then ignored.
However, if this value is an object with a pair named $computed (which must be associated with a string), then the JSONiq query in $content.$default.$computed is executed upon Annotation, with the context item bound to the Candidate Instance being matched against the containing Object Type. It must result in one item, which is the default value for the Pair Descriptor.
An object $o is valid against the $content facet if the following conditions are met:
For each pair $k : $v in the field descriptor such that $v."$optional" is false and $v."$default" is absent, there must be a pair named $k in $o.
For each pair $k : $v in the field descriptor, if $o.$k exists, then $o.$k must be valid against the Type $v."$type".
$open (boolean) : specifies whether pairs not specified in $content are to be accepted. The default is the same as the $baseType (true if $baseType is object).
All objects are valid against the $open facet if it is set to true.
If it is set to false, an object $o is valid against the $open facet if all its keys appear in $content, or in the $content of a super type.
The object facets must fulfill the following consistency constraints against the super types (i.e., in the transitive closure of the $baseType relationship).
These constraints make sure that the new value space is a subset of the base type's value space.
If the $baseType's $open property is false, then $open cannot be set back to true.
Field descriptors on new keys may only be defined in $content if the $baseType's $open property is true.
Field descriptors on keys that were already defined in a super type are only allowed if they are more restrictive, i.e., $type must be a subtype of the $type associated to this key by the closest super type which does so.
If a field descriptor redefines a key that was not $optional in the closest super type, $optional cannot be set back to true.
Note: since currently, the $baseType must be "object", these constraints are always fulfilled.