Package net.sf.saxon.type
Interface SchemaType
-
- All Superinterfaces:
SchemaComponent
- All Known Subinterfaces:
AtomicType
,ComplexType
,ListType
,SimpleType
- All Known Implementing Classes:
AnySimpleType
,AnyType
,BuiltInAtomicType
,BuiltInListType
,ErrorType
,NumericType
,SimpleTypeDefinition
,Untyped
,UserAtomicType
,UserComplexType
,UserDefinedType
,UserListType
,UserSimpleType
,UserUnionType
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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface net.sf.saxon.type.SchemaComponent
SchemaComponent.ValidationStatus
-
-
Field Summary
Fields Modifier and Type Field Description static int
DERIVATION_EXTENSION
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the derivation by extension.static int
DERIVATION_LIST
If the document's schema is an XML Schema [XML Schema Part 1] , this constant represents the list.static 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.static 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.static int
DERIVE_BY_SUBSTITUTION
Derivation by substitution.-
Fields inherited from interface net.sf.saxon.type.SchemaComponent
COMPONENT_FUNCTION_TYPE
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description boolean
allowsDerivation(int derivation)
Determines whether derivation (of a particular kind) from this type is allowed, based on the "final" propertyvoid
analyzeContentExpression(Expression expression, int kind)
Analyze an XPath expression to see whether the expression is capable of delivering a value of this type.AtomicSequence
atomize(NodeInfo node)
Get the typed value of a node that is annotated with this schema type.void
checkTypeDerivationIsOK(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.SchemaType
getBaseType()
Returns the base type that this type inherits from.int
getBlock()
Returns the value of the 'block' attribute for this type, as a bit-significant integer with fields such asDERIVATION_LIST
andDERIVATION_EXTENSION
.int
getDerivationMethod()
Gets the integer code of the derivation method used to derive this type from its parent.java.lang.String
getDescription()
Get a description of this type for use in error messages.java.lang.String
getDisplayName()
Get the display name of the type: that is, a lexical QName with an arbitrary prefixjava.lang.String
getEQName()
Get the name of this type as an EQName, that is, a string in the format Q{uri}local.int
getFinalProhibitions()
Get the types of derivation that are not permitted, by virtue of the "final" property.int
getFingerprint()
Get the fingerprint of the name of this typejava.lang.String
getName()
Get the local name of this typedefault SchemaType
getNearestNamedType()
Get the nearest named type in the type hierarchy, that is, the nearest type that is not anonymous.StructuredQName
getStructuredQName()
Get the name of the type as a StructuredQNamejava.lang.String
getSystemId()
Get the URI of the schema document where the type was originally defined.java.lang.String
getTargetNamespace()
Get the target namespace of this typeboolean
isAnonymousType()
Test whether this is an anonymous typeboolean
isAtomicType()
Test whether this SchemaType is an atomic typeboolean
isComplexType()
Test whether this SchemaType is a complex typeboolean
isIdRefType()
Ask whether this type is an IDREF or IDREFS type.boolean
isIdType()
Ask whether this type is an ID type.boolean
isSameType(SchemaType other)
Test whether this is the same type as another type.boolean
isSimpleType()
Test whether this SchemaType is a simple type-
Methods inherited from interface net.sf.saxon.type.SchemaComponent
getComponentAsFunction, getRedefinitionLevel, getValidationStatus
-
-
-
-
Field Detail
-
DERIVATION_RESTRICTION
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.- See Also:
- Constant Field Values
-
DERIVATION_EXTENSION
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.- See Also:
- Constant Field Values
-
DERIVATION_UNION
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 byDERIVATION_RESTRICTION
orDERIVATION_EXTENSION
, T2 is derived from the other type definition byDERIVATION_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.- See Also:
- Constant Field Values
-
DERIVATION_LIST
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 byDERIVATION_RESTRICTION
orDERIVATION_EXTENSION
, T2 is derived from the other type definition byDERIVATION_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.- See Also:
- Constant Field Values
-
DERIVE_BY_SUBSTITUTION
static final int DERIVE_BY_SUBSTITUTION
Derivation by substitution. This constant, unlike the others, is NOT defined in the DOM level 3 TypeInfo interface.- See Also:
- Constant Field Values
-
-
Method Detail
-
getName
java.lang.String getName()
Get the local name of this type- Returns:
- the local name of this type definition, if it has one. Return null in the case of an anonymous type.
-
getTargetNamespace
java.lang.String getTargetNamespace()
Get the target namespace of this type- Returns:
- the target namespace of this type definition, if it has one. Return null in the case of an anonymous type, and in the case of a global type defined in a no-namespace schema.
-
getFingerprint
int getFingerprint()
Get the fingerprint of the name of this type- Returns:
- the fingerprint. Returns an invented fingerprint for an anonymous type.
-
getDisplayName
java.lang.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. In the case of an anonymous type, an internally-generated name is returned
-
getStructuredQName
StructuredQName getStructuredQName()
Get the name of the type as a StructuredQName- Returns:
- a StructuredQName identifying the type. In the case of an anonymous type, an internally-generated name is returned
-
getEQName
java.lang.String getEQName()
Get the name of this type as an EQName, that is, a string in the format Q{uri}local.- Returns:
- an EQName identifying the type. In the case of an anonymous type, an internally-generated name is returned
-
isComplexType
boolean isComplexType()
Test whether this SchemaType is a complex type- Returns:
- true if this SchemaType is a complex type
-
isSimpleType
boolean isSimpleType()
Test whether this SchemaType is a simple type- Returns:
- true if this SchemaType is a simple type
-
isAtomicType
boolean isAtomicType()
Test whether this SchemaType is an atomic type- Returns:
- true if this SchemaType is an atomic type
-
isAnonymousType
boolean isAnonymousType()
Test whether this is an anonymous type- Returns:
- true if this SchemaType is an anonymous type
-
getBlock
int getBlock()
Returns the value of the 'block' attribute for this type, as a bit-significant integer with fields such asDERIVATION_LIST
andDERIVATION_EXTENSION
. This corresponds to the property "prohibited substitutions" in the schema component model.- Returns:
- the value of the 'block' attribute for this type
-
getBaseType
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, or null if this is xs:anyType (the root of the type hierarchy)
-
getNearestNamedType
default SchemaType getNearestNamedType()
Get the nearest named type in the type hierarchy, that is, the nearest type that is not anonymous. (In practice, since types cannot be derived from anonymous types, this will either the type itself, or its immediate base type).- Returns:
- the nearest type, found by following the
getBaseType()
relation recursively, that is not an anonymous type
-
getDerivationMethod
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
-
getFinalProhibitions
int getFinalProhibitions()
Get the types of derivation that are not permitted, by virtue of the "final" property.- Returns:
- the types of derivation that are not permitted, as a bit-significant integer
containing bits such as
DERIVATION_EXTENSION
-
allowsDerivation
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 exampleDERIVATION_LIST
- Returns:
- true if this kind of derivation is allowed
-
analyzeContentExpression
void analyzeContentExpression(Expression expression, int kind) throws XPathException
Analyze an XPath expression to see whether the expression is capable of delivering a value of this type. This method is called during static analysis of a query or stylesheet to give compile-time warnings when "impossible" paths are used.- Parameters:
expression
- the expression that delivers the contentkind
- the node kind whose content is being delivered:Type.ELEMENT
,Type.ATTRIBUTE
, orType.DOCUMENT
- Throws:
XPathException
- if the expression will never deliver a value of the correct type
-
atomize
AtomicSequence atomize(NodeInfo node) throws XPathException
Get the typed value of a node that is annotated with this schema type.- Parameters:
node
- the node whose typed value is required- Returns:
- the typed value.
- Throws:
XPathException
- if the node cannot be atomized, for example if this is a complex type with element-only content- Since:
- 8.5. Changed in 9.5 to return the new type AtomicSequence
-
isSameType
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)- Parameters:
other
- the other type- Returns:
- true if this is the same type as other
-
getDescription
java.lang.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".
-
checkTypeDerivationIsOK
void checkTypeDerivationIsOK(SchemaType base, int block) throws SchemaException
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 permittedblock
- the derivations that are blocked by the relevant element declaration- Throws:
SchemaException
- if the derivation is not allowed
-
getSystemId
java.lang.String getSystemId()
Get the URI of the schema document where the type was originally defined.- Returns:
- the URI of the schema document. Returns null if the information is unknown or if this is a built-in type
-
isIdType
boolean isIdType() throws MissingComponentException
Ask whether this type is an ID type. This is defined to be any simple type who typed value may contain atomic values of type xs:ID: that is, it includes types derived from ID by restriction, list, or union. Note that for a node to be treated as an ID in XSD 1.0, its typed value must be a *single* atomic value of type ID; the type of the node, however, can still allow a list. But in XSD 1.1, a list of IDs is permitted- Returns:
- true if this type is an ID type
- Throws:
MissingComponentException
-
isIdRefType
boolean isIdRefType() throws MissingComponentException
Ask whether this type is an IDREF or IDREFS type. This is defined to be any simple type who typed value may contain atomic values of type xs:IDREF: that is, it includes types derived from IDREF or IDREFS by restriction, list, or union- Returns:
- true if this type is an IDREF type
- Throws:
MissingComponentException
-
-