* @param valueAttr
* @return
*/
private Output createOutput(OMElement parameterElement) {
Output parameter = new Output();
OMAttribute srcXPathAttr = parameterElement
.getAttribute(ATT_SOURCE_XPATH);
OMAttribute targetXPathAttr = parameterElement
.getAttribute(ATT_TARGET_XPATH);
OMAttribute targetKeyAttr = parameterElement
.getAttribute(ATT_TARGET_KEY);
if ((null == targetXPathAttr || null == targetXPathAttr
.getAttributeValue())
&& (null == targetKeyAttr || null == targetKeyAttr
.getAttributeValue())) {
handleException("Output without a target-xpath or target-key attribute, "
+ "but it is required to have a target-xpath or target-key attribute for all outputs");
}
if (null != targetXPathAttr
&& null != targetXPathAttr.getAttributeValue()) {
if (null == srcXPathAttr
|| null == srcXPathAttr.getAttributeValue()) {
handleException("Output without source-xpath attribute, "
+ "but it is required to have source-xpath attribute when target-xpath is present for all outputs");
}
try {
parameter.setSourceXPath(SynapseXPathFactory.getSynapseXPath(
parameterElement, ATT_SOURCE_XPATH));
} catch (JaxenException e) {
handleException(
String
.format(
"Couldn't build the source-xpath from the expression: %s for the output",
srcXPathAttr.getAttributeValue()), e);
}
try {
parameter.setTargetXPath(SynapseXPathFactory.getSynapseXPath(
parameterElement, ATT_TARGET_XPATH));
} catch (JaxenException e) {
handleException(
String
.format(
"Couldn't build the target-xpath from the expression: %s for the output",
srcXPathAttr.getAttributeValue()), e);
}
} else {
parameter.setTargetKey(targetKeyAttr.getAttributeValue());
}
return parameter;
}