DocumentImpl doc = context.getBroker().getXMLResource(XmldbURI.xmldbUriFor(path), Lock.READ_LOCK);
doc = context.getBroker().getXMLResource(XmldbURI.xmldbUriFor(path), Lock.READ_LOCK);
    public Sequence eval(Sequence[] args, Sequence contextSequence)            throws XPathException {        Sequence defaultReturn = (isCalledAs("binary-doc") ? Sequence.EMPTY_SEQUENCE : BooleanValue.FALSE);        if (args[0].isEmpty())            return defaultReturn;        String path = args[0].getStringValue();        try {            DocumentImpl doc = context.getBroker().getXMLResource(XmldbURI.xmldbUriFor(path), Lock.READ_LOCK);            if (doc == null)                return defaultReturn;            if (doc.getResourceType() != DocumentImpl.BINARY_FILE)                throw new XPathException(getASTNode(), path + " exists but is not a binary resource");            if (isCalledAs("binary-doc")) {                BinaryDocument bin = (BinaryDocument) doc;                byte[] data = context.getBroker().getBinaryResource(bin);                return new Base64Binary(data);            } else                return BooleanValue.TRUE;        } catch (URISyntaxException e) {            throw new XPathException(getASTNode(), "Invalid resource uri",e);        } catch (PermissionDeniedException e) {            throw new XPathException(getASTNode(), path + ": permission denied to read resource");        }    }