* @return
*/
@SuppressWarnings("unchecked")
protected Input createInput(OMElement inputElement) {
Input parameter = new Input();
OMAttribute parameterNameAttr = inputElement.getAttribute(ATT_NAME);
OMAttribute srcXPathAttr = inputElement.getAttribute(ATT_SOURCE_XPATH);
OMAttribute typeAttr = inputElement.getAttribute(ATT_TYPE);
OMAttribute srcValueAttr = inputElement.getAttribute(ATT_SOURCE_VALUE);
if (null != typeAttr && null != typeAttr.getAttributeValue()) {
parameter.setType(typeAttr.getAttributeValue());
for (Iterator<OMElement> itr = inputElement
.getChildrenWithName(Q_INPUT); itr.hasNext();) {
parameter.getSubInputs().add(createInput(itr.next()));
}
} else {
if (null == parameterNameAttr
|| null == parameterNameAttr.getAttributeValue()) {
handleException("Input without the name attribute has been found, but it is required to have the name attribute for all inputs");
}
parameter.setName(parameterNameAttr.getAttributeValue());
if ((null == srcXPathAttr || null == srcXPathAttr
.getAttributeValue())
&& (null == srcValueAttr || null == srcValueAttr
.getAttributeValue())) {
handleException(String
.format(
"Input parameter %s: has no source-xpath or source-value attribute, "
+ "but it is required to have source-xpath or source-value attribute for all inputs",
parameter.getName()));
}
if (null != srcXPathAttr
&& null != srcXPathAttr.getAttributeValue()) {
try {
parameter.setSourceXPath(SynapseXPathFactory
.getSynapseXPath(inputElement, ATT_SOURCE_XPATH));
} catch (JaxenException e) {
handleException(
String
.format(
"Input parameter %s: couldn't build the source-xpath from the expression: %s",
parameter.getName(), srcXPathAttr
.getAttributeValue()), e);
}
} else {
parameter.setSourceValue(srcValueAttr.getAttributeValue());
}
}
return parameter;
}