You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by ka...@apache.org on 2008/10/29 01:11:16 UTC

svn commit: r708740 [2/2] - in /ode/branches/APACHE_ODE_1.X: ./ bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/ bpel-compiler/src/main/java/org/apache/ode/bpel/compiler/api/ bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compil...

Added: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xquery10/runtime/XQuery10ExpressionRuntime.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xquery10/runtime/XQuery10ExpressionRuntime.java?rev=708740&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xquery10/runtime/XQuery10ExpressionRuntime.java (added)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xquery10/runtime/XQuery10ExpressionRuntime.java Tue Oct 28 17:11:15 2008
@@ -0,0 +1,564 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.ode.bpel.elang.xquery10.runtime;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xquery.XQConnection;
+import javax.xml.xquery.XQConstants;
+import javax.xml.xquery.XQDataSource;
+import javax.xml.xquery.XQException;
+import javax.xml.xquery.XQItem;
+import javax.xml.xquery.XQItemType;
+import javax.xml.xquery.XQPreparedExpression;
+import javax.xml.xquery.XQResultSequence;
+import javax.xml.xquery.XQSequence;
+import javax.xml.xquery.XQStaticContext;
+
+import net.sf.saxon.Configuration;
+import net.sf.saxon.om.Validation;
+import net.sf.saxon.trans.DynamicError;
+import net.sf.saxon.value.DurationValue;
+import net.sf.saxon.xqj.SaxonXQConnection;
+import net.sf.saxon.xqj.SaxonXQDataSource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.ode.bpel.common.FaultException;
+import org.apache.ode.bpel.elang.xpath20.compiler.Constants;
+import org.apache.ode.bpel.elang.xpath20.compiler.WrappedResolverException;
+import org.apache.ode.bpel.elang.xpath20.runtime.JaxpFunctionResolver;
+import org.apache.ode.bpel.elang.xpath20.runtime.JaxpVariableResolver;
+import org.apache.ode.bpel.elang.xquery10.compiler.XQuery10BpelFunctions;
+import org.apache.ode.bpel.elang.xquery10.o.OXQuery10ExpressionBPEL20;
+import org.apache.ode.bpel.explang.ConfigurationException;
+import org.apache.ode.bpel.explang.EvaluationContext;
+import org.apache.ode.bpel.explang.EvaluationException;
+import org.apache.ode.bpel.explang.ExpressionLanguageRuntime;
+import org.apache.ode.bpel.o.OExpression;
+import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.ISO8601DateParser;
+import org.apache.ode.utils.NSContext;
+import org.apache.ode.utils.xsd.Duration;
+import org.apache.ode.utils.xsl.XslTransformHandler;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+
+/**
+ * XQuery 1.0 Expression Language run-time subsytem. Saxon implementation.
+ */
+@SuppressWarnings("deprecation")
+public class XQuery10ExpressionRuntime implements ExpressionLanguageRuntime {
+    static final short NODE_TYPE = 1;
+    static final short NODESET_TYPE = 2;
+    static final short STRING_TYPE = 3;
+    static final short BOOLEAN_TYPE = 4;
+    static final short NUMBER_TYPE = 5;
+
+    /** Class-level logger. */
+    private static final Log __log = LogFactory.getLog(XQuery10ExpressionRuntime.class);
+
+    /**
+     * Creates a new XQuery10ExpressionRuntime object.
+     */
+    public XQuery10ExpressionRuntime() {
+    }
+
+    /**
+     * Initialize XSL Transformer
+     *
+     * @param properties properties 
+     *
+     * @throws ConfigurationException ConfigurationException 
+     */
+    public void initialize(Map properties) throws ConfigurationException {
+        TransformerFactory trsf = new net.sf.saxon.TransformerFactoryImpl();
+        XslTransformHandler.getInstance().setTransformerFactory(trsf);
+    }
+
+    /**
+     * 
+     * @see org.apache.ode.bpel.explang.ExpressionLanguageRuntime#evaluateAsString(org.apache.ode.bpel.o.OExpression,
+     *      org.apache.ode.bpel.explang.EvaluationContext)
+     */
+    public String evaluateAsString(OExpression cexp, EvaluationContext ctx)
+        throws FaultException, EvaluationException {
+        return (String) evaluate(cexp, ctx, XPathConstants.STRING);
+    }
+
+    /**
+     * 
+     * @see org.apache.ode.bpel.explang.ExpressionLanguageRuntime#evaluateAsBoolean(org.apache.ode.bpel.o.OExpression,
+     *      org.apache.ode.bpel.explang.EvaluationContext)
+     */
+    public boolean evaluateAsBoolean(OExpression cexp, EvaluationContext ctx)
+        throws FaultException, EvaluationException {
+        return (Boolean) evaluate(cexp, ctx, XPathConstants.BOOLEAN);
+    }
+
+    /**
+     * Evaluate expression and return a number
+     *
+     * @param cexp cexp 
+     * @param ctx ctx 
+     *
+     * @return type
+     *
+     * @throws FaultException FaultException 
+     * @throws EvaluationException EvaluationException 
+     */
+    public Number evaluateAsNumber(OExpression cexp, EvaluationContext ctx)
+        throws FaultException, EvaluationException {
+        return (Number) evaluate(cexp, ctx, XPathConstants.NUMBER);
+    }
+
+    /**
+     * 
+     * @see org.apache.ode.bpel.explang.ExpressionLanguageRuntime#evaluate(org.apache.ode.bpel.o.OExpression,
+     *      org.apache.ode.bpel.explang.EvaluationContext)
+     */
+    public List evaluate(OExpression cexp, EvaluationContext ctx)
+        throws FaultException, EvaluationException {
+        List result;
+        Object someRes = evaluate(cexp, ctx, XPathConstants.NODESET);
+
+        if (someRes instanceof List) {
+            result = (List) someRes;
+            __log.debug("Returned list of size " + result.size());
+
+            if ((result.size() == 1) && !(result.get(0) instanceof Node)) {
+                // Dealing with a Java class
+                Object simpleType = result.get(0);
+
+                // Dates get a separate treatment as we don't want to call toString on them
+                String textVal;
+
+                if (simpleType instanceof Date) {
+                    textVal = ISO8601DateParser.format((Date) simpleType);
+                } else if (simpleType instanceof DurationValue) {
+                    textVal = ((DurationValue) simpleType).getStringValue();
+                } else {
+                    textVal = simpleType.toString();
+                }
+
+                // Wrapping in a document
+                Document d = DOMUtils.newDocument();
+
+                // Giving our node a parent just in case it's an LValue expression
+                Element wrapper = d.createElement("wrapper");
+                Text text = d.createTextNode(textVal);
+                wrapper.appendChild(text);
+                d.appendChild(wrapper);
+                result = Collections.singletonList(text);
+            }
+        } else if (someRes instanceof NodeList) {
+            NodeList retVal = (NodeList) someRes;
+            __log.debug("Returned node list of size " + retVal.getLength());
+            result = new ArrayList(retVal.getLength());
+
+            for (int m = 0; m < retVal.getLength(); ++m) {
+                Node val = retVal.item(m);
+
+                if (val.getNodeType() == Node.DOCUMENT_NODE) {
+                    val = ((Document) val).getDocumentElement();
+                }
+
+                result.add(val);
+            }
+        } else {
+            result = null;
+        }
+
+        return result;
+    }
+
+    /**
+     * Evaluate expression and return a node
+     *
+     * @param cexp cexp 
+     * @param ctx ctx 
+     *
+     * @return type
+     *
+     * @throws FaultException FaultException 
+     * @throws EvaluationException EvaluationException 
+     */
+    public Node evaluateNode(OExpression cexp, EvaluationContext ctx)
+        throws FaultException, EvaluationException {
+        List retVal = evaluate(cexp, ctx);
+
+        if (retVal.size() == 0) {
+            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure,
+                "No results for expression: " + cexp);
+        }
+
+        if (retVal.size() > 1) {
+            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure,
+                "Multiple results for expression: " + cexp);
+        }
+
+        return (Node) retVal.get(0);
+    }
+
+    /**
+     * Evaluate expression and return a date
+     *
+     * @param cexp cexp 
+     * @param context context 
+     *
+     * @return type
+     *
+     * @throws FaultException FaultException 
+     * @throws EvaluationException EvaluationException 
+     */
+    public Calendar evaluateAsDate(OExpression cexp, EvaluationContext context)
+        throws FaultException, EvaluationException {
+        List literal = DOMUtils.toList(evaluate(cexp, context,
+                    XPathConstants.NODESET));
+
+        if (literal.size() == 0) {
+            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure,
+                "No results for expression: " + cexp);
+        }
+
+        if (literal.size() > 1) {
+            throw new FaultException(cexp.getOwner().constants.qnSelectionFailure,
+                "Multiple results for expression: " + cexp);
+        }
+
+        Object date = literal.get(0);
+
+        if (date instanceof Calendar) {
+            return (Calendar) date;
+        }
+
+        if (date instanceof Date) {
+            Calendar cal = Calendar.getInstance();
+            cal.setTime((Date) date);
+
+            return cal;
+        }
+
+        if (date instanceof Element) {
+            date = ((Element) date).getTextContent();
+        }
+
+        try {
+            return ISO8601DateParser.parseCal(date.toString());
+        } catch (Exception ex) {
+            String errmsg = "Invalid date: " + literal;
+            __log.error(errmsg, ex);
+            throw new FaultException(cexp.getOwner().constants.qnInvalidExpressionValue,
+                errmsg);
+        }
+    }
+
+    /**
+     * Evaluate expression and return duration
+     *
+     * @param cexp cexp 
+     * @param context context 
+     *
+     * @return type
+     *
+     * @throws FaultException FaultException 
+     * @throws EvaluationException EvaluationException 
+     */
+    public Duration evaluateAsDuration(OExpression cexp,
+        EvaluationContext context) throws FaultException, EvaluationException {
+        String literal = this.evaluateAsString(cexp, context);
+
+        try {
+            return new Duration(literal);
+        } catch (Exception ex) {
+            String errmsg = "Invalid duration: " + literal;
+            __log.error(errmsg, ex);
+            throw new FaultException(cexp.getOwner().constants.qnInvalidExpressionValue,
+                errmsg);
+        }
+    }
+
+    /**
+     * Evaluate expression and return opaque type
+     *
+     * @param cexp cexp 
+     * @param ctx ctx 
+     * @param type type 
+     *
+     * @return type
+     *
+     * @throws FaultException FaultException 
+     * @throws EvaluationException EvaluationException 
+     */
+    private Object evaluate(OExpression cexp, EvaluationContext ctx, QName type)
+        throws FaultException, EvaluationException {
+        try {
+            OXQuery10ExpressionBPEL20 oxquery10 = ((OXQuery10ExpressionBPEL20) cexp);
+
+            XQDataSource xqds = new SaxonXQDataSource();
+            XQConnection xqconn = xqds.getConnection();
+
+            Configuration configuration = ((SaxonXQConnection) xqconn).getConfiguration();
+            configuration.setAllNodesUntyped(true);
+            configuration.setHostLanguage(Configuration.XQUERY);
+
+            XQStaticContext staticEnv = xqconn.getStaticContext();
+
+            NSContext nsContext = oxquery10.namespaceCtx;
+            Set<String> prefixes = nsContext.getPrefixes();
+            for (String prefix : prefixes) {
+                String uri = nsContext.getNamespaceURI(prefix);
+                staticEnv.declareNamespace(prefix, uri);
+            }
+
+            configuration.setSchemaValidationMode(Validation.SKIP);
+            xqconn.setStaticContext(staticEnv);
+
+            // Prepare expression, for starters
+            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()) {
+            	// Evaluate referenced variable
+                Object value = variableResolver.resolveVariable(variable);
+                
+                // Figure out type of variable
+                XQItemType xqType = getItemType(xqconn, value);
+                
+                // Saxon doesn't like binding sequences to variables
+                if (value instanceof NodeList) {
+                    // So extract the first item from the node list
+                	NodeList nodeList = (NodeList) value;
+                	ArrayList nodeArray = new ArrayList();
+                	for (int i = 0; i < nodeList.getLength(); i++) {
+                		nodeArray.add(nodeList.item(i));
+                	}
+                	value = xqconn.createSequence(nodeArray.iterator());
+                }
+                
+                
+                // Bind value with external variable
+                if (value != null && xqType != null) {
+                	if (value instanceof XQSequence) {
+                		exp.bindSequence(variable, (XQSequence) value);
+                	} else {
+		                exp.bindObject(variable, value, xqType);
+                	}
+                }
+            }
+
+            // Set context node
+            Node contextNode = (ctx.getRootNode() == null)
+	            ? DOMUtils.newDocument() : ctx.getRootNode();
+            contextNode.setUserData(XQuery10BpelFunctions.USER_DATA_KEY_FUNCTION_RESOLVER,
+                funcResolver, null);
+            exp.bindItem(XQConstants.CONTEXT_ITEM,
+                xqconn.createItemFromNode(contextNode, xqconn.createNodeType()));
+
+            // Execute query
+            XQResultSequence result = exp.executeQuery();
+
+            // Cast Saxon result to Java result
+            Object evalResult = getResultValue(type, result);
+
+            if ((evalResult != null) && __log.isDebugEnabled()) {
+                __log.debug("Expression " + cexp.toString() +
+                    " generated result " + evalResult + " - type=" +
+                    evalResult.getClass().getName());
+
+                if (ctx.getRootNode() != null) {
+                    __log.debug("Was using context node " +
+                        DOMUtils.domToString(ctx.getRootNode()));
+                }
+            }
+
+            return evalResult;
+        } catch (XQException xqe) {
+            // Extracting the real cause from all this wrapping isn't a simple task
+            Throwable cause = (xqe.getCause() != null) ? xqe.getCause() : xqe;
+
+            if (cause instanceof DynamicError) {
+                Throwable th = ((DynamicError) cause).getException();
+
+                if (th != null) {
+                    cause = th;
+
+                    if (cause.getCause() != null) {
+                        cause = cause.getCause();
+                    }
+                }
+            }
+
+            throw new EvaluationException(
+                "Error while executing an XQuery expression: " + cause.toString(), cause);
+        } catch (WrappedResolverException wre) {
+            __log.debug("Could not evaluate expression because of ", wre);
+            throw (FaultException) wre.getCause();
+        }
+    }
+
+    /**
+     * Return opaque object embedded in XQuery Item
+     *
+     * @param item item 
+     *
+     * @return type
+     *
+     * @throws XQException XQException 
+     */
+    private Object getItemValue(XQItem item) throws XQException {
+        XQItemType itemType = item.getItemType();
+        Object itemValue = null;
+
+        switch (itemType.getBaseType()) {
+        case XQItemType.XQBASETYPE_BOOLEAN:
+            itemValue = item.getBoolean();
+
+            break;
+
+        case XQItemType.XQBASETYPE_DECIMAL:
+            itemValue = item.getDouble();
+
+            break;
+
+        case XQItemType.XQBASETYPE_BYTE:
+            itemValue = item.getByte();
+
+            break;
+
+        case XQItemType.XQBASETYPE_FLOAT:
+            itemValue = item.getFloat();
+
+            break;
+
+        case XQItemType.XQBASETYPE_INT:
+        case XQItemType.XQBASETYPE_INTEGER:
+            itemValue = item.getInt();
+
+            break;
+
+        case XQItemType.XQBASETYPE_LONG:
+            itemValue = item.getLong();
+
+            break;
+
+        case XQItemType.XQBASETYPE_ANYTYPE:
+            itemValue = item.getNode();
+
+            break;
+
+        case XQItemType.XQBASETYPE_ANYURI:
+            itemValue = item.getNodeUri();
+
+            break;
+
+        case XQItemType.XQBASETYPE_SHORT:
+            itemValue = item.getShort();
+
+            break;
+
+        case XQItemType.XQBASETYPE_STRING:
+        case XQItemType.XQBASETYPE_ANYATOMICTYPE:
+            itemValue = item.getAtomicValue();
+
+            break;
+        }
+
+        return itemValue;
+    }
+    
+    /**
+     * Return XQuery type corresponding to given value
+     *
+     * @param xqconn XQuery connection 
+     * @param value value 
+     *
+     * @return type
+     *
+     * @throws XQException XQException 
+     */
+    private XQItemType getItemType(XQConnection xqconn, Object value) throws XQException {
+        XQItemType xqType = null;
+        if (value instanceof Long) {
+            xqType = xqconn.createAtomicType(XQItemType.XQBASETYPE_LONG);
+        } else if (value instanceof String) {
+            xqType = xqconn.createAtomicType(XQItemType.XQBASETYPE_STRING);
+        } else if (value instanceof NodeList) {
+            NodeList nodeList = (NodeList) value;
+
+            if (nodeList.getLength() == 1) {
+                xqType = xqconn.createNodeType();
+                value = nodeList.item(0);
+            } else {
+                value = null;
+            }
+        }
+        return xqType;
+    }
+    
+    /**
+     * Cast XQuery sequence into an opaque list 
+     *
+     * @param type type 
+     * @param result result 
+     *
+     * @return value
+     *
+     * @throws XQException XQException 
+     */
+    private Object getResultValue(QName type, XQResultSequence result) throws XQException {
+    	Object resultValue = null;
+        if (XPathConstants.NODESET.equals(type)) {
+            List list = new ArrayList();
+
+            while (result.next()) {
+                Object itemValue = getItemValue(result.getItem());
+
+                if (itemValue != null) {
+                    list.add(itemValue);
+                }
+            }
+
+            resultValue = list;
+        } else {
+            resultValue = getItemValue(result.getItem());
+        }
+    	return resultValue;
+    }
+}

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java?rev=708740&r1=708739&r2=708740&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/MockCompilerContext.java Tue Oct 28 17:11:15 2008
@@ -18,6 +18,7 @@
  */
 package org.apache.ode.bpel.elang.xpath20.runtime;
 
