String to = assignment.getTo();
XPathFactory factory = XPathFactory.newInstance();
XPath xpathFrom = factory.newXPath();
XPathExpression exprFrom = xpathFrom.compile(from);
XPath xpathTo = factory.newXPath();
XPathExpression exprTo = xpathTo.compile(to);
Object target = null;
Object source = null;
if (isInput) {
source = context.getVariable(sourceExpr);
target = ((WorkItem) workItem).getParameter(targetExpr);
} else {
target = context.getVariable(targetExpr);
source = ((WorkItem) workItem).getResult(sourceExpr);
}
Object targetElem = null;
// XPATHExpressionModifier modifier = new XPATHExpressionModifier();
// // modify the tree, returning the root node
// target = modifier.insertMissingData(to, (org.w3c.dom.Node) target);
// now pick the leaf for this operation
if (target != null) {
org.w3c.dom.Node parent = null;
parent = ((org.w3c.dom.Node) target).getParentNode();
targetElem = exprTo.evaluate(parent, XPathConstants.NODE);
if (targetElem == null) {
throw new RuntimeException("Nothing was selected by the to expression " + to + " on " + targetExpr);
}
}