Package org.apache.ode.bpel.compiler.v2.xpath20

Examples of org.apache.ode.bpel.compiler.v2.xpath20.OdeXPathFunctionLibrary


            Configuration configuration = ((SaxonXQConnection) xqconn).getConfiguration();
            configuration.setAllNodesUntyped(true);
            configuration.setHostLanguage(Configuration.XQUERY);

            XQStaticContext staticContext = xqconn.getStaticContext();
            JaxpFunctionResolver funcResolver = new JaxpFunctionResolver(
                    _compilerContext, out, source.getNamespaceContext(), _bpelNS);
            JaxpVariableResolver variableResolver = new JaxpVariableResolver(
                _compilerContext, out);

            XQueryDeclarations declarations = new XQueryDeclarations();           
View Full Code Here


     *
     * @return type
     */
    private static XPathFunction resolveFunction(XPathContext context,
        QName name) {
        JaxpFunctionResolver funcResolver = null;
        Item item = context.getCurrentIterator().current();

        if (item instanceof NodeWrapper) {
            Node node = (Node) ((NodeWrapper) item).getUnderlyingNode();

            if (node != null) {
                funcResolver = (JaxpFunctionResolver) node.getUserData(USER_DATA_KEY_FUNCTION_RESOLVER);
            }
        }

        return funcResolver.resolveFunction(name, 0);
    }
