final ItemType type = resultType.getPrimaryType();
if (type != AnyItemType.getInstance()) {
result = new ItemMappingIterator(result,
new ItemMappingFunction() {
public Item map(Item item) throws XPathException {
if (!type.matchesItem(item, false, config)) {
String msg = "Item returned by integrated function " +
getFunctionName().getDisplayName() +
"() is not of declared item type. Actual type is " +
Value.asValue(item).getItemType(config.getTypeHierarchy()).toString(config.getNamePool()) +
"; expected type is " + type.toString(config.getNamePool());