/** * 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). * @return the nearest type, found by following the {@code getBaseType()} relation * recursively, that is not an anonymous type */ default SchemaType getNearestNamedType() { SchemaType type = this; while (type.isAnonymousType()) { type = type.getBaseType(); } return 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). * @return the nearest type, found by following the {@code getBaseType()} relation * recursively, that is not an anonymous type */ default SchemaType getNearestNamedType() { SchemaType type = this; while (type.isAnonymousType()) { type = type.getBaseType(); } return type; }
t1 = t1.getBaseType(); if (t1 == null) { break; t2 = t2.getBaseType(); if (t2 == null) { break;
t1 = t1.getBaseType(); if (t1 == null) { break; t2 = t2.getBaseType(); if (t2 == null) { break;
while ((t1 = t1.getBaseType()) != null) { if (t1.isSameType(s2)) { return SUBSUMED_BY; while ((t2 = t2.getBaseType()) != null) { if (t2.isSameType(s1)) { return SUBSUMES;
private boolean matchesAnnotation(int annotation) { if (requiredType == StandardNames.XS_ANY_TYPE) { return true; } if (annotation == -1) { annotation = (kind==Type.ATTRIBUTE ? StandardNames.XS_UNTYPED_ATOMIC : StandardNames.XS_UNTYPED); } if (matchDTDTypes) { annotation = annotation & NamePool.FP_MASK; } else if (((annotation & NodeInfo.IS_DTD_TYPE) != 0)) { return (requiredType == StandardNames.XS_UNTYPED_ATOMIC); } if (annotation == requiredType) { return true; } // see if the type annotation is a subtype of the required type try { SchemaType type = config.getSchemaType(annotation & NamePool.FP_MASK).getBaseType(); if (type == null) { // only true if annotation = XS_ANY_TYPE return false; } ItemType actual = new ContentTypeTest(kind, type, config); return config.getTypeHierarchy().isSubType(actual, this); } catch (UnresolvedReferenceException e) { throw new IllegalStateException(e.getMessage()); } //return false; }
private boolean matchesAnnotation(int annotation) { if (requiredType == StandardNames.XS_ANY_TYPE) { return true; } if (annotation == -1) { annotation = (kind==Type.ATTRIBUTE ? StandardNames.XS_UNTYPED_ATOMIC : StandardNames.XS_UNTYPED); } if (matchDTDTypes) { annotation = annotation & NamePool.FP_MASK; } else if (((annotation & NodeInfo.IS_DTD_TYPE) != 0)) { return (requiredType == StandardNames.XS_UNTYPED_ATOMIC); } if (annotation == requiredType) { return true; } // see if the type annotation is a subtype of the required type try { SchemaType type = config.getSchemaType(annotation & NamePool.FP_MASK).getBaseType(); if (type == null) { // only true if annotation = XS_ANY_TYPE return false; } ItemType actual = new ContentTypeTest(kind, type, config); return config.getTypeHierarchy().isSubType(actual, this); } catch (UnresolvedReferenceException e) { throw new IllegalStateException(e.getMessage()); } //return false; }
while ((t1 = t1.getBaseType()) != null) { if (t1.isSameType(s2)) { return SUBSUMED_BY; while ((t2 = t2.getBaseType()) != null) { if (t2.isSameType(s1)) { return SUBSUMES;
} else { marker = "<"; st = st.getBaseType(); if (st == null) { return "Q{" + NamespaceConstant.SCHEMA + "}anyType";
/** * Get a string representation of the type. This will be a string that conforms to the * XPath ItemType production, for example a QName (always in "Q{uri}local" format, or a construct * such as "node()" or "map(*)". If the type is an anonymous schema type, the name of the nearest * named base type will be given, preceded by the character "<". * @return a string representation of the type * @since 9.7 */ public String toString() { net.sf.saxon.type.ItemType type = getUnderlyingItemType(); if (type instanceof SchemaType) { String marker = ""; SchemaType st = (SchemaType)type; StructuredQName name = null; while (true) { name = st.getStructuredQName(); if (name != null) { return marker + name.getEQName(); } else { marker = "<"; st = st.getBaseType(); if (st == null) { return "Q{" + NamespaceConstant.SCHEMA + "}anyType"; } } } } else { return type.toString(); } }
/** * This method returns true if there is a derivation between the reference type definition, that is the TypeInfo * on which the method is being called, and the other type definition, that is the one passed as parameters. * This method implements the DOM Level 3 TypeInfo interface. It must be called only on a valid type. * * @param typeNamespaceArg the namespace of the "other" type * @param typeNameArg the local name of the "other" type * @param derivationMethod the derivation method: zero or more of {@link SchemaType#DERIVATION_RESTRICTION}, * {@link SchemaType#DERIVATION_EXTENSION}, {@link SchemaType#DERIVATION_LIST}, or {@link SchemaType#DERIVATION_UNION}. * Zero means derived by any possible route. */ public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod) throws IllegalStateException { SchemaType base = schemaType.getBaseType(); int fingerprint = config.getNamePool().allocateFingerprint(typeNamespaceArg, typeNameArg); if (derivationMethod == 0 || (derivationMethod & schemaType.getDerivationMethod()) != 0) { if (base.getFingerprint() == fingerprint) { return true; } else if (base instanceof AnyType) { return false; } else { return new TypeInfoImpl(config, base).isDerivedFrom(typeNamespaceArg, typeNameArg, derivationMethod); } } return false; // Note: if derivationMethod is RESTRICTION, this interpretation requires every step to be derived // by restriction. An alternative interpretation is that at least one step must be derived by restriction. }
/** * This method returns true if there is a derivation between the reference type definition, that is the TypeInfo * on which the method is being called, and the other type definition, that is the one passed as parameters. * This method implements the DOM Level 3 TypeInfo interface. It must be called only on a valid type. * @param typeNamespaceArg the namespace of the "other" type * @param typeNameArg the local name of the "other" type * @param derivationMethod the derivation method: zero or more of {@link SchemaType#DERIVATION_RESTRICTION}, * {@link SchemaType#DERIVATION_EXTENSION}, {@link SchemaType#DERIVATION_LIST}, or {@link SchemaType#DERIVATION_UNION}. * Zero means derived by any possible route. */ public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod) throws IllegalStateException { SchemaType base = schemaType.getBaseType(); int fingerprint = config.getNamePool().allocate("", typeNamespaceArg, typeNameArg); if (derivationMethod==0 || (derivationMethod & schemaType.getDerivationMethod()) != 0) { if (base.getFingerprint() == fingerprint) { return true; } else if (base instanceof AnyType) { return false; } else { return new TypeInfoImpl(config, base).isDerivedFrom(typeNamespaceArg, typeNameArg, derivationMethod); } } return false; // Note: if derivationMethod is RESTRICTION, this interpretation requires every step to be derived // by restriction. An alternative interpretation is that at least one step must be derived by restriction. }
/** * This method returns true if there is a derivation between the reference type definition, that is the TypeInfo * on which the method is being called, and the other type definition, that is the one passed as parameters. * This method implements the DOM Level 3 TypeInfo interface. It must be called only on a valid type. * * @param typeNamespaceArg the namespace of the "other" type * @param typeNameArg the local name of the "other" type * @param derivationMethod the derivation method: zero or more of {@link SchemaType#DERIVATION_RESTRICTION}, * {@link SchemaType#DERIVATION_EXTENSION}, {@link SchemaType#DERIVATION_LIST}, or {@link SchemaType#DERIVATION_UNION}. * Zero means derived by any possible route. */ public boolean isDerivedFrom(String typeNamespaceArg, String typeNameArg, int derivationMethod) throws IllegalStateException { SchemaType base = schemaType.getBaseType(); int fingerprint = config.getNamePool().allocateFingerprint(typeNamespaceArg, typeNameArg); if (derivationMethod == 0 || (derivationMethod & schemaType.getDerivationMethod()) != 0) { if (base.getFingerprint() == fingerprint) { return true; } else if (base instanceof AnyType) { return false; } else { return new TypeInfoImpl(config, base).isDerivedFrom(typeNamespaceArg, typeNameArg, derivationMethod); } } return false; // Note: if derivationMethod is RESTRICTION, this interpretation requires every step to be derived // by restriction. An alternative interpretation is that at least one step must be derived by restriction. }
return SUBSUMED_BY; st = st.getBaseType(); if (st == null) { return DISJOINT;