net.sf.saxon.type

Interface SchemaType

public interface SchemaType extends SchemaComponent

SchemaType is an interface implemented by all schema types: simple and complex types, built-in and user-defined types.

There is a hierarchy of interfaces that extend SchemaType, representing the top levels of the schema type system: SimpleType and ComplexType, with SimpleType further subdivided into List, Union, and Atomic types.

The implementations of these interfaces are organized into a different hierarchy: on the one side, built-in types such as AnyType, AnySimpleType, and the built-in atomic types and list types; on the other side, user-defined types defined in a schema.

Field Summary
static intDERIVATION_EXTENSION
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the derivation by extension.
static intDERIVATION_LIST
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the list.
static intDERIVATION_RESTRICTION
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the derivation by restriction if complex types are involved, or a restriction if simple types are involved.
static intDERIVATION_UNION
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the union if simple types are involved.
static intDERIVE_BY_SUBSTITUTION
Derivation by substitution.
Method Summary
booleanallowsDerivation(int derivation)
Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property
voidanalyzeContentExpression(Expression expression, int kind, StaticContext env)
Analyze an expression to see whether the expression is capable of delivering a value of this type.
Valueatomize(NodeInfo node)
Get the typed value of a node that is annotated with this schema type.
SchemaTypegetBaseType()
Returns the base type that this type inherits from.
intgetBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as DERIVATION_LIST and
intgetDerivationMethod()
Gets the integer code of the derivation method used to derive this type from its parent.
StringgetDescription()
Get a description of this type for use in error messages.
StringgetDisplayName()
Get the display name of the type: that is, a lexical QName with an arbitrary prefix
intgetFingerprint()
Get the fingerprint of the name of this type
intgetNameCode()
Get the namecode of the name of this type.
SequenceIteratorgetTypedValue(NodeInfo node)
Get the typed value of a node that is annotated with this schema type.
booleanisComplexType()
Test whether this SchemaType is a complex type
booleanisSameType(SchemaType other)
Test whether this is the same type as another type.
booleanisSimpleType()
Test whether this SchemaType is a simple type
voidisTypeDerivationOK(SchemaType base, int block)
Check that this type is validly derived from a given type, following the rules for the Schema Component Constraint "Is Type Derivation OK (Simple)" (3.14.6) or "Is Type Derivation OK (Complex)" (3.4.6) as appropriate.

Field Detail

DERIVATION_EXTENSION

public static final int DERIVATION_EXTENSION
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the derivation by extension.
The reference type definition is derived by extension from the other type definition if the other type definition can be reached recursively following the {base type definition} property from the reference type definition, and at least one of the derivation methods involved is an extension.

DERIVATION_LIST

public static final int DERIVATION_LIST
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the list.
The reference type definition is derived by list from the other type definition if there exists two type definitions T1 and T2 such as the reference type definition is derived from T1 by DERIVATION_RESTRICTION or DERIVATION_EXTENSION, T2 is derived from the other type definition by DERIVATION_RESTRICTION, T1 has {variety} list, and T2 is the {item type definition}. Note that T1 could be the same as the reference type definition, and T2 could be the same as the other type definition.

DERIVATION_RESTRICTION

public static final int DERIVATION_RESTRICTION
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the derivation by restriction if complex types are involved, or a restriction if simple types are involved.
The reference type definition is derived by restriction from the other type definition if the other type definition is the same as the reference type definition, or if the other type definition can be reached recursively following the {base type definition} property from the reference type definition, and all the derivation methods involved are restriction.

DERIVATION_UNION

public static final int DERIVATION_UNION
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the union if simple types are involved.
The reference type definition is derived by union from the other type definition if there exists two type definitions T1 and T2 such as the reference type definition is derived from T1 by DERIVATION_RESTRICTION or DERIVATION_EXTENSION, T2 is derived from the other type definition by DERIVATION_RESTRICTION, T1 has {variety} union, and one of the {member type definitions} is T2. Note that T1 could be the same as the reference type definition, and T2 could be the same as the other type definition.

