Package net.sf.saxon.type
Class TypeHierarchy
java.lang.Object
net.sf.saxon.type.TypeHierarchy
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
FieldsModifier and TypeFieldDescriptionprotected Configurationstatic final intConstant denoting relationship between two types: A is disjoint from Bstatic final intConstant denoting relationship between two types: A overlaps Bstatic final intConstant denoting relationship between two types: A is the same type as Bstatic final intConstant denoting relationship between two types: A is subsumed by Bstatic final intConstant denoting relationship between two types: A subsumes B -
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 function items are supplied as arguments to a function call.Sequence<?>applyFunctionConversionRules(Sequence<?> value, SequenceType requiredType, RoleDiagnostic role, Location locator) Apply the function conversion rules to a value, given a required type.protected intCompute 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 intinverseRelationship(int relation) booleanDetermine whether type A is type B or one of its subtypes, recursively.intrelationship(ItemType t1, ItemType t2) Determine the relationship of one item type to another.intGet the relationship of two schema types to each otherintGet the relationship of two sequence types to each other
-
Field Details
-
config
-
SAME_TYPE
public static final int SAME_TYPEConstant denoting relationship between two types: A is the same type as B- See Also:
-
SUBSUMES
public static final int SUBSUMESConstant denoting relationship between two types: A subsumes B- See Also:
-
SUBSUMED_BY
public static final int SUBSUMED_BYConstant denoting relationship between two types: A is subsumed by B- See Also:
-
OVERLAPS
public static final int OVERLAPSConstant denoting relationship between two types: A overlaps B- See Also:
-
DISJOINT
public static final int DISJOINTConstant denoting relationship between two types: A is disjoint from B- See Also:
-
-
Constructor Details
-
TypeHierarchy
Create the type hierarchy cache for a configuration- Parameters:
config- the configuration
-
-
Method Details
-
applyFunctionConversionRules
public Sequence<?> applyFunctionConversionRules(Sequence<?> value, SequenceType requiredType, RoleDiagnostic role, 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 typerole- 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 function items are supplied as arguments to a function call. This does not happen in Saxon-HE, so the implementation is subclassed in Saxon-PE/EE- 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:
SAME_TYPEif the types are the same;SUBSUMESif the first type subsumes the second (that is, all instances of the second type are also instances of the first);SUBSUMED_BYif the second type subsumes the first;OVERLAPSif the two types overlap (have a non-empty intersection, but neither subsumes the other);DISJOINTif the two types are disjoint (have an empty intersection)
-
computeContentRelationship
protected int 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 typesn1- the set of element names allowed by the first typen2- the set of element names allowed by the second type- Returns:
- the relationship (same type, subsumes, overlaps, subsumed-by)
-
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
SAME_TYPE,SUBSUMES,SUBSUMED_BY,DISJOINT,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
SAME_TYPE,SUBSUMES,SUBSUMED_BY,DISJOINT
-
inverseRelationship
public static int inverseRelationship(int relation) -
getGenericFunctionItemType
-