Class TypeHierarchy

  • Direct Known Subclasses:

    public class TypeHierarchy
    extends java.lang.Object
    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.
    • Constructor Detail

      • TypeHierarchy

        public TypeHierarchy​(Configuration config)
        Create the type hierarchy cache for a configuration
        config - the configuration
    • Method Detail

      • getNearestNamedType

        public static SchemaType getNearestNamedType​(SchemaType type)
        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).
        the nearest type, found by following the getBaseType() relation recursively, that is not an anonymous type
      • applyFunctionConversionRules

        public GroundedValue applyFunctionConversionRules​(Sequence value,
                                                          SequenceType requiredType,
                                                          java.util.function.Supplier<RoleDiagnostic> roleSupplier,
                                                          Location locator)
                                                   throws XPathException
        Apply the function conversion rules to a value, given a required type.
        value - a value to be converted
        requiredType - the required type
        roleSupplier - identifies the value to be converted in error messages
        locator - identifies the location for error messages
        the converted value
        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
        iterator - An iterator over the supplied value of the parameter
        suppliedItemType - the item type of the supplied value
        requiredItemType - the required item type (typically a function item type)
        locator - information for diagnostics
        an iterator over the converted value
      • getConfiguration

        public Configuration getConfiguration()
        Get the Saxon configuration to which this type hierarchy belongs
        the configuration
      • isSubType

        public boolean isSubType​(ItemType subtype,
                                 ItemType supertype)
        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.
        subtype - identifies the first type
        supertype - identifies the second type
        true if the first type is the second type or is subsumed by the second type
      • relationship

        public Affinity relationship​(ItemType t1,
                                     ItemType t2)
        Determine the relationship of one item type to another.
        t1 - the first item type
        t2 - the second item type
        One of:
      • computeContentRelationship

        protected Affinity computeContentRelationship​(ItemType t1,
                                                      ItemType t2,
                                                      java.util.Optional<IntSet> n1,
                                                      java.util.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.
        t1 - the first type
        t2 - the second type
        n1 - the set of element names allowed by the first type
        n2 - the set of element names allowed by the second type
        the relationship, as one of the constants Affinity.SAME_TYPE, Affinity.SUBSUMES, Affinity.SUBSUMED_BY, Affinity.DISJOINT, Affinity.OVERLAPS
      • inverseRelationship

        public static Affinity inverseRelationship​(Affinity relation)
      • getGenericFunctionItemType

        public ItemType getGenericFunctionItemType()