Search in sources :

Example 6 with XMLColumn

use of org.teiid.query.sql.lang.XMLTable.XMLColumn in project teiid by teiid.

the class SaxonXQueryExpression method processColumns.

private void processColumns(List<XMLTable.XMLColumn> columns, IndependentContext ic) throws QueryResolverException {
    if (columns == null) {
        return;
    }
    XPathEvaluator eval = new XPathEvaluator(config);
    eval.setStaticContext(ic);
    for (XMLColumn xmlColumn : columns) {
        if (xmlColumn.isOrdinal()) {
            continue;
        }
        String path = xmlColumn.getPath();
        if (path == null) {
            path = xmlColumn.getName();
        }
        path = path.trim();
        if (path.startsWith("/")) {
            // $NON-NLS-1$
            if (path.startsWith("//")) {
                // $NON-NLS-1$
                path = '.' + path;
            } else {
                path = path.substring(1);
            }
        }
        XPathExpression exp;
        try {
            exp = eval.createExpression(path);
        } catch (XPathException e) {
            throw new QueryResolverException(QueryPlugin.Event.TEIID30155, e, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID30155, xmlColumn.getName(), xmlColumn.getPath()));
        }
        xmlColumn.setPathExpression(exp);
    }
}
Also used : XMLColumn(org.teiid.query.sql.lang.XMLTable.XMLColumn) XPathExpression(net.sf.saxon.sxpath.XPathExpression) XPathException(net.sf.saxon.trans.XPathException) XPathEvaluator(net.sf.saxon.sxpath.XPathEvaluator) QueryResolverException(org.teiid.api.exception.query.QueryResolverException)

Aggregations

XMLColumn (org.teiid.query.sql.lang.XMLTable.XMLColumn)6 XPathExpression (net.sf.saxon.sxpath.XPathExpression)3 XPathException (net.sf.saxon.trans.XPathException)2 TeiidProcessingException (org.teiid.core.TeiidProcessingException)2 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ContextItemExpression (net.sf.saxon.expr.ContextItemExpression)1 Expression (net.sf.saxon.expr.Expression)1 RootExpression (net.sf.saxon.expr.RootExpression)1 PathMap (net.sf.saxon.expr.parser.PathMap)1 PathMapArc (net.sf.saxon.expr.parser.PathMap.PathMapArc)1 PathMapNode (net.sf.saxon.expr.parser.PathMap.PathMapNode)1 PathMapRoot (net.sf.saxon.expr.parser.PathMap.PathMapRoot)1 Item (net.sf.saxon.om.Item)1 SequenceIterator (net.sf.saxon.om.SequenceIterator)1 XQueryExpression (net.sf.saxon.query.XQueryExpression)1 XPathDynamicContext (net.sf.saxon.sxpath.XPathDynamicContext)1 XPathEvaluator (net.sf.saxon.sxpath.XPathEvaluator)1