ValueRepresentation value, SequenceType requiredType, final XPathContext context)
throws XPathException {
final TypeHierarchy th = context.getConfiguration().getTypeHierarchy();
final ItemType requiredItemType = requiredType.getPrimaryType();
ItemType suppliedItemType = (value instanceof NodeInfo
? new NameTest(((NodeInfo)value))
: ((Value)value).getItemType(th));
SequenceIterator iterator = Value.asIterator(value);
if (requiredItemType.isAtomicType()) {