View Full Code Here

            configuration.setHostLanguage(Configuration.XQUERY);

            XQStaticContext staticContext = xqconn.getStaticContext();
            JaxpFunctionResolver funcResolver = new JaxpFunctionResolver(
                    _compilerContext, out, source.getNamespaceContext(), _bpelNS);
            JaxpVariableResolver variableResolver = new JaxpVariableResolver(
                _compilerContext, out);

            XQueryDeclarations declarations = new XQueryDeclarations();           
            NSContext nsContext = source.getNamespaceContext();
          Set<String> prefixes = nsContext.getPrefixes();
          if (!nsContext.getUriSet().contains(Namespaces.ODE_EXTENSION_NS)) {
            nsContext.register("ode", Namespaces.ODE_EXTENSION_NS);
          }
          for (String prefix : prefixes) {
            String uri = nsContext.getNamespaceURI(prefix);
            staticContext.declareNamespace(prefix, uri);
            if ("".equals(prefix)) {
              declarations.declareDefaultElementNamespace(uri);
            } else if ("bpws".equals(prefix)) {
                    declarations.declareNamespace("bpws", "java:" + Constants.XQUERY_FUNCTION_HANDLER_COMPILER);
            } else {
              declarations.declareNamespace(prefix, uri);
            }
          }
            declarations.declareVariable(
                getQName(nsContext, Namespaces.ODE_EXTENSION_NS, "pid"),
                getQName(nsContext, Namespaces.XML_SCHEMA, "integer"));
            Map<URI, Source> schemaDocuments = _compilerContext.getSchemaSources();
            for (URI schemaUri : schemaDocuments.keySet()) {
              Source schemaSource = schemaDocuments.get(schemaUri);
              // Don't add schema sources, since our Saxon library is not schema-aware.
              // configuration.addSchemaSource(schemaSource);
            }
            configuration.setSchemaValidationMode(Validation.SKIP);
            List<OScope.Variable> variables = _compilerContext.getAccessibleVariables();
            Map<QName, QName> variableTypes = new HashMap<QName, QName>();
            for (String variableName : getVariableNames(xqueryStr)) {
              OScope.Variable variable = getVariable(variables, variableName);
              if (variable == null) {
                continue;
              }
                OVarType type = variable.type;
                QName nameQName = getNameQName(variableName);
                QName typeQName = getTypeQName(variableName, type);
                variableTypes.put(nameQName, typeQName);
                String prefix = typeQName.getPrefix();
                if (prefix == null || "".equals(prefix.trim())) {
                  prefix = getPrefixForUri(nsContext, typeQName.getNamespaceURI());
                }
                // don't declare typed variables, as our engine is not schema-aware
                // declarations.declareVariable(variable.name, typeQName);
                declarations.declareVariable(variableName);
            }
           
            // Add implicit declarations as prolog to the user-defined XQuery
            out.xquery = declarations.toString() + xqueryStr;

            // Check the XQuery for compilation errors
            xqconn.setStaticContext(staticContext);           
            XQPreparedExpression exp = xqconn.prepareExpression(out.xquery);
           
            // Pre-evaluate variables and functions by executing query 
            node.setUserData(XQuery10BpelFunctions.USER_DATA_KEY_FUNCTION_RESOLVER,
                funcResolver, null);
            exp.bindItem(XQConstants.CONTEXT_ITEM,
                    xqconn.createItemFromNode(node, xqconn.createNodeType()));
            // Bind external variables to dummy runtime values
            for (QName variable : exp.getAllUnboundExternalVariables()) {
              QName typeQName = variableTypes.get(variable);
                Object value = variableResolver.resolveVariable(variable);
              if (typeQName != null) {
                if (value.getClass().getName().startsWith("java.lang")) {
                      exp.bindAtomicValue(variable, value.toString(),
                          xqconn.createAtomicType(XQItemType.XQBASETYPE_ANYATOMICTYPE));
                } else if (value instanceof Node) {
View Full Code Here

    public void setUp() throws Exception {
        _vars = new HashMap<String, Node>();
        _cc = new MockCompilerContext();
        _runtime = new XPath20ExpressionRuntime();      
        _runtime.initialize(new HashMap());
        _compiler = new XPath20ExpressionCompilerBPEL20();
        _compiler.setCompilerContext(_cc);
       
        _vardoc = DOMUtils.parse(getClass().getResourceAsStream("/xpath20/variables.xml"));
        NodeList variables = _vardoc.getDocumentElement().getChildNodes();
        for (int i = 0; i < variables.getLength(); ++i) {
View Full Code Here

    XPath20ExpressionCompilerBPEL20Draft compiler = new XPath20ExpressionCompilerBPEL20Draft();
    assertCompilationExceptionForEmptyXPath(compiler);
  }

  public void testEmptyXPath20StringBPEL20() throws Exception {
    XPath20ExpressionCompilerBPEL20 compiler = new XPath20ExpressionCompilerBPEL20();
    assertCompilationExceptionForEmptyXPath(compiler);
  }
View Full Code Here

    XPath10ExpressionCompilerBPEL20 compiler = new XPath10ExpressionCompilerBPEL20();
    assertCompilationExceptionForEmptyXPath(compiler);
  }

  public void testEmptyXPath20StringBPEL20Draft() throws Exception {
    XPath20ExpressionCompilerBPEL20Draft compiler = new XPath20ExpressionCompilerBPEL20Draft();
    assertCompilationExceptionForEmptyXPath(compiler);
  }
View Full Code Here

    /**
     * @see org.apache.ode.bpel.compiler.v1.api.ExpressionCompiler#compile(java.lang.Object)
     */
    private OExpression _compile(Expression xpath, boolean isJoinCondition)
            throws CompilationException {
        OXPath20ExpressionBPEL20 oexp = new OXPath20ExpressionBPEL20(_compilerContext.getOProcess(), _qnVarData,
                _qnVarProp, _qnLinkStatus, _qnXslTransform, isJoinCondition);
        oexp.namespaceCtx = xpath.getNamespaceContext();
        doJaxpCompile(oexp, xpath);
        return oexp;
    }
View Full Code Here

            String xquery = oxquery10.xquery.replaceFirst(
                    Constants.XQUERY_FUNCTION_HANDLER_COMPILER,
                    Constants.XQUERY_FUNCTION_HANDLER_RUNTIME);
            XQPreparedExpression exp = xqconn.prepareExpression(xquery);

            JaxpFunctionResolver funcResolver = new JaxpFunctionResolver(ctx,
                    oxquery10);
            JaxpVariableResolver variableResolver = new JaxpVariableResolver(ctx,
                    oxquery10, configuration);
            // Bind external variables to runtime values
            for (QName variable : exp.getAllUnboundExternalVariables()) {
View Full Code Here

     *
     * @return type
     */
    private static XPathFunction resolveFunction(XPathContext context,
        QName name) {
        JaxpFunctionResolver funcResolver = null;
        Item item = context.getCurrentIterator().current();

        if (item instanceof NodeWrapper) {
            Node node = (Node) ((NodeWrapper) item).getUnderlyingNode();

            if (node != null) {
                funcResolver = (JaxpFunctionResolver) node.getUserData(USER_DATA_KEY_FUNCTION_RESOLVER);
            }
        }

        return funcResolver.resolveFunction(name, 0);
    }
View Full Code Here

                    Constants.XQUERY_FUNCTION_HANDLER_RUNTIME);
            XQPreparedExpression exp = xqconn.prepareExpression(xquery);

            JaxpFunctionResolver funcResolver = new JaxpFunctionResolver(ctx,
                    oxquery10);
            JaxpVariableResolver variableResolver = new JaxpVariableResolver(ctx,
                    oxquery10, configuration);
            // Bind external variables to runtime values
            for (QName variable : exp.getAllUnboundExternalVariables()) {
              // Evaluate referenced variable
                Object value = variableResolver.resolveVariable(variable);
               
                // Figure out type of variable
                XQSequenceType xqType = getItemType(xqconn, value);
               
                // Saxon doesn't like binding sequences to variables
View Full Code Here

TOP

Related Classes of org.apache.ode.bpel.compiler.v2.xpath20.OdeXPathFunctionLibrary

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.