/** * 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; }
/** * Check that any elements and attributes constructed or returned by this expression are acceptable * in the content model of a given complex type. It's always OK to say yes, since the check will be * repeated at run-time. The process of checking element and attribute constructors against the content * model of a complex type also registers the type of content expected of those constructors, so the * static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, boolean whole) throws XPathException { if (parentType instanceof SimpleType) { String msg = "Attributes are not permitted here: "; if (parentType.isAnonymousType()) { msg += "the containing element is defined to have a simple type"; } else { msg += "the containing element is of simple type " + parentType.getDescription(); } XPathException err = new XPathException(msg); err.setIsTypeError(true); err.setLocation(getLocation()); throw err; } }
/** * Check that any elements and attributes constructed or returned by this expression are acceptable * in the content model of a given complex type. It's always OK to say yes, since the check will be * repeated at run-time. The process of checking element and attribute constructors against the content * model of a complex type also registers the type of content expected of those constructors, so the * static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, boolean whole) throws XPathException { if (parentType instanceof SimpleType) { String msg = "Attributes are not permitted here: "; if (parentType.isAnonymousType()) { msg += "the containing element is defined to have a simple type"; } else { msg += "the containing element is of simple type " + parentType.getDescription(); } XPathException err = new XPathException(msg); err.setIsTypeError(true); err.setLocation(getLocation()); throw err; } }
/** * Check that any elements and attributes constructed or returned by this expression are acceptable * in the content model of a given complex type. It's always OK to say yes, since the check will be * repeated at run-time. The process of checking element and attribute constructors against the content * model of a complex type also registers the type of content expected of those constructors, so the * static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, boolean whole) throws XPathException { if (parentType instanceof SimpleType || ((ComplexType) parentType).isSimpleContent()) { String msg = "Elements are not permitted here: the containing element "; if (parentType instanceof SimpleType) { if (parentType.isAnonymousType()) { msg += "is defined to have a simple type"; } else { msg += "is of simple type " + parentType.getDescription(); } } else { msg += "has a complex type with simple content"; } XPathException err = new XPathException(msg); err.setIsTypeError(true); err.setLocation(getLocation()); throw err; } // NOTE: we could in principle check that if all the elements permitted in the content of the parentType // themselves have a simple type (not uncommon, perhaps) then this element must not have element content. }
/** * Check that any elements and attributes constructed or returned by this expression are acceptable * in the content model of a given complex type. It's always OK to say yes, since the check will be * repeated at run-time. The process of checking element and attribute constructors against the content * model of a complex type also registers the type of content expected of those constructors, so the * static validation can continue recursively. */ public void checkPermittedContents(SchemaType parentType, boolean whole) throws XPathException { if (parentType instanceof SimpleType || ((ComplexType) parentType).isSimpleContent()) { String msg = "Elements are not permitted here: the containing element "; if (parentType instanceof SimpleType) { if (parentType.isAnonymousType()) { msg += "is defined to have a simple type"; } else { msg += "is of simple type " + parentType.getDescription(); } } else { msg += "has a complex type with simple content"; } XPathException err = new XPathException(msg); err.setIsTypeError(true); err.setLocation(getLocation()); throw err; } // NOTE: we could in principle check that if all the elements permitted in the content of the parentType // themselves have a simple type (not uncommon, perhaps) then this element must not have element content. }