*/
public void checkPermittedContents(SchemaType parentType, StaticContext env, boolean whole) throws XPathException {
// if the expression is a constant value, check that it is valid for the type
if (select instanceof Literal) {
Value selectValue = ((Literal)select).getValue();
SimpleType stype = null;
if (parentType instanceof SimpleType && whole) {
stype = (SimpleType)parentType;
} else if (parentType instanceof ComplexType && ((ComplexType)parentType).isSimpleContent()) {
stype = ((ComplexType)parentType).getSimpleContentType();
}
if (whole && stype != null && !stype.isNamespaceSensitive()) {
// Can't validate namespace-sensitive content statically
ValidationFailure err = stype.validateContent(
selectValue.getStringValue(), null, env.getConfiguration().getNameChecker());
if (err != null) {
err.setLocator(this);
throw err.makeException();
}
return;
}
if (parentType instanceof ComplexType &&
!((ComplexType)parentType).isSimpleContent() &&
!((ComplexType)parentType).isMixedContent() &&
!Whitespace.isWhite(selectValue.getStringValue())) {
XPathException err = new XPathException("Complex type " + parentType.getDescription() +
" does not allow text content " +
Err.wrap(selectValue.getStringValue()));
err.setLocator(this);
err.setIsTypeError(true);
throw err;
}
}