Package xbird.xquery.expr.var

Examples of xbird.xquery.expr.var.Variable


                String defaultNamespace = currentModule.getNamespace();
                if(defaultNamespace == null) {
                    defaultNamespace = "";
                }
                QualifiedName vn = QNameUtil.parse(currentToken.image, namespaceContext, defaultNamespace);
                Variable var = currentModule.getVariable(vn);
                if(var == null) {
                    error("err:XPST0008");
                }
                expr = new VarRef(var);
                break;
View Full Code Here


            return clause;
        }

        @Override
        public XQExpression visit(VarRef ref, XQueryContext ctxt) throws XQueryException {
            Variable var = ref.getValue();
            if(!var.isInsideRemoteExpr()) {
                if(var.isAnalyzed()) {
                    var.staticAnalysis(_statEnv);
                    ShippedVariable shippedVar = new ShippedVariable(var, _counter++);
                    _variablesHolder.add(shippedVar);
                    ref.setValue(shippedVar);
                }
            }
View Full Code Here

            this._variablesHolder = variablesHolder;
        }

        @Override
        public XQExpression visit(VarRef ref, XQueryContext ctxt) throws XQueryException {
            final Variable var = ref.getValue();
            if(var instanceof ShippedVariable) {
                ShippedVariable shippedVar = (ShippedVariable) var;
                int shippedId = shippedVar.getIdentifier();
                ShippedVariable original = _variablesHolder.get(shippedId);
                XQExpression originalExpr = original.getValue();
View Full Code Here

            this._variablesHolder = holder;
        }

        @Override
        public XQExpression visit(VarRef ref, XQueryContext ctxt) throws XQueryException {
            final Variable var = ref.getValue();
            if(var instanceof ShippedVariable) {
                _variablesHolder.add((ShippedVariable) var);
            }
            return ref;
        }
View Full Code Here

    }

    private static ShippedVariable wrapVariableToShip(QueryRequest request, VarRef ref, ValueSequence contextSeq, DynamicContext dynEnv)
            throws XQueryException {
        QualifiedName varname = ref.getName();
        Variable var = ref.getValue();
        Sequence result = var.getResult();
        if(result == null) {
            result = var.eval(contextSeq, dynEnv);
        }
        ReturnType rettype = request.getReturnType();
        final ShippedVariable shiped;
        if(ENV_NOWRAP_VARSHIP || !rettype.isRemoteSequnece()) {
            shiped = new ShippedVariable(varname, new MarshalledSequence(result, dynEnv));
View Full Code Here

                return null; //TODO REVIEWME
            }
            final XQExpression srcExpr = srcVar.getValue();
            if(srcExpr instanceof VarRef) {
                VarRef ref = (VarRef) srcExpr;
                Variable var = ref.getValue();
                assert (var != null);
                return rewrite(var, filterExpr, statEnv);
            } else if(srcExpr instanceof Variable) {
                Variable var = (Variable) srcExpr;
                return rewrite(var, filterExpr, statEnv);
            } else if(srcExpr instanceof BDQExpr) {
                final BDQExpr distExpr = (BDQExpr) srcExpr;
                final XQExpression bodyExpr = distExpr.getBodyExpression();
                if(bodyExpr instanceof PathVariable) {
View Full Code Here

                String inputVarName = xpath.evaluate("./*[local-name()='input-query']/@variable", testCase);
                if(inputVarName != null && inputVarName.length() > 0) {
                    String dateData = xpath.evaluate("./*[local-name()='input-query']/@date", testCase);
                    assert (dateData != null) : dateData;
                    QualifiedName varName = QNameTable.instantiate(XMLConstants.DEFAULT_NS_PREFIX, inputVarName);
                    Variable var = new Variable.GlobalVariable(varName, null);
                    var.setResult(new DateTimeValue(dateData, DateType.DATE));
                    xqmod.putVariable(varName, var);
                }
            }

            // -----------------------------------------------------------
View Full Code Here

                if(testFileRelDir != null) {
                    if(fromUri) {
                        File testDataFile = new File(xqtsDir, testFileRelDir);
                        String dest = testDataFile.toURI().toString();
                        QualifiedName varName = QNameTable.instantiate(XMLConstants.DEFAULT_NS_PREFIX, varNameStr);
                        Variable var = new Variable.GlobalVariable(varName, null);
                        var.setResult(new XString(dest));
                        xqmod.putVariable(varName, var);
                    } else {
                        DTMDocument testDataDoc = _docCache.get(testDataId);
                        if(testDataDoc == null) {
                            File testDataFile = new File(xqtsDir, testFileRelDir);
                            // load test data
                            DocumentTableModel dtm = new DocumentTableModel(false);
                            dtm.loadDocument(new FileInputStream(testDataFile));
                            testDataDoc = dtm.documentNode();
                            _docCache.put(testDataId, testDataDoc);
                        }
                        // import namespace decl
                        Map<String, String> nsmap = testDataDoc.documentTable().getDeclaredNamespaces();
                        NamespaceBinder nsResolver = statEnv.getStaticalyKnownNamespaces();
                        nsResolver.declarePrefixs(nsmap);
                        // reserve variable
                        QualifiedName varName = QNameTable.instantiate(XMLConstants.DEFAULT_NS_PREFIX, varNameStr);
                        Variable var = new Variable.GlobalVariable(varName, null);
                        var.setResult(testDataDoc);
                        xqmod.putVariable(varName, var);
                    }
                } else {
                    NodeList list = (NodeList) xpath.evaluate("/*[local-name()='test-suite']/*[local-name()='sources']/*[local-name()='collection'][@ID='"
                            + testDataId + "']/*[local-name()='input-document']/text()", catalog, XPathConstants.NODESET);
                    final int listlen = list.getLength();
                    if(listlen > 0) {
                        final NodeSequence<DTMDocument> ret = new NodeSequence<DTMDocument>(new DynamicContext(statEnv));
                        for(int i = 0; i < listlen; i++) {
                            String name = list.item(i).getTextContent();
                            DTMDocument testDataDoc = _docCache.get(name);
                            if(testDataDoc == null) {
                                File testDataFile = new File(xqtsDir, name + ".xml");
                                DocumentTableModel dtm = new DocumentTableModel(false);
                                dtm.loadDocument(new FileInputStream(testDataFile));
                                testDataDoc = dtm.documentNode();
                                _docCache.put(testDataId, testDataDoc);
                            }
                            // import namespace decl
                            Map<String, String> nsmap = testDataDoc.documentTable().getDeclaredNamespaces();
                            NamespaceBinder nsResolver = statEnv.getStaticalyKnownNamespaces();
                            nsResolver.declarePrefixs(nsmap);
                            ret.addItem(testDataDoc);
                        }
                        // reserve variable
                        QualifiedName varName = QNameTable.instantiate(XMLConstants.DEFAULT_NS_PREFIX, varNameStr);
                        Variable var = new Variable.GlobalVariable(varName, null);
                        var.setResult(ret);
                        xqmod.putVariable(varName, var);
                    }
                }
            }
        }
View Full Code Here

        Enumeration<String> paramNames = req.getParameterNames();
        while(paramNames.hasMoreElements()) {
            String name = paramNames.nextElement();
            String value = req.getParameter(name);
            QualifiedName qname = QNameUtil.parse(name, XQSP_NSURI);
            Variable var = new GlobalVariable(qname, null);
            var.setResult(XString.valueOf(value));
            try {
                loadedModule.putVariable(qname, var);
            } catch (XQueryException e) {
                reportError("Setting parameter failed: " + qname, e, out);
                return;
View Full Code Here

        }
        return variable;
    }

    public XQExpression visit(VarRef ref, XQueryContext ctxt) throws XQueryException {
        Variable var = ref.getValue();
        var.visit(this, ctxt);
        boolean isLoopInvariant = var.isLoopInvariant();
        if(isLoopInvariant) {
            return hookLoopInvariant(ref);
        }
        return ref;
    }
View Full Code Here

TOP

Related Classes of xbird.xquery.expr.var.Variable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.