Package net.sf.saxon.type
Class TypeHierarchy
java.lang.Object
net.sf.saxon.type.TypeHierarchy
- Direct Known Subclasses:
TypeHierarchyEE
This class exists to provide answers to questions about the type hierarchy. Because
such questions are potentially expensive, it caches the answers. There is one instance of
this class for a Configuration.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTypeHierarchy
(Configuration config) Create the type hierarchy cache for a configuration -
Method Summary
Modifier and TypeMethodDescriptionprotected SequenceIterator
applyFunctionCoercion
(SequenceIterator iterator, ItemType suppliedItemType, ItemType requiredItemType, Location locator) Apply function coercion when a function item is supplied as a parameter in a function callapplyFunctionConversionRules
(Sequence value, SequenceType requiredType, Supplier<RoleDiagnostic> roleSupplier, Location locator) Apply the function conversion rules to a value, given a required type.protected Affinity
Compute the relationship between the allowed content-types of two types, for example attribute(*, xs:integer) and attribute(xs:string).Get the Saxon configuration to which this type hierarchy belongsstatic SchemaType
Get the nearest named type in the type hierarchy, that is, the nearest type that is not anonymous.static Affinity
inverseRelationship
(Affinity relation) boolean
Determine whether type A is type B or one of its subtypes, recursively.relationship
(ItemType t1, ItemType t2) Determine the relationship of one item type to another.Get the relationship of two schema types to each otherGet the relationship of two sequence types to each other
-
Field Details
-
config
-
-
Constructor Details
-
TypeHierarchy
Create the type hierarchy cache for a configuration- Parameters:
config
- the configuration
-
-
Method Details
-
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
-
applyFunctionConversionRules
public GroundedValue applyFunctionConversionRules(Sequence value, SequenceType requiredType, Supplier<RoleDiagnostic> roleSupplier, Location locator) throws XPathException Apply the function conversion rules to a value, given a required type.- Parameters:
value
- a value to be convertedrequiredType
- the required typeroleSupplier
- identifies the value to be converted in error messageslocator
- identifies the location for error messages- Returns:
- the converted value
- Throws:
XPathException
- if the value cannot be converted to the required type
-
applyFunctionCoercion
protected SequenceIterator applyFunctionCoercion(SequenceIterator iterator, ItemType suppliedItemType, ItemType requiredItemType, Location locator) Apply function coercion when a function item is supplied as a parameter in a function call- Parameters:
iterator
- An iterator over the supplied value of the parametersuppliedItemType
- the item type of the supplied valuerequiredItemType
- the required item type (typically a function item type)locator
- information for diagnostics- Returns:
- an iterator over the converted value
-
getConfiguration
Get the Saxon configuration to which this type hierarchy belongs- Returns:
- the configuration
-
isSubType
Determine whether type A is type B or one of its subtypes, recursively. "Subtype" here means a type that is subsumed, that is, a type whose instances are a subset of the instances of the other type.- Parameters:
subtype
- identifies the first typesupertype
- identifies the second type- Returns:
- true if the first type is the second type or is subsumed by the second type
-
relationship
Determine the relationship of one item type to another.- Parameters:
t1
- the first item typet2
- the second item type- Returns:
- One of:
Affinity.SAME_TYPE
if the types are the same;Affinity.SUBSUMES
if the first type subsumes the second (that is, all instances of the second type are also instances of the first);Affinity.SUBSUMED_BY
if the second type subsumes the first;Affinity.OVERLAPS
if the two types overlap (have a non-empty intersection, but neither subsumes the other);Affinity.DISJOINT
if the two types are disjoint (have an empty intersection)
-
computeContentRelationship
protected Affinity computeContentRelationship(ItemType t1, ItemType t2, Optional<IntSet> n1, Optional<IntSet> n2) Compute the relationship between the allowed content-types of two types, for example attribute(*, xs:integer) and attribute(xs:string). Note that although such types are fairly meaningless in a non-schema-aware environment, they are permitted, and supported in Saxon-HE.- Parameters:
t1
- the first typet2
- the second typen1
- the set of element names allowed by the first typen2
- the set of element names allowed by the second type- Returns:
- the relationship, as one of the constants
Affinity.SAME_TYPE
,Affinity.SUBSUMES
,Affinity.SUBSUMED_BY
,Affinity.DISJOINT
,Affinity.OVERLAPS
-
sequenceTypeRelationship
Get the relationship of two sequence types to each other- Parameters:
s1
- the first types2
- the second type- Returns:
- the relationship, as one of the constants
Affinity.SAME_TYPE
,Affinity.SUBSUMES
,Affinity.SUBSUMED_BY
,Affinity.DISJOINT
,Affinity.OVERLAPS
-
schemaTypeRelationship
Get the relationship of two schema types to each other- Parameters:
s1
- the first types2
- the second type- Returns:
- the relationship of the two types, as one of the constants
Affinity.SAME_TYPE
,Affinity.SUBSUMES
,Affinity.SUBSUMED_BY
,Affinity.DISJOINT
,Affinity.OVERLAPS
-
inverseRelationship
-
getGenericFunctionItemType
-