use of javax.xml.xquery.XQResultSequence in project iaf by ibissource.
the class XQueryPipe method doPipe.
public PipeRunResult doPipe(Object input, IPipeLineSession session) throws PipeRunException {
if (input == null) {
throw new PipeRunException(this, getLogPrefix(session) + "got null input");
}
if (!(input instanceof String)) {
throw new PipeRunException(this, getLogPrefix(session) + "got an invalid type as input, expected String, got " + input.getClass().getName());
}
try {
String stringResult = (String) input;
// We already specifically use Saxon in this pipe, hence set xslt2
// to true to make XmlUtils use the Saxon
// DocumentBuilderFactoryImpl.
ParameterResolutionContext prc = new ParameterResolutionContext(stringResult, session, isNamespaceAware(), true);
Map parametervalues = null;
if (getParameterList() != null) {
parametervalues = prc.getValueMap(getParameterList());
}
preparedExpression.bindDocument(XQConstants.CONTEXT_ITEM, stringResult, null, null);
Iterator iterator = getParameterList().iterator();
while (iterator.hasNext()) {
Parameter parameter = (Parameter) iterator.next();
preparedExpression.bindObject(new QName(parameter.getName()), parametervalues.get(parameter.getName()), null);
}
XQResultSequence resultSequence = preparedExpression.executeQuery();
stringResult = resultSequence.getSequenceAsString(null);
return new PipeRunResult(getForward(), stringResult);
} catch (Exception e) {
throw new PipeRunException(this, getLogPrefix(session) + " Exception on running xquery", e);
}
}
Aggregations