AnyURIValue imgPath = (AnyURIValue)args[0];
AnyURIValue imgPath = (AnyURIValue)args[0].itemAt(0);
	public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException	{		//was a image speficifed		if (args[0].isEmpty())            return Sequence.EMPTY_SEQUENCE;				//get the path of the image		AnyURIValue imgPath = (AnyURIValue)args[0];                //Get the image document from the db        DBBroker dbbroker = context.getBroker();        DocumentImpl docImage = null;        try        {        	docImage = dbbroker.getXMLResource(imgPath.toXmldbURI(), Lock.READ_LOCK);        }        catch (PermissionDeniedException e)        {        	throw new XPathException(getASTNode(), imgPath + ": permission denied to read resource");         }                //Valid document?        if (docImage == null)        {        	LOG.error(imgPath + " does not exist!");                return Sequence.EMPTY_SEQUENCE;        }                //Binary Document?        if (docImage.getResourceType() != DocumentImpl.BINARY_FILE)        {            LOG.error(imgPath + " exists but is not a binary resource!");        	return Sequence.EMPTY_SEQUENCE;        }               //Binary document is an image?        if(!docImage.getMetadata().getMimeType().startsWith("image/"))        {        	LOG.error(imgPath + " exists but is not an image!");        	return Sequence.EMPTY_SEQUENCE;        }                //Get the image document as a binary document        BinaryDocument binImage = (BinaryDocument) docImage;                //get a byte array representing the image        byte[] imgData = dbbroker.getBinaryResource(binImage);                //close the image from the db        dbbroker.closeDocument();                Image image = null;        int iHeight = -1;                //Create an Image object from the byte array        try        {        	image = ImageIO.read(new ByteArrayInputStream(imgData));        }        catch(IOException ioe)        {        	LOG.error(imgPath + " could not read image data!");        	return Sequence.EMPTY_SEQUENCE;        }                //Get the Height of the image        iHeight = image.getHeight(null);                //did we get the Height of the image?        if(iHeight == -1)        {        	//no, log the error        	LOG.error(imgPath + " could not read image data!");        	return Sequence.EMPTY_SEQUENCE;         }        else        {        	//return the Height of the image        	return new IntegerValue(iHeight);	        }	}