/** * Determine the relationship of one function item type to another * * @return for example {@link net.sf.saxon.type.TypeHierarchy#SUBSUMES}, {@link net.sf.saxon.type.TypeHierarchy#SAME_TYPE} */ public int relationship(FunctionItemType other, TypeHierarchy th) { if (other == AnyFunctionType.getInstance()) { return TypeHierarchy.SUBSUMED_BY; } else if (equals(other)) { return TypeHierarchy.SAME_TYPE; } else if (other == ArrayItemType.ANY_ARRAY_TYPE) { return TypeHierarchy.SUBSUMED_BY; } else if (other.isMapType()){ return TypeHierarchy.DISJOINT; } else if (other instanceof ArrayItemType) { // See bug 3720. Array types are never disjoint, because the empty array // is an instance of every array type ArrayItemType f2 = (ArrayItemType) other; int rel = th.sequenceTypeRelationship(memberType, f2.memberType); return rel==TypeHierarchy.DISJOINT ? TypeHierarchy.OVERLAPS : rel; } else { int rel = TypeHierarchy.DISJOINT; return rel; } }
/** * Determine the relationship of one function item type to another * * @return for example {@link net.sf.saxon.type.TypeHierarchy#SUBSUMES}, {@link net.sf.saxon.type.TypeHierarchy#SAME_TYPE} */ public int relationship(FunctionItemType other, TypeHierarchy th) { if (other == AnyFunctionType.getInstance()) { return TypeHierarchy.SUBSUMED_BY; } else if (equals(other)) { return TypeHierarchy.SAME_TYPE; } else if (other == ArrayItemType.ANY_ARRAY_TYPE) { return TypeHierarchy.SUBSUMED_BY; } else if (other.isMapType()){ return TypeHierarchy.DISJOINT; } else if (other instanceof ArrayItemType) { // See bug 3720. Array types are never disjoint, because the empty array // is an instance of every array type ArrayItemType f2 = (ArrayItemType) other; int rel = th.sequenceTypeRelationship(memberType, f2.memberType); return rel==TypeHierarchy.DISJOINT ? TypeHierarchy.OVERLAPS : rel; } else { int rel = TypeHierarchy.DISJOINT; return rel; } }
boolean narrower = false; for (int i = 0; i < argTypes.length; i++) { int argRel = th.sequenceTypeRelationship(argTypes[i], other.getArgumentTypes()[i]); switch (argRel) { case TypeHierarchy.DISJOINT: int resRel = th.sequenceTypeRelationship(resultType, other.getResultType()); switch (resRel) { case TypeHierarchy.DISJOINT:
boolean narrower = false; for (int i = 0; i < argTypes.length; i++) { int argRel = th.sequenceTypeRelationship(argTypes[i], other.getArgumentTypes()[i]); switch (argRel) { case TypeHierarchy.DISJOINT: int resRel = th.sequenceTypeRelationship(resultType, other.getResultType()); switch (resRel) { case TypeHierarchy.DISJOINT:
return Optional.of(s); int rel = th.sequenceTypeRelationship(resultType, other.getResultType()); if (rel != TypeHierarchy.SAME_TYPE && rel != TypeHierarchy.SUBSUMES) { String s = "The return type of the required function is " + resultType + " but the return" rel = th.sequenceTypeRelationship(argTypes[j], other.getArgumentTypes()[j]); if (rel != TypeHierarchy.SAME_TYPE && rel != TypeHierarchy.SUBSUMED_BY) { String s = "The type of the " + RoleDiagnostic.ordinal(j+1) +
return Optional.of(s); int rel = th.sequenceTypeRelationship(resultType, other.getResultType()); if (rel != TypeHierarchy.SAME_TYPE && rel != TypeHierarchy.SUBSUMES) { String s = "The return type of the required function is " + resultType + " but the return" rel = th.sequenceTypeRelationship(argTypes[j], other.getArgumentTypes()[j]); if (rel != TypeHierarchy.SAME_TYPE && rel != TypeHierarchy.SUBSUMED_BY) { String s = "The type of the " + RoleDiagnostic.ordinal(j+1) +
return TypeHierarchy.OVERLAPS; int valueRel = th.sequenceTypeRelationship(valueType, f2.valueType);
public void checkCompatibility(Component component) { SequenceType st1 = getSourceBinding().getDeclaredType(); if (st1 == null) { st1 = SequenceType.ANY_SEQUENCE; } GlobalVariable other = (GlobalVariable) component.getActor(); TypeHierarchy th = component.getDeclaringPackage().getConfiguration().getTypeHierarchy(); int relation = th.sequenceTypeRelationship(st1, other.getRequiredType()); if (relation != TypeHierarchy.SAME_TYPE) { compileError( "The declared type of the overriding variable $" + getVariableQName().getDisplayName() + " is different from that of the overridden variable", "XTSE3070"); } }
return TypeHierarchy.OVERLAPS; int valueRel = th.sequenceTypeRelationship(valueType, f2.valueType);
public void checkCompatibility(Component component) { SequenceType st1 = getSourceBinding().getDeclaredType(); if (st1 == null) { st1 = SequenceType.ANY_SEQUENCE; } GlobalVariable other = (GlobalVariable) component.getActor(); TypeHierarchy th = component.getDeclaringPackage().getConfiguration().getTypeHierarchy(); int relation = th.sequenceTypeRelationship(st1, other.getRequiredType()); if (relation != TypeHierarchy.SAME_TYPE) { compileError( "The declared type of the overriding variable $" + getVariableQName().getDisplayName() + " is different from that of the overridden variable", "XTSE3070"); } }
int rel = th.sequenceTypeRelationship(entry, f2.getValueType()); if (!(rel == TypeHierarchy.SUBSUMED_BY || rel == TypeHierarchy.SAME_TYPE)) { return TypeHierarchy.OVERLAPS;
int rel = th.sequenceTypeRelationship(entry, f2.getValueType()); if (!(rel == TypeHierarchy.SUBSUMED_BY || rel == TypeHierarchy.SAME_TYPE)) { return TypeHierarchy.OVERLAPS;
private SequenceType combineTypeDeclarations(String asAtt, String extraAsAtt) { SequenceType declaredType = null; if (asAtt != null) { try { declaredType = sourceElement.makeSequenceType(asAtt); } catch (XPathException e) { sourceElement.compileErrorInAttribute(e.getMessage(), e.getErrorCodeLocalPart(), "as"); } } if (extraAsAtt != null) { SequenceType extraResultType = null; try { extraResultType = sourceElement.makeExtendedSequenceType(extraAsAtt); } catch (XPathException e) { sourceElement.compileErrorInAttribute(e.getMessage(), e.getErrorCodeLocalPart(), "saxon:as"); extraResultType = SequenceType.ANY_SEQUENCE; } if (asAtt != null) { int rel = sourceElement.getConfiguration().getTypeHierarchy().sequenceTypeRelationship(extraResultType, declaredType); if (rel == TypeHierarchy.SAME_TYPE || rel == TypeHierarchy.SUBSUMED_BY) { declaredType = extraResultType; } else { sourceElement.compileErrorInAttribute("When both are present, @saxon:as must be a subtype of @as", "SXER7TBA", "as"); } } else { declaredType = extraResultType; } } return declaredType; }
private SequenceType combineTypeDeclarations(String asAtt, String extraAsAtt) { SequenceType declaredType = null; if (asAtt != null) { try { declaredType = sourceElement.makeSequenceType(asAtt); } catch (XPathException e) { sourceElement.compileErrorInAttribute(e.getMessage(), e.getErrorCodeLocalPart(), "as"); } } if (extraAsAtt != null) { SequenceType extraResultType = null; try { extraResultType = sourceElement.makeExtendedSequenceType(extraAsAtt); } catch (XPathException e) { sourceElement.compileErrorInAttribute(e.getMessage(), e.getErrorCodeLocalPart(), "saxon:as"); extraResultType = SequenceType.ANY_SEQUENCE; } if (asAtt != null) { int rel = sourceElement.getConfiguration().getTypeHierarchy().sequenceTypeRelationship(extraResultType, declaredType); if (rel == TypeHierarchy.SAME_TYPE || rel == TypeHierarchy.SUBSUMED_BY) { declaredType = extraResultType; } else { sourceElement.compileErrorInAttribute("When both are present, @saxon:as must be a subtype of @as", "SXER7TBA", "as"); } } else { declaredType = extraResultType; } } return declaredType; }
SequenceType v2 = ((MapType)t2).getValueType(); int keyRel = relationship(k1, k2); int valueRel = sequenceTypeRelationship(v1, v2); int rel = combineRelationships(keyRel, valueRel); if (rel == SAME_TYPE || rel == SUBSUMES || rel == SUBSUMED_BY) {
SequenceType v2 = ((MapType)t2).getValueType(); int keyRel = relationship(k1, k2); int valueRel = sequenceTypeRelationship(v1, v2); int rel = combineRelationships(keyRel, valueRel); if (rel == SAME_TYPE || rel == SUBSUMES || rel == SUBSUMED_BY) {
int rel = getConfiguration().getTypeHierarchy().sequenceTypeRelationship(extraResultType, requiredType); if (rel == TypeHierarchy.SAME_TYPE || rel == TypeHierarchy.SUBSUMED_BY) { requiredType = extraResultType;
int rel = getConfiguration().getTypeHierarchy().sequenceTypeRelationship(extraResultType, requiredType); if (rel == TypeHierarchy.SAME_TYPE || rel == TypeHierarchy.SUBSUMED_BY) { requiredType = extraResultType;
int rel = getConfiguration().getTypeHierarchy().sequenceTypeRelationship(extraResultType, resultType); if (rel == TypeHierarchy.SAME_TYPE || rel == TypeHierarchy.SUBSUMED_BY) { resultType = extraResultType;
int rel = getConfiguration().getTypeHierarchy().sequenceTypeRelationship(extraResultType, resultType); if (rel == TypeHierarchy.SAME_TYPE || rel == TypeHierarchy.SUBSUMED_BY) { resultType = extraResultType;