* Evaluate the expression
*/
public Item evaluateItem(XPathContext context) throws XPathException {
String arg0 = argument[0].evaluateItem(context).getStringValue();
NodeInfo doc = null;
try {
doc = (NodeInfo)argument[1].evaluateItem(context);
} catch (XPathException err) {
if ("XPDY0002".equals(err.getErrorCodeLocalPart())) {
if (operation == URI) {
XPathException e = new XPathException("Cannot call the unparsed-entity-uri()" +
" function when there is no context node");
e.setErrorCode("XTDE1370");
throw e;
} else {
XPathException e = new XPathException("Cannot call the unparsed-entity-public-id()" +
" function when there is no context node");
e.setErrorCode("XTDE1380");
throw e;
}
} else if ("XPDY0050".equals(err.getErrorCodeLocalPart())) {
if (operation == URI) {
XPathException e = new XPathException("Can only call the unparsed-entity-uri()" +
" function when the context node is in a tree rooted at a document node");
e.setErrorCode("XTDE1370");
throw e;
} else {
XPathException e = new XPathException("Can only call the unparsed-entity-public-id()" +
" function when the context node is in a tree rooted at a document node");
e.setErrorCode("XTDE1380");
throw e;
}
}
}
if (doc.getNodeKind() != Type.DOCUMENT) {
String code = (operation==URI ? "XTDE1370" : "XTDE1380");
dynamicError("In function " + getDisplayName() +
", the context node must be in a tree whose root is a document node", code, context);
}
String[] ids = ((DocumentInfo)doc).getUnparsedEntity(arg0);