Search in sources :

Example 1 with ValidationException

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);
    }
}
Also used : Item(net.sf.saxon.om.Item) BinaryType(org.teiid.core.types.BinaryType) XMLType(org.teiid.core.types.XMLType) DocType(nu.xom.DocType) Type(org.teiid.core.types.XMLType.Type) TransformationException(org.teiid.core.types.TransformationException) FunctionExecutionException(org.teiid.api.exception.query.FunctionExecutionException) ValidationException(net.sf.saxon.type.ValidationException) Configuration(net.sf.saxon.Configuration) XPathException(net.sf.saxon.trans.XPathException) SQLException(java.sql.SQLException) StreamSource(javax.xml.transform.stream.StreamSource) IOException(java.io.IOException) StringValue(net.sf.saxon.value.StringValue)

Aggregations

IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 StreamSource (javax.xml.transform.stream.StreamSource)1 Configuration (net.sf.saxon.Configuration)1 Item (net.sf.saxon.om.Item)1 XPathException (net.sf.saxon.trans.XPathException)1 ValidationException (net.sf.saxon.type.ValidationException)1 StringValue (net.sf.saxon.value.StringValue)1 DocType (nu.xom.DocType)1 FunctionExecutionException (org.teiid.api.exception.query.FunctionExecutionException)1 BinaryType (org.teiid.core.types.BinaryType)1 TransformationException (org.teiid.core.types.TransformationException)1 XMLType (org.teiid.core.types.XMLType)1 Type (org.teiid.core.types.XMLType.Type)1