use of net.sf.saxon.type.ValidationException in project teiid by teiid.
the class XQueryEvaluator method evaluate.
public static Object evaluate(XMLType value, XMLCast expression, CommandContext context) throws ExpressionEvaluationException {
Configuration config = new Configuration();
Type t = value.getType();
try {
Item i = null;
switch(t) {
case CONTENT:
// content could map to an array value, but we aren't handling that case here yet - only in xmltable
case COMMENT:
case PI:
throw new FunctionExecutionException();
case TEXT:
i = new StringValue(value.getString());
break;
case UNKNOWN:
case DOCUMENT:
case ELEMENT:
StreamSource ss = value.getSource(StreamSource.class);
try {
i = config.buildDocument(ss);
} finally {
if (ss.getInputStream() != null) {
ss.getInputStream().close();
}
if (ss.getReader() != null) {
ss.getReader().close();
}
}
break;
default:
// $NON-NLS-1$
throw new AssertionError("Unknown xml value type " + t);
}
return XMLTableNode.getValue(expression.getType(), i, config, context);
} catch (IOException e) {
throw new FunctionExecutionException(e);
} catch (ValidationException e) {
throw new FunctionExecutionException(e);
} catch (TransformationException e) {
throw new FunctionExecutionException(e);
} catch (XPathException e) {
throw new FunctionExecutionException(e);
} catch (SQLException e) {
throw new FunctionExecutionException(e);
}
}
Aggregations