DERIVE_BY_SUBSTITUTION

public static final int DERIVE_BY_SUBSTITUTION
Derivation by substitution. This constant, unlike the others, is NOT defined in the DOM level 3 TypeInfo interface.

Method Detail

allowsDerivation

public boolean allowsDerivation(int derivation)
Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" property

Parameters: derivation the kind of derivation, for example DERIVATION_LIST

Returns: true if this kind of derivation is allowed

analyzeContentExpression

public void analyzeContentExpression(Expression expression, int kind, StaticContext env)
Analyze an expression to see whether the expression is capable of delivering a value of this type.

Parameters: expression the expression that delivers the content kind the node kind whose content is being delivered: ELEMENT, ATTRIBUTE, or DOCUMENT env The static evaluation context for the query or stylesheet

Throws: XPathException if the expression will never deliver a value of the correct type

atomize

public Value atomize(NodeInfo node)
Get the typed value of a node that is annotated with this schema type. The result of this method will always be consistent with the method SchemaType. However, this method is often more convenient and may be more efficient, especially in the common case where the value is expected to be a singleton.

Parameters: node the node whose typed value is required

Returns: the typed value.

Since: 8.5

getBaseType

public SchemaType getBaseType()
Returns the base type that this type inherits from. This method can be used to get the base type of a type that is known to be valid. If this type is a Simpletype that is a built in primitive type then null is returned.

Returns: the base type.

Throws: IllegalStateException if this type is not valid.

getBlock

public int getBlock()
Returns the value of the 'block' attribute for this type, as a bit-signnificant integer with fields such as DERIVATION_LIST and DERIVATION_EXTENSION

Returns: the value of the 'block' attribute for this type

getDerivationMethod

public int getDerivationMethod()
Gets the integer code of the derivation method used to derive this type from its parent. Returns zero for primitive types.

Returns: a numeric code representing the derivation method, for example DERIVATION_RESTRICTION

getDescription

public String getDescription()
Get a description of this type for use in error messages. This is the same as the display name in the case of named types; for anonymous types it identifies the type by its position in a source schema document.

Returns: text identifing the type, for use in a phrase such as "the type XXXX".

getDisplayName

public String getDisplayName()
Get the display name of the type: that is, a lexical QName with an arbitrary prefix

Returns: a lexical QName identifying the type

getFingerprint

public int getFingerprint()
Get the fingerprint of the name of this type

Returns: the fingerprint. Returns an invented fingerprint for an anonymous type.

getNameCode

public int getNameCode()
Get the namecode of the name of this type. This includes the prefix from the original type declaration: in the case of built-in types, there may be a conventional prefix or there may be no prefix.

getTypedValue

public SequenceIterator getTypedValue(NodeInfo node)
Get the typed value of a node that is annotated with this schema type. The results of this method are consistent with the SchemaType method, but this version returns a SequenceIterator which may be more efficient when handling long lists.

Parameters: node the node whose typed value is required

Returns: a SequenceIterator over the atomic values making up the typed value of the specified node. The objects returned by this iterator are of type AtomicValue

isComplexType

public boolean isComplexType()
Test whether this SchemaType is a complex type

Returns: true if this SchemaType is a complex type

isSameType

public boolean isSameType(SchemaType other)
Test whether this is the same type as another type. They are considered to be the same type if they are derived from the same type definition in the original XML representation (which can happen when there are multiple includes of the same file)

isSimpleType

public boolean isSimpleType()
Test whether this SchemaType is a simple type

Returns: true if this SchemaType is a simple type

isTypeDerivationOK

public void isTypeDerivationOK(SchemaType base, int block)
Check that this type is validly derived from a given type, following the rules for the Schema Component Constraint "Is Type Derivation OK (Simple)" (3.14.6) or "Is Type Derivation OK (Complex)" (3.4.6) as appropriate.

Parameters: base the base type; the algorithm tests whether derivation from this type is permitted block the derivations that are blocked by the relevant element declaration

Throws: SchemaException if the derivation is not allowed