l = getBpelRuntimeContext().getExpLangRuntime().evaluate(expr, getEvaluationContext());
} catch (EvaluationException e) {
String msg = __msgs.msgEvalException(from.toString(), e.getMessage());
if (__log.isDebugEnabled()) __log.debug(from + ": " + msg);
if (e.getCause() instanceof FaultException) throw (FaultException)e.getCause();
throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
}
if (l.size() == 0) {
String msg = __msgs.msgRValueNoNodesSelected(expr.toString());
if (__log.isDebugEnabled()) __log.debug(from + ": " + msg);
throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg, new Throwable("ignoreMissingFromData"));
} else if (l.size() > 1) {
String msg = __msgs.msgRValueMultipleNodesSelected(expr.toString());
if (__log.isDebugEnabled()) __log.debug(from + ": " + msg);
throw new FaultException(getOAsssign().getOwner().constants.qnSelectionFailure, msg);
}
retVal = (Node) l.get(0);
} else if (from instanceof OAssign.Literal) {
String literal = ((OAssign.Literal) from).getXmlLiteral();
Element literalRoot;
try {
literalRoot = DOMUtils.stringToDOM(literal);
} catch (Exception e) {
throw new RuntimeException("XML literal parsing failed " + literal, e);
}
assert literalRoot.getLocalName().equals("literal");
// We'd like a single text node...
literalRoot.normalize();
retVal = literalRoot.getFirstChild();
// Adjust for whitespace before an element.
if (retVal != null && retVal.getNodeType() == Node.TEXT_NODE
&& retVal.getTextContent().trim().length() == 0
&& retVal.getNextSibling() != null) {
retVal = retVal.getNextSibling();
}
if (retVal == null) {
// Special case, no children --> empty TII
retVal = literalRoot.getOwnerDocument().createTextNode("");
} else if (retVal.getNodeType() == Node.ELEMENT_NODE) {
// Make sure there is no more elements.
Node x = retVal.getNextSibling();
while (x != null) {
if (x.getNodeType() == Node.ELEMENT_NODE) {
String msg = __msgs.msgLiteralContainsMultipleEIIs();
if (__log.isDebugEnabled())
__log.debug(from + ": " + msg);
throw new FaultException(
getOAsssign().getOwner().constants.qnSelectionFailure,
msg);
}
x = x.getNextSibling();
}
} else if (retVal.getNodeType() == Node.TEXT_NODE) {
// Make sure there are no elements following this text node.
Node x = retVal.getNextSibling();
while (x != null) {
if (x.getNodeType() == Node.ELEMENT_NODE) {
String msg = __msgs.msgLiteralContainsMixedContent();
if (__log.isDebugEnabled())
__log.debug(from + ": " + msg);
throw new FaultException(
getOAsssign().getOwner().constants.qnSelectionFailure,
msg);
}
x = x.getNextSibling();
}
}
if (retVal == null) {
String msg = __msgs.msgLiteralMustContainTIIorEII();
if (__log.isDebugEnabled())
__log.debug(from + ": " + msg);
throw new FaultException(
getOAsssign().getOwner().constants.qnSelectionFailure,
msg);
}
} else {
String msg = __msgs
.msgInternalError("Unknown RVALUE type: " + from);
if (__log.isErrorEnabled())
__log.error(from + ": " + msg);
throw new FaultException(
getOAsssign().getOwner().constants.qnSelectionFailure, msg);
}
// Now verify we got something.
if (retVal == null) {
String msg = __msgs.msgEmptyRValue();
if (__log.isDebugEnabled())
__log.debug(from + ": " + msg);
throw new FaultException(
getOAsssign().getOwner().constants.qnSelectionFailure, msg);
}
// Now check that we got the right thing.
switch (retVal.getNodeType()) {
case Node.TEXT_NODE:
case Node.ATTRIBUTE_NODE:
case Node.ELEMENT_NODE:
case Node.CDATA_SECTION_NODE:
break;
default:
String msg = __msgs.msgInvalidRValue();
if (__log.isDebugEnabled())
__log.debug(from + ": " + msg);
throw new FaultException(
getOAsssign().getOwner().constants.qnSelectionFailure, msg);
}
return retVal;