+import java.net.URI;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -25,6 +26,7 @@
 
 import javax.wsdl.Operation;
 import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
 
 import org.apache.ode.bpel.compiler.api.CompilationException;
 import org.apache.ode.bpel.compiler.api.CompilerContext;
@@ -207,4 +209,9 @@
     public Part resolveHeaderPart(Variable variable, String partname) throws CompilationException {
         return null;
     }
+    
+    public Map<URI, Source> getSchemaSources() {
+    	// TODO Auto-generated method stub
+    	return null;
+    }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java?rev=708740&r1=708739&r2=708740&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/java/org/apache/ode/test/DataHandling20Test.java Tue Oct 28 17:11:15 2008
@@ -18,10 +18,11 @@
  */
 package org.apache.ode.test;
 
+import org.junit.Ignore;
 import org.junit.Test;
 
 public class DataHandling20Test extends BPELTestAbstract {
-    @Test public void testComposeUrl() throws Throwable {
+	@Test public void testComposeUrl() throws Throwable {
         go("/bpel/2.0/TestComposeUrl");
     }
     @Test public void testCombineUrl() throws Throwable {
@@ -54,7 +55,7 @@
     @Test public void testSimpleVariableType() throws Throwable {
         go("/bpel/2.0/TestSimpleVariableType");
     }
-    @Test public void testXslTransform() throws Throwable {
+   @Test public void testXslTransform() throws Throwable {
         go("/bpel/2.0/TestXslTransform");
     }
     @Test public void testSplit() throws Throwable {
@@ -75,4 +76,7 @@
     @Test public void testAssignMissingData() throws Throwable {
       go("/bpel/2.0/TestAssignMissingData");
     }
+    @Test public void testXQueryExpression() throws Throwable {
+        go("/bpel/2.0/TestXQueryExpression");
+    }
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity1/test.properties
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity1/test.properties?rev=708740&r1=708739&r2=708740&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity1/test.properties (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestAssignActivity1/test.properties Tue Oct 28 17:11:15 2008
@@ -19,4 +19,4 @@
 service=TestAssignService
 operation=testAssign
 request1=<message><TestPart>Hello</TestPart></message>
-response1=.*Hello World7true3.*
\ No newline at end of file
+response1=.*Hello World7.*true3.*
\ No newline at end of file

Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestAssignDate/NewDiagram-Pool.bpel
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestAssignDate/NewDiagram-Pool.bpel?rev=708740&r1=708739&r2=708740&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestAssignDate/NewDiagram-Pool.bpel (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestAssignDate/NewDiagram-Pool.bpel Tue Oct 28 17:11:15 2008
@@ -29,11 +29,11 @@
     </bpel:assign>
     <bpel:assign bpmn:label="Task" bpmn:id="_e0Xz0Nw9Edye_tsy8V393Q">
       <bpel:copy>
-        <bpel:from xmlns:xdt="http://www.w3.org/2003/11/xpath-datatypes">xs:dateTime($variable) + xdt:dayTimeDuration ("P1D")</bpel:from>
+        <bpel:from>xs:dateTime($variable) + xs:dayTimeDuration ("P1D")</bpel:from>
         <bpel:to>$variable</bpel:to>
       </bpel:copy>
         <bpel:copy>
-          <bpel:from xmlns:xdt="http://www.w3.org/2003/11/xpath-datatypes">$variable + xdt:dayTimeDuration ("P1D")</bpel:from>
+          <bpel:from>$variable + xs:dayTimeDuration ("P1D")</bpel:from>
           <bpel:to>$variable</bpel:to>
         </bpel:copy>
     </bpel:assign>

Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestDuration/BugCastDayTimeDurationToDuration-Pool.bpel
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestDuration/BugCastDayTimeDurationToDuration-Pool.bpel?rev=708740&r1=708739&r2=708740&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestDuration/BugCastDayTimeDurationToDuration-Pool.bpel (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestDuration/BugCastDayTimeDurationToDuration-Pool.bpel Tue Oct 28 17:11:15 2008
@@ -21,7 +21,8 @@
     </bpel:assign>
     <bpel:assign bpmn:label="Task" bpmn:id="_6_3QwOu1EdyUWbG-WWtMzg">
       <bpel:copy>
-        <bpel:from xmlns:xdt="http://www.w3.org/2003/11/xpath-datatypes">xdt:dayTimeDuration ("PT2S")</bpel:from>
+        <!--<bpel:from xmlns:xdt="http://www.w3.org/2003/11/xpath-datatypes">xdt:dayTimeDuration ("PT2S")</bpel:from>-->
+        <bpel:from>xs:dayTimeDuration ("PT2S")</bpel:from>
         <bpel:to>$thisTaskRequestMsg.body/tns:duration</bpel:to>
       </bpel:copy>
     </bpel:assign>

Added: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel?rev=708740&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel (added)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.bpel Tue Oct 28 17:11:15 2008
@@ -0,0 +1,107 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<process name="HelloXQueryWorld" 
+    targetNamespace="http://ode/bpel/unit-test"
+    xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+    xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+    xmlns:tns="http://ode/bpel/unit-test"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:types="http://ode/bpel/types"
+    xmlns:test="http://ode/bpel/unit-test.wsdl"
+	xmlns:ode="http://www.apache.org/ode/type/extension"
+    queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xquery1.0"
+    expressionLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xquery1.0">
+
+    <import location="HelloXQueryWorld.wsdl"
+        namespace="http://ode/bpel/unit-test.wsdl"
+        importType="http://schemas.xmlsoap.org/wsdl/"/>
+    
+    <partnerLinks>
+        <partnerLink name="HelloXQueryPartnerLink" 
+            partnerLinkType="test:HelloXQueryPartnerLinkType" 
+            myRole="me" />
+    </partnerLinks>
+        
+    <variables>
+        <variable name="myVar" messageType="test:HelloXQueryMessage"/>
+        <variable name="tempVar" element="test:content"/>
+        <variable name="otherVar" type="xsd:string"/>
+    </variables>
+            
+    <sequence>   
+        <receive 
+            name="start"
+            partnerLink="HelloXQueryPartnerLink"
+            portType="test:HelloXQueryPortType"
+            operation="HelloXQuery"
+            variable="myVar"
+            createInstance="yes"/>
+        <assign name="assign1">
+            <copy>
+                <from variable="myVar" part="TestPart"/>
+                <to variable="otherVar"/>
+            </copy>
+            <copy>
+                <from><![CDATA[<test:content>Hello</test:content>]]></from>
+                <to variable="tempVar"/>
+            </copy>
+            <copy>
+                <from>
+					typeswitch ($myVar.TestPart) 
+				      case $a as xs:string return "test"
+					  default return "default"
+				</from>
+                <to variable="otherVar"/>
+            </copy>
+            <copy>
+                <from><![CDATA[
+					typeswitch ($myVar.TestPart) 
+				      case $a as text() return <test:content/>
+					  default return <test:content/>
+					  ]]>
+				</from>
+                <to variable="otherVar"/>
+            </copy>
+			<!-- this copy will fail since saxon is not schema-aware 
+            <copy>
+                <from>
+					typeswitch ($myVar.TestPart) 
+				      case $a as element(*, test:content) return "test"
+					  default return "default"
+				</from>
+                <to variable="otherVar"/>
+            </copy>
+			-->
+            <copy>
+                <from>
+					for $loopOnce in (1) 
+					return 
+						concat(bpws:getVariableProperty("myVar", "test:content"), "XQuery World")
+				</from>
+                <to variable="myVar" part="TestPart"/>
+            </copy>
+        </assign>
+        <reply name="end"  
+                partnerLink="HelloXQueryPartnerLink"
+                portType="test:HelloXQueryPortType" 
+                operation="HelloXQuery"
+                variable="myVar"/>
+    </sequence>
+    
+</process>

Added: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.wsdl?rev=708740&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.wsdl (added)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/HelloXQueryWorld.wsdl Tue Oct 28 17:11:15 2008
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<wsdl:definitions 
+    targetNamespace="http://ode/bpel/unit-test.wsdl"
+    xmlns="http://schemas.xmlsoap.org/wsdl/"
+    xmlns:tns="http://ode/bpel/unit-test.wsdl"
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:vprop="http://docs.oasis-open.org/wsbpel/2.0/varprop"
+    xmlns:types="http://ode/bpel/types"
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+    xmlns:bpws="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
+    xmlns:plnk="http://docs.oasis-open.org/wsbpel/2.0/plnktype">
+
+    <wsdl:types>
+        <xsd:schema targetNamespace="http://ode/bpel/types">
+            <xsd:complexType name="ContentCT">
+                <xsd:sequence>
+                    <xsd:element name="content" type="xsd:string"/>
+                </xsd:sequence>
+            </xsd:complexType>
+        </xsd:schema>
+    </wsdl:types>
+
+    <wsdl:message name="HelloXQueryMessage">
+        <wsdl:part name="TestPart" type="types:ContentCT"/>
+    </wsdl:message>
+
+    <wsdl:portType name="HelloXQueryPortType">
+        <wsdl:operation name="HelloXQuery">
+            <wsdl:input message="tns:HelloXQueryMessage" name="TestIn"/>
+            <wsdl:output message="tns:HelloXQueryMessage" name="TestOut"/>
+        </wsdl:operation>    
+    </wsdl:portType>
+
+    <wsdl:binding name="HelloXQuerySoapBinding" type="tns:HelloXQueryPortType">
+        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="HelloXQuery">
+            <soap:operation soapAction="" style="rpc"/>
+            <wsdl:input>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl"
+                    use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body
+                    namespace="http://ode/bpel/unit-test.wsdl"
+                    use="literal"/>
+            </wsdl:output>
+        </wsdl:operation>
+    </wsdl:binding>
+    <wsdl:service name="HelloXQueryService">
+                <wsdl:port name="HelloXQueryPort" binding="tns:HelloXQuerySoapBinding">
+                <soap:address location="http://localhost:8080/ode/processes/HelloXQueryWorld"/>
+                </wsdl:port>
+    </wsdl:service>
+    
+    <plnk:partnerLinkType name="HelloXQueryPartnerLinkType">
+        <plnk:role name="me" portType="tns:HelloXQueryPortType"/>
+        <plnk:role name="you" portType="tns:HelloXQueryPortType"/>
+    </plnk:partnerLinkType>
+	
+  <vprop:property name="content" type="xsd:string"/>
+  <vprop:propertyAlias propertyName="tns:content" messageType="tns:HelloXQueryMessage" part="TestPart">
+
+    <vprop:query queryLanguage="urn:oasis:names:tc:wsbpel:2.0:sublang:xpath2.0">
+      content
+    </vprop:query>  
+   
+  </vprop:propertyAlias>
+	
+</wsdl:definitions>
+

Added: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/deploy.xml
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/deploy.xml?rev=708740&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/deploy.xml (added)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/deploy.xml Tue Oct 28 17:11:15 2008
@@ -0,0 +1,29 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements.  See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership.  The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License.  You may obtain a copy of the License at
+  ~
+  ~    http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied.  See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+<deploy xmlns="http://www.apache.org/ode/schemas/dd/2007/03"
+        xmlns:pns="http://ode/bpel/unit-test"
+        xmlns:wns="http://ode/bpel/unit-test.wsdl">
+
+    <process name="pns:HelloXQueryWorld">
+        <active>true</active>
+        <provide partnerLink="HelloXQueryPartnerLink">
+            <service name="wns:HelloXQueryService" port="HelloXQueryPort"/>
+        </provide>
+    </process>
+</deploy>

Added: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/test.properties
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/test.properties?rev=708740&view=auto
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/test.properties (added)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestXQueryExpression/test.properties Tue Oct 28 17:11:15 2008
@@ -0,0 +1,23 @@
+#
+#    Licensed to the Apache Software Foundation (ASF) under one or more
+#    contributor license agreements.  See the NOTICE file distributed with
+#    this work for additional information regarding copyright ownership.
+#    The ASF licenses this file to You under the Apache License, Version 2.0
+#    (the "License"); you may not use this file except in compliance with
+#    the License.  You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#    Unless required by applicable law or agreed to in writing, software
+#    distributed under the License is distributed on an "AS IS" BASIS,
+#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#    See the License for the specific language governing permissions and
+#    limitations under the License.
+#
+
+namespace=http://ode/bpel/unit-test.wsdl
+service=HelloXQueryService
+operation=HelloXQuery
+request1=<message><TestPart><content>Hello</content></TestPart></message>
+response1=.*HelloXQuery World.*
+

Modified: ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java?rev=708740&r1=708739&r2=708740&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java (original)
+++ ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/DOMUtils.java Tue Oct 28 17:11:15 2008
@@ -690,6 +690,15 @@
     public static QName getElementQName(Element el) {
         return new QName(el.getNamespaceURI(),el.getLocalName());
     }
+    
+    public static QName getNodeQName(String qualifiedName) {
+    	int index = qualifiedName.indexOf(":");
+    	if (index >= 0) {
+    		return new QName(qualifiedName.substring(0, index), qualifiedName.substring(index + 1));
+    	} else {
+    		return new QName(qualifiedName);
+    	}
+    }
 
     /**
      * Remove the child nodes under another node.
@@ -1044,4 +1053,7 @@
         return ll;
     }
 
+	public static Document getDocument(Node contextNode) {
+		return (contextNode == null) ? DOMUtils.newDocument() : contextNode.getOwnerDocument();
+    }
 }
\ No newline at end of file

Modified: ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/Namespaces.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/Namespaces.java?rev=708740&r1=708739&r2=708740&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/Namespaces.java (original)
+++ ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/Namespaces.java Tue Oct 28 17:11:15 2008
@@ -50,6 +50,7 @@
     public static final String WSDL_20 = "http://www.w3.org/2006/01/wsdl";
     public static final String XML_SCHEMA = "http://www.w3.org/2001/XMLSchema";
     public static final String XML_INSTANCE = "http://www.w3. org/2001/XMLSchema-instance";
+    public static final String XPATH_FUNCTIONS = "http://www.w3.org/2005/xpath-functions";
     public static final String JBI_END_POINT_REFERENCE = "http://java.sun.com/jbi/end-point-reference";
     public static final QName WS_ADDRESSING_ENDPOINT = new QName(WS_ADDRESSING_NS, "EndpointReference");
     public static final QName WS_ADDRESSING_USINGADDRESSING = new QName(WS_ADDRESSING_WSDL_NS, "UsingAddressing");