ode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mr...@apache.org
Subject svn commit: r691733 - in /ode/branches/APACHE_ODE_1.X: bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/ bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/ bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign...
Date Wed, 03 Sep 2008 19:01:43 GMT
Author: mriou
Date: Wed Sep  3 12:01:42 2008
New Revision: 691733

URL: http://svn.apache.org/viewvc?rev=691733&view=rev
Log:
ODE-367 XPath Update Facility

Modified:
    ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java
    ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java
    ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
    ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.bpel
    ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.wsdl
    ode/branches/APACHE_ODE_1.X/utils/src/main/java/org/apache/ode/utils/Namespaces.java

Modified: ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java?rev=691733&r1=691732&r2=691733&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java Wed Sep  3 12:01:42 2008
@@ -49,11 +49,22 @@
     /**
      * Non standard extension function ode:splitToElements(sourceText, 'separator' 'targetLocalName', 'targetNS'?)
      */
-    public static final String NON_STDRD_FUNCTION_SPLITTOELEMENTS = "splitToElements";
-    public static final String NON_STDRD_FUNCTION_COMBINE_URL = "combineUrl";
-    public static final String NON_STDRD_FUNCTION_COMPOSE_URL = "composeUrl";
-    public static final String NON_STDRD_FUNCTION_EXPAND_TEMPLATE = "expandTemplate";
-    public static final String NON_STDRD_FUNCTION_DOM_TO_STRING= "domToString";
+    public static final String NON_STDRD_FUNCTION_DEPRECATED_SPLIT_TO_ELEMENTS = "splitToElements";
+    public static final String NON_STDRD_FUNCTION_DEPRECATED_COMBINE_URL = "combineUrl";
+    public static final String NON_STDRD_FUNCTION_DEPRECATED_COMPOSE_URL = "composeUrl";
+    public static final String NON_STDRD_FUNCTION_DEPRECATED_EXPAND_TEMPLATE = "expandTemplate";
+    public static final String NON_STDRD_FUNCTION_DEPRECATED_DOM_TO_STRING= "domToString";
+    public static final String NON_STDRD_FUNCTION_SPLIT_TO_ELEMENTS = "split-to-elements";
+    public static final String NON_STDRD_FUNCTION_COMBINE_URL = "combine-url";
+    public static final String NON_STDRD_FUNCTION_COMPOSE_URL = "compose-url";
+    public static final String NON_STDRD_FUNCTION_EXPAND_TEMPLATE = "expand-template";
+    public static final String NON_STDRD_FUNCTION_DOM_TO_STRING= "dom-to-string";
+    public static final String NON_STDRD_FUNCTION_INSERT_AFTER = "insert-after";
+    public static final String NON_STDRD_FUNCTION_INSERT_BEFORE = "insert-before";
+    public static final String NON_STDRD_FUNCTION_INSERT_AS_FIRST_INTO = "insert-as-first-into";
+    public static final String NON_STDRD_FUNCTION_INSERT_AS_LAST_INTO = "insert-as-last-into";
+    public static final String NON_STDRD_FUNCTION_DELETE = "delete";
+    public static final String NON_STDRD_FUNCTION_RENAME = "rename";
 
     public static boolean isBpelNamespace(String uri){
         return Namespaces.WS_BPEL_20_NS.equals(uri) || Namespaces.WSBPEL2_0_FINAL_EXEC.equals(uri)

Modified: ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java?rev=691733&r1=691732&r2=691733&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java Wed Sep  3 12:01:42 2008
@@ -19,6 +19,13 @@
 
 package org.apache.ode.bpel.elang.xpath20.compiler;
 
+import java.util.List;
+
+import javax.xml.namespace.QName;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionException;
+import javax.xml.xpath.XPathFunctionResolver;
+
 import org.apache.ode.bpel.compiler.api.CompilationException;
 import org.apache.ode.bpel.compiler.api.CompilerContext;
 import org.apache.ode.bpel.elang.xpath10.compiler.XPathMessages;
@@ -32,12 +39,6 @@
 import org.apache.ode.utils.msg.MessageBundle;
 import org.apache.ode.utils.xsl.XslTransformHandler;
 
-import javax.xml.namespace.QName;
-import javax.xml.xpath.XPathFunction;
-import javax.xml.xpath.XPathFunctionException;
-import javax.xml.xpath.XPathFunctionResolver;
-import java.util.List;
-
 /**
  * @author mriou <mriou at apache dot org>
  */
@@ -73,15 +74,32 @@
             }
         } else if (functionName.getNamespaceURI().equals(Namespaces.ODE_EXTENSION_NS)) {
             String localName = functionName.getLocalPart();
-            if (Constants.NON_STDRD_FUNCTION_SPLITTOELEMENTS.equals(localName)) {
+            if (Constants.NON_STDRD_FUNCTION_SPLIT_TO_ELEMENTS.equals(localName) ||
+            		Constants.NON_STDRD_FUNCTION_DEPRECATED_SPLIT_TO_ELEMENTS.equals(localName)) {
                 return new SplitToElements();
-            } else if (Constants.NON_STDRD_FUNCTION_COMBINE_URL.equals(localName)) {
+            } else if (Constants.NON_STDRD_FUNCTION_COMBINE_URL.equals(localName) ||
+            		Constants.NON_STDRD_FUNCTION_DEPRECATED_COMBINE_URL.equals(localName)) {
                 return new CombineUrl();
-            } else if (Constants.NON_STDRD_FUNCTION_COMPOSE_URL.equals(localName)
-                    || Constants.NON_STDRD_FUNCTION_EXPAND_TEMPLATE.equals(localName)) {
+            } else if (Constants.NON_STDRD_FUNCTION_COMPOSE_URL.equals(localName) ||
+                    Constants.NON_STDRD_FUNCTION_EXPAND_TEMPLATE.equals(localName) ||
+                    Constants.NON_STDRD_FUNCTION_DEPRECATED_COMPOSE_URL.equals(localName) ||
+                    Constants.NON_STDRD_FUNCTION_DEPRECATED_EXPAND_TEMPLATE.equals(localName)) {
                 return new ComposeUrl();
-            } else if ( Constants.NON_STDRD_FUNCTION_DOM_TO_STRING.equals(localName)) {
+            } else if (Constants.NON_STDRD_FUNCTION_DOM_TO_STRING.equals(localName) ||
+            		Constants.NON_STDRD_FUNCTION_DEPRECATED_DOM_TO_STRING.equals(localName)) {
             	return new DomToString();
+            } else if (Constants.NON_STDRD_FUNCTION_INSERT_AFTER.equals(localName)) {
+            	return new InsertAfter();
+            } else if (Constants.NON_STDRD_FUNCTION_INSERT_AS_FIRST_INTO.equals(localName)) {
+            	return new InsertAsFirstInto();
+            } else if (Constants.NON_STDRD_FUNCTION_INSERT_AS_LAST_INTO.equals(localName)) {
+            	return new InsertAsLastInto();
+            } else if (Constants.NON_STDRD_FUNCTION_INSERT_BEFORE.equals(localName)) {
+            	return new InsertBefore();
+            } else if (Constants.NON_STDRD_FUNCTION_DELETE.equals(localName)) {
+            	return new Delete();
+            } else if (Constants.NON_STDRD_FUNCTION_RENAME.equals(localName)) {
+            	return new Rename();
             }
         }
 
@@ -144,7 +162,7 @@
         public Object evaluate(List params) throws XPathFunctionException {
             if (params.size() < 3 || params.size() > 4) {
                 throw new CompilationException(
-                        __msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_SPLITTOELEMENTS));
+                        __msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_SPLIT_TO_ELEMENTS));
             }
             return "";
         }
@@ -177,5 +195,69 @@
             return "";
         }
     }
+    
+    public class InsertInto implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() != 3) {
+                throw new CompilationException(__msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_INSERT_AFTER));
+            }
+            return "";
+    	}
+    }
+    
+    public class InsertAfter implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() < 2 || args.size() > 3) {
+                throw new CompilationException(__msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_INSERT_AFTER));
+            }
+            return "";
+    	}
+    }
+    
+    public class InsertBefore implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() < 2 || args.size() > 3) {
+                throw new CompilationException(__msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_INSERT_BEFORE));
+            }
+            return "";
+    	}
+    }
+
+    public class InsertAsFirstInto implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() != 2) {
+                throw new CompilationException(__msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_INSERT_AS_FIRST_INTO));
+            }
+            return "";
+    	}
+    }
+
+    public class InsertAsLastInto implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() != 2) {
+                throw new CompilationException(__msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_INSERT_AS_LAST_INTO));
+            }
+            return "";
+    	}
+    }
+
+    public class Delete implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() < 1 || args.size() > 2) {
+                throw new CompilationException(__msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_DELETE));
+            }
+            return "";
+    	}
+    }
+    
+    public class Rename implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() < 2) {
+                throw new CompilationException(__msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_RENAME));
+            }
+            return "";
+    	}
+    }
+    
 
 }

Modified: ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java?rev=691733&r1=691732&r2=691733&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java Wed Sep  3 12:01:42 2008
@@ -19,7 +19,28 @@
 
 package org.apache.ode.bpel.elang.xpath20.runtime;
 
+import java.io.IOException;
+import java.io.StringWriter;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.xpath.XPathFunction;
+import javax.xml.xpath.XPathFunctionException;
+import javax.xml.xpath.XPathFunctionResolver;
+
 import net.sf.saxon.dom.NodeWrapper;
+import net.sf.saxon.value.IntegerValue;
+import net.sf.saxon.value.QNameValue;
+
 import org.apache.commons.httpclient.URIException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -27,7 +48,6 @@
 import org.apache.ode.bpel.elang.xpath10.o.OXPath10Expression;
 import org.apache.ode.bpel.elang.xpath10.o.OXPath10ExpressionBPEL20;
 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.o.OXPath20ExpressionBPEL20;
 import org.apache.ode.bpel.explang.EvaluationContext;
 import org.apache.ode.bpel.o.OLink;
@@ -41,25 +61,10 @@
 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;
 import org.xml.sax.SAXException;
 
-import javax.xml.namespace.QName;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.xpath.XPathFunction;
-import javax.xml.xpath.XPathFunctionException;
-import javax.xml.xpath.XPathFunctionResolver;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 /**
  * @author mriou <mriou at apache dot org>
  */
@@ -78,7 +83,7 @@
     public XPathFunction resolveFunction(QName functionName, int arity) {
         __log.debug("Resolving function " + functionName);
         if (functionName.getNamespaceURI() == null) {
-            throw new WrappedResolverException("Undeclared namespace for " + functionName);
+            throw new NullPointerException("Undeclared namespace for " + functionName);
         } else if (functionName.getNamespaceURI().equals(Namespaces.WS_BPEL_20_NS) ||
                 functionName.getNamespaceURI().equals(Namespaces.WSBPEL2_0_FINAL_EXEC)) {
             String localName = functionName.getLocalPart();
@@ -91,20 +96,37 @@
             } else if (Constants.EXT_FUNCTION_DOXSLTRANSFORM.equals(localName)) {
                 return new DoXslTransform();
             } else {
-                throw new WrappedResolverException("Unknown BPEL function: " + functionName);
+                throw new NullPointerException("Unknown BPEL function: " + functionName);
             }
         } else if (functionName.getNamespaceURI().equals(Namespaces.ODE_EXTENSION_NS)) {
             String localName = functionName.getLocalPart();
-            if (Constants.NON_STDRD_FUNCTION_SPLITTOELEMENTS.equals(localName)) {
+            if (Constants.NON_STDRD_FUNCTION_SPLIT_TO_ELEMENTS.equals(localName) ||
+            		Constants.NON_STDRD_FUNCTION_DEPRECATED_SPLIT_TO_ELEMENTS.equals(localName)) {
                 return new SplitToElements();
-            } else if (Constants.NON_STDRD_FUNCTION_COMBINE_URL.equals(localName)) {
+            } else if (Constants.NON_STDRD_FUNCTION_COMBINE_URL.equals(localName) ||
+            		Constants.NON_STDRD_FUNCTION_DEPRECATED_COMBINE_URL.equals(localName)) {
                 return new CombineUrl();
-            } else if (Constants.NON_STDRD_FUNCTION_COMPOSE_URL.equals(localName)) {
+            } else if (Constants.NON_STDRD_FUNCTION_COMPOSE_URL.equals(localName) ||
+            		Constants.NON_STDRD_FUNCTION_DEPRECATED_COMPOSE_URL.equals(localName)) {
                 return new ComposeUrl();
-            } else if (Constants.NON_STDRD_FUNCTION_EXPAND_TEMPLATE.equals(localName)) {
+            } else if (Constants.NON_STDRD_FUNCTION_EXPAND_TEMPLATE.equals(localName) ||
+            		Constants.NON_STDRD_FUNCTION_DEPRECATED_EXPAND_TEMPLATE.equals(localName)) {
                 return new ComposeUrl(true, "expandTemplateInvalidSource");
-            } else if ( Constants.NON_STDRD_FUNCTION_DOM_TO_STRING.equals(localName)) {
+            } else if (Constants.NON_STDRD_FUNCTION_DOM_TO_STRING.equals(localName) ||
+            		Constants.NON_STDRD_FUNCTION_DEPRECATED_DOM_TO_STRING.equals(localName)) {
             	return new DomToString();
+            } else if (Constants.NON_STDRD_FUNCTION_INSERT_AFTER.equals(localName)) {
+            	return new InsertAfter();
+            } else if (Constants.NON_STDRD_FUNCTION_INSERT_AS_FIRST_INTO.equals(localName)) {
+            	return new InsertAsFirstInto();
+            } else if (Constants.NON_STDRD_FUNCTION_INSERT_AS_LAST_INTO.equals(localName)) {
+            	return new InsertAsLastInto();
+            } else if (Constants.NON_STDRD_FUNCTION_INSERT_BEFORE.equals(localName)) {
+            	return new InsertBefore();
+            } else if (Constants.NON_STDRD_FUNCTION_DELETE.equals(localName)) {
+            	return new Delete();
+            } else if (Constants.NON_STDRD_FUNCTION_RENAME.equals(localName)) {
+            	return new Rename();
             }
         }
 
@@ -183,6 +205,7 @@
     }
 
     public class DoXslTransform implements XPathFunction {
+
 		public Object evaluate(List args) throws XPathFunctionException {
             if (args.size() < 2 || (args.size() % 2) != 0)
                 throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "doXslTransformInvalidSource"), "Invalid arguments"));
@@ -496,6 +519,557 @@
 
     }
 
+    public class InsertInto implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() != 3)
+                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "insertIntoInvalidSource"), "Invalid arguments"));
+
+            if (__log.isDebugEnabled()) {
+                __log.debug("insertInto call(context=" + _ectx + " args=" + args + ")");
+            }
+            
+            Element parentElmt;
+            int position;
+            List childNodes;
+            try {
+                if (args.get(0) instanceof List) {
+                    List elmts = (List) args.get(0);
+                    if (elmts.size() != 1) throw new XPathFunctionException(
+                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                    "The bpws:insertInto function MUST be passed a single " +
+                                            "element node."));
+                    parentElmt = (Element) elmts.get(0);
+                } else if (args.get(0) instanceof NodeWrapper) {
+                    parentElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
+                } else if (args.get(0) instanceof Element) {
+                    parentElmt = (Element) args.get(0);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
+                }
+                position = Helper.extractInteger(args.get(1));
+                if (args.get(2) instanceof List) {
+                    childNodes = (List) args.get(2);
+                } else if (args.get(2) instanceof NodeWrapper) {
+                    Node childElmt = (Node) ((NodeWrapper) args.get(2)).getUnderlyingNode();
+                    childNodes = new ArrayList<Node>();
+                    childNodes.add(childElmt);
+                } else if (args.get(2) instanceof Element) {
+                    Node childElmt = (Node) args.get(2);
+                    childNodes = new ArrayList<Node>();
+                    childNodes.add(childElmt);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
+                }
+            } catch (IllegalArgumentException e) {
+                throw new XPathFunctionException(
+                		new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
+                				"Invalid argument: URI Template expected. " + args.get(0), e));
+            } catch (ClassCastException e) {
+                throw new XPathFunctionException(
+                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                "The bpws:insertInto function MUST be passed a single " +
+                                        "element node."));
+            }
+            Element clonedElmt = (Element) parentElmt.cloneNode(true);
+            NodeList children = clonedElmt.getChildNodes();
+            int childCount = children.getLength();
+            Node refChild = null;
+            if (position <= 1) {
+            	refChild = clonedElmt.getFirstChild();
+            } else if (position == childCount) {
+            	refChild = clonedElmt.getLastChild();
+            } else if (position > childCount) {
+            	refChild = null;
+            } else {
+            	refChild = children.item(position + 1);
+            }
+            for (int i = 0; i < childNodes.size(); i++) {
+            	clonedElmt.insertBefore((Node) childNodes.get(i), refChild);
+            }
+            return clonedElmt;
+    	}
+    }
+    
+    public class InsertAfter implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() < 2 || args.size() > 3)
+                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "insertAfterInvalidSource"), "Invalid arguments"));
+
+            if (__log.isDebugEnabled()) {
+                __log.debug("insertAfter call(context=" + _ectx + " args=" + args + ")");
+            }
+            
+            Element targetElmt;
+            List<Node> siblingNodes;
+        	Object childArg = null, siblingsArg = null;
+            try {
+            	if (args.size() == 2) {
+            		childArg = args.get(0);
+            		siblingsArg = args.get(1);
+            	} else {
+            		childArg = args.get(1);
+            		siblingsArg = args.get(2);
+            	}
+                if (childArg instanceof List) {
+                    List elmts = (List) childArg;
+                    // allow insertions after a sequence of node items
+                    // if (elmts.size() != 1) throw new XPathFunctionException(
+                    //        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                    //                "The bpws:insertAfter function MUST be passed a single " +
+                    //                        "element node."));
+                    targetElmt = (Element) elmts.get(elmts.size() - 1);
+                } else if (childArg instanceof NodeWrapper) {
+                    targetElmt = (Element) ((NodeWrapper) childArg).getUnderlyingNode();
+                } else if (childArg instanceof Element) {
+                    targetElmt = (Element) childArg;
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: " + childArg.getClass());
+                }
+                if (siblingsArg instanceof List) {
+                    siblingNodes = (List<Node>) siblingsArg;
+                } else if (siblingsArg instanceof NodeWrapper) {
+                    Node childElmt = (Node) ((NodeWrapper) siblingsArg).getUnderlyingNode();
+                    siblingNodes = new ArrayList<Node>();
+                    siblingNodes.add(childElmt);
+                } else if (siblingsArg instanceof Element) {
+                    Node childElmt = (Node) siblingsArg;
+                    siblingNodes = new ArrayList<Node>();
+                    siblingNodes.add(childElmt);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: " + siblingsArg.getClass());
+                }
+            } catch (IllegalArgumentException e) {
+                throw new XPathFunctionException(
+                		new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
+                				"Invalid argument: URI Template expected. " + siblingsArg, e));
+            } catch (ClassCastException e) {
+                throw new XPathFunctionException(
+                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                "The bpws:insertAfter function MUST be passed a single " +
+                                        "element node."));
+            }
+            Element parentElmt = (Element) targetElmt.getParentNode();
+            NodeList children = parentElmt.getChildNodes();
+            int position = 0;
+            while (position < children.getLength()) {
+            	if (children.item(position++).isSameNode(targetElmt)) {
+            		break;
+            	}
+            }
+            Element clonedElmt = (Element) parentElmt.cloneNode(true);
+            children = clonedElmt.getChildNodes();
+            Node refChild = (position < children.getLength()) ? children.item(position) : null;
+            Document clonedDocument = clonedElmt.getOwnerDocument();
+            for (int i = 0; i < siblingNodes.size(); i++) {
+            	clonedElmt.insertBefore(clonedDocument.importNode((Node) siblingNodes.get(i), true), refChild);
+            }
+            return clonedElmt;
+    	}
+    }
+    
+    public class InsertBefore implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() < 2 || args.size() > 3)
+                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "insertBeforeInvalidSource"), "Invalid arguments"));
+
+            if (__log.isDebugEnabled()) {
+                __log.debug("insertBefore call(context=" + _ectx + " args=" + args + ")");
+            }
+            
+            Element targetElmt;
+            List<Node> siblingNodes;
+        	Object childArg = null, siblingsArg = null;
+            try {
+            	if (args.size() == 2) {
+            		childArg = args.get(0);
+            		siblingsArg = args.get(1);
+            	} else {
+            		childArg = args.get(1);
+            		siblingsArg = args.get(2);
+            	}
+                if (childArg instanceof List) {
+                    List elmts = (List) childArg;
+                    // allow insertions after a sequence of node items
+                    // if (elmts.size() != 1) throw new XPathFunctionException(
+                    //        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                    //                "The bpws:insertBefore function MUST be passed a single " +
+                    //                        "element node."));
+                    targetElmt = (Element) elmts.get(0);
+                } else if (childArg instanceof NodeWrapper) {
+                    targetElmt = (Element) ((NodeWrapper) childArg).getUnderlyingNode();
+                } else if (childArg instanceof Element) {
+                    targetElmt = (Element) childArg;
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: " + childArg.getClass());
+                }
+                if (siblingsArg instanceof List) {
+                    siblingNodes = (List) siblingsArg;
+                } else if (siblingsArg instanceof NodeWrapper) {
+                    Node childElmt = (Node) ((NodeWrapper) siblingsArg).getUnderlyingNode();
+                    siblingNodes = new ArrayList<Node>();
+                    siblingNodes.add(childElmt);
+                } else if (siblingsArg instanceof Element) {
+                    Node childElmt = (Node) siblingsArg;
+                    siblingNodes = new ArrayList<Node>();
+                    siblingNodes.add(childElmt);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: " + siblingsArg.getClass());
+                }
+            } catch (IllegalArgumentException e) {
+                throw new XPathFunctionException(
+                		new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
+                				"Invalid argument: URI Template expected. " + childArg, e));
+            } catch (ClassCastException e) {
+                throw new XPathFunctionException(
+                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                "The bpws:insertBefore function MUST be passed a single " +
+                                        "element node."));
+            }
+            Element parentElmt = (Element) targetElmt.getParentNode();
+            NodeList children = parentElmt.getChildNodes();
+            int position = 0;
+            while (position < children.getLength()) {
+            	if (children.item(position++).isSameNode(targetElmt)) {
+            		break;
+            	}
+            }
+            Element clonedElmt = (Element) parentElmt.cloneNode(true);
+            children = clonedElmt.getChildNodes();
+            Node refChild = (position <= children.getLength()) ? children.item(position - 1) : null;
+            Document clonedDocument = clonedElmt.getOwnerDocument();
+            for (int i = 0; i < siblingNodes.size(); i++) {
+            	clonedElmt.insertBefore(clonedDocument.importNode((Node) siblingNodes.get(i), true), refChild);
+            }
+            return clonedElmt;
+    	}
+    }
+
+    public class InsertAsFirstInto implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() != 2)
+                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "insertAsFirstIntoInvalidSource"), "Invalid arguments"));
+
+            if (__log.isDebugEnabled()) {
+                __log.debug("insertAsFirstInto call(context=" + _ectx + " args=" + args + ")");
+            }
+            
+            Element targetElmt;
+            List siblingNodes;
+            try {
+                if (args.get(0) instanceof List) {
+                    List elmts = (List) args.get(0);
+                    if (elmts.size() != 1) throw new XPathFunctionException(
+                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                    "The bpws:insertAsFirstInto function MUST be passed a single " +
+                                            "element node."));
+                    targetElmt = (Element) elmts.get(0);
+                } else if (args.get(0) instanceof NodeWrapper) {
+                    targetElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
+                } else if (args.get(0) instanceof Element) {
+                    targetElmt = (Element) args.get(0);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
+                }
+                if (args.get(1) instanceof List) {
+                    siblingNodes = (List) args.get(1);
+                } else if (args.get(1) instanceof NodeWrapper) {
+                    Node childElmt = (Node) ((NodeWrapper) args.get(1)).getUnderlyingNode();
+                    siblingNodes = new ArrayList<Node>();
+                    siblingNodes.add(childElmt);
+                } else if (args.get(1) instanceof Element) {
+                    Node childElmt = (Node) args.get(1);
+                    siblingNodes = new ArrayList<Node>();
+                    siblingNodes.add(childElmt);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
+                }
+            } catch (IllegalArgumentException e) {
+                throw new XPathFunctionException(
+                		new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
+                				"Invalid argument: URI Template expected. " + args.get(0), e));
+            } catch (ClassCastException e) {
+                throw new XPathFunctionException(
+                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                "The bpws:insertAsFirstInto function MUST be passed a single " +
+                                        "element node."));
+            }
+            Element clonedElmt = (Element) targetElmt.cloneNode(true);
+            Node refChild = clonedElmt.getFirstChild();
+            Document clonedDocument = clonedElmt.getOwnerDocument();
+            for (int i = 0; i < siblingNodes.size(); i++) {
+            	clonedElmt.insertBefore(clonedDocument.importNode((Node) siblingNodes.get(i), true), refChild);
+            }
+            return clonedElmt;
+    	}
+    }
+
+    public class InsertAsLastInto implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() != 2)
+                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "insertAsLastIntoInvalidSource"), "Invalid arguments"));
+
+            if (__log.isDebugEnabled()) {
+                __log.debug("insertAsLastInto call(context=" + _ectx + " args=" + args + ")");
+            }
+            
+            Element targetElmt;
+            List siblingNodes;
+            try {
+                if (args.get(0) instanceof List) {
+                    List elmts = (List) args.get(0);
+                    if (elmts.size() != 1) throw new XPathFunctionException(
+                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                    "The bpws:insertAsLastInto function MUST be passed a single " +
+                                            "element node."));
+                    targetElmt = (Element) elmts.get(0);
+                } else if (args.get(0) instanceof NodeWrapper) {
+                    targetElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
+                } else if (args.get(0) instanceof Element) {
+                    targetElmt = (Element) args.get(0);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
+                }
+                if (args.get(1) instanceof List) {
+                    siblingNodes = (List) args.get(1);
+                } else if (args.get(1) instanceof NodeWrapper) {
+                    Node childElmt = (Node) ((NodeWrapper) args.get(1)).getUnderlyingNode();
+                    siblingNodes = new ArrayList<Node>();
+                    siblingNodes.add(childElmt);
+                } else if (args.get(1) instanceof Element) {
+                    Node childElmt = (Node) args.get(1);
+                    siblingNodes = new ArrayList<Node>();
+                    siblingNodes.add(childElmt);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
+                }
+            } catch (IllegalArgumentException e) {
+                throw new XPathFunctionException(
+                		new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
+                				"Invalid argument: URI Template expected. " + args.get(0), e));
+            } catch (ClassCastException e) {
+                throw new XPathFunctionException(
+                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                "The bpws:insertAsLastInto function MUST be passed a single " +
+                                        "element node."));
+            }
+            Element clonedElmt = (Element) targetElmt.cloneNode(true);
+            Document clonedDocument = clonedElmt.getOwnerDocument();
+            for (int i = 0; i < siblingNodes.size(); i++) {
+            	clonedElmt.appendChild(clonedDocument.importNode((Node) siblingNodes.get(i), true));
+            }
+            return clonedElmt;
+    	}
+    }
+
+    public class Delete implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() < 1 || args.size() > 2)
+                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "deleteInvalidSource"), "Invalid arguments"));
+
+            if (__log.isDebugEnabled()) {
+                __log.debug("delete call(context=" + _ectx + " args=" + args + ")");
+            }
+            
+            List<Node> targetNodes = new ArrayList();
+            List siblingNodes;
+        	Object delete = args.size() == 2 ? delete = args.get(1) : args.get(0);
+            try {
+                if (delete instanceof List) {
+                    List elmts = (List) delete;
+                    // allow insertions after a sequence of node items
+                    // if (elmts.size() != 1) throw new XPathFunctionException(
+                    //        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                    //                "The bpws:delete function MUST be passed a single " +
+                    //                        "element node."));
+                    targetNodes.addAll(elmts);
+                } else if (delete instanceof NodeWrapper) {
+                    targetNodes.add((Element) ((NodeWrapper) delete).getUnderlyingNode());
+                } else if (delete instanceof Element) {
+                    targetNodes.add((Element) delete);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: " + delete.getClass());
+                }
+            } catch (IllegalArgumentException e) {
+                throw new XPathFunctionException(
+                		new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
+                				"Invalid argument: URI Template expected. " + delete, e));
+            } catch (ClassCastException e) {
+                throw new XPathFunctionException(
+                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                "The bpws:delete function MUST be passed a valid " +
+                                        "element node."));
+            }
+            Element parentElmt = null;
+            for (Node targetNode : targetNodes) {
+            	if (parentElmt == null) {
+            		parentElmt = (Element) targetNode.getParentNode();
+            	} else if (!parentElmt.isSameNode((Element) targetNode.getParentNode())) {
+                    throw new XPathFunctionException(
+                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                    "The bpws:delete function MUST be passed nodes that have " +
+                                            "the same parent."));
+            	}
+            }
+            NodeList children = parentElmt.getChildNodes();
+            int[] positions = new int[targetNodes.size()];
+            for (int target = 0; target < positions.length; target++) {
+	            for (int position = 0; position < children.getLength(); position++) {
+	            	if (children.item(position).isSameNode(targetNodes.get(target))) {
+	            		positions[target] = position;
+		            }
+	            }
+            }
+            Element clonedElmt = (Element) parentElmt.cloneNode(true);
+            children = clonedElmt.getChildNodes();
+            for (int target = 0; target < positions.length; target++) {
+	            Element deleteElmt = (Element) children.item(positions[target]);
+	            clonedElmt.removeChild(deleteElmt);
+            }
+            return clonedElmt;
+    	}
+    }
+    
+    public class Rename implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() < 2)
+                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "renameInvalidSource"), "Invalid arguments"));
+
+            if (__log.isDebugEnabled()) {
+                __log.debug("rename call(context=" + _ectx + " args=" + args + ")");
+            }
+            
+            Element targetElmt;
+            QName elementQName = null, elementTypeQName = null;
+            try {
+                if (args.get(0) instanceof List) {
+                    List elmts = (List) args.get(0);
+                    if (elmts.size() != 1) throw new XPathFunctionException(
+                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                    "The bpws:rename function MUST be passed a single " +
+                                            "element node."));
+                    targetElmt = (Element) elmts.get(0);
+                } else if (args.get(0) instanceof NodeWrapper) {
+                    targetElmt = (Element) ((NodeWrapper) args.get(0)).getUnderlyingNode();
+                } else if (args.get(0) instanceof Element) {
+                    targetElmt = (Element) args.get(0);
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: "+args.get(0).getClass());
+                }
+            	String localName = null, namespaceUri = null, prefix = null;
+                if (args.get(1) instanceof QNameValue) {
+                	QNameValue qNameValue = (QNameValue) args.get(1);
+                    namespaceUri = qNameValue.getNamespaceURI();
+                    localName = qNameValue.getLocalName();
+                    prefix = qNameValue.getPrefix();
+                } else if (args.get(1) instanceof List) {
+                    List elmts = (List) args.get(1);
+                    if (elmts.size() != 1) throw new XPathFunctionException(
+                            new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                    "The bpws:rename function MUST be passed a single " +
+                                            "element node."));
+                    Element nameElmt = (Element) elmts.get(0);
+                	namespaceUri = nameElmt.getNamespaceURI();
+                	localName = nameElmt.getLocalName();
+                	prefix = nameElmt.getPrefix();
+                } else if (args.get(1) instanceof NodeWrapper) {
+                	Element nameElmt = (Element) ((NodeWrapper) args.get(1)).getUnderlyingNode();
+                	namespaceUri = nameElmt.getNamespaceURI();
+                	localName = nameElmt.getLocalName();
+                	prefix = nameElmt.getPrefix();
+                } else if (args.get(1) instanceof Element) {
+                	Element nameElmt = (Element) args.get(1);
+                	namespaceUri = nameElmt.getNamespaceURI();
+                	localName = nameElmt.getLocalName();
+                	prefix = nameElmt.getPrefix();
+                } else if (args.get(1) instanceof String)	{
+                	String qName = (String) args.get(1);
+                	if (qName.contains(":")) {
+                		int index = qName.indexOf(":");
+                		prefix = qName.substring(0, index);
+                		localName = qName.substring(index + 1);
+                	} else {
+                		localName = qName;
+                	}
+                } else {
+                    throw new XPathFunctionException("Unexpected argument type: "+args.get(1).getClass());
+                }
+                if (namespaceUri == null) {
+                	namespaceUri = targetElmt.lookupNamespaceURI(prefix);
+                }
+            	elementQName = new QName(namespaceUri, localName, prefix);
+                if (args.size() > 2) {
+                    if (args.get(2) instanceof QNameValue) {
+                    	QNameValue qNameValue = (QNameValue) args.get(2);
+                        namespaceUri = qNameValue.getNamespaceURI();
+                        localName = qNameValue.getLocalName();
+                        prefix = qNameValue.getPrefix();
+                    } else if (args.get(2) instanceof NodeWrapper) {
+                    	Element nameElmt = (Element) ((NodeWrapper) args.get(2)).getUnderlyingNode();
+                    	namespaceUri = nameElmt.getNamespaceURI();
+                    	localName = nameElmt.getLocalName();
+                    	prefix = nameElmt.getPrefix();
+                    } else if (args.get(2) instanceof Element) {
+                    	Element nameElmt = (Element) args.get(2);
+                    	namespaceUri = nameElmt.getNamespaceURI();
+                    	localName = nameElmt.getLocalName();
+                    	prefix = nameElmt.getPrefix();
+                    } else if (args.get(2) instanceof String)	{
+                    	String qName = (String) args.get(2);
+                    	if (qName.contains(":")) {
+                    		int index = qName.indexOf(":");
+                    		prefix = qName.substring(0, index);
+                    		localName = qName.substring(index + 1);
+                    	} else {
+                    		localName = qName;
+                    	}
+                    } else {
+                        throw new XPathFunctionException("Unexpected argument type: "+args.get(2).getClass());
+                    }
+                    if (namespaceUri == null) {
+                    	namespaceUri = targetElmt.lookupNamespaceURI(prefix);
+                    }
+                    elementTypeQName = new QName(namespaceUri, localName, prefix);;
+                }
+            } catch (IllegalArgumentException e) {
+                throw new XPathFunctionException(
+                		new FaultException(_oxpath.getOwner().constants.qnInvalidExpressionValue,
+                				"Invalid argument: URI Template expected. " + args.get(0), e));
+            } catch (ClassCastException e) {
+                throw new XPathFunctionException(
+                        new FaultException(_oxpath.getOwner().constants.qnSelectionFailure,
+                                "The bpws:rename function MUST be passed a single " +
+                                        "element node."));
+            }
+            Element parentElmt = (Element) targetElmt.getParentNode();
+            NodeList children = parentElmt.getChildNodes();
+            int position = 0;
+            while (position < children.getLength()) {
+            	if (children.item(position++).isSameNode(targetElmt)) {
+            		break;
+            	}
+            }
+            Element clonedElmt = (Element) parentElmt.cloneNode(true);
+            children = clonedElmt.getChildNodes();
+            Element renamedElmt = targetElmt
+						        	.getOwnerDocument()
+						        	.createElementNS(
+						        			elementQName.getNamespaceURI(), 
+						        			elementQName.getPrefix() + ":" + elementQName.getLocalPart());
+            Element originalElmt = (Element) children.item(position - 1);
+            children = originalElmt.getChildNodes();
+            for (int i = 0; i < children.getLength(); i++) {
+            	renamedElmt.appendChild(children.item(i));
+            }
+            clonedElmt.replaceChild(renamedElmt, originalElmt);
+            if (elementTypeQName != null) {
+            	renamedElmt.setAttributeNS(
+            			Namespaces.XML_INSTANCE, "xsi:type", 
+            			elementTypeQName.getPrefix() + ":" + elementTypeQName.getLocalPart());
+            }
+            return clonedElmt;
+    	}
+    }
+    
     public static class Helper {
         /**
          * Extract a string from the given parameter.<br/>
@@ -546,6 +1120,36 @@
         }
 
         /**
+         * Extract an integer from the given parameter.<br/>
+         * The parameter could be:
+         * <ol>
+         * <li>a {@link java.util.List} containing exactly one {@link org.w3c.dom.Node}</li>
+         * <li>a {@link net.sf.saxon.dom.NodeWrapper}</li>
+         * <li>a {@link org.w3c.dom.Node}</li>
+         * <li>a {@link String}</li>
+         * <li>or an {@link Integer}</li>
+         * </ol>
+         * In the first 3 cases, if the {@linkplain org.w3c.dom.Node node} type is {@link Node#ELEMENT_NODE} the (trimmed) {@linkplain org.w3c.dom.Node#getTextContent() text content} is returned.
+         * if the {@linkplain org.w3c.dom.Node node} type is {@link Node#TEXT_NODE} the (trimmed) {@linkplain org.w3c.dom.Text#getWholeText() text content} is returned.
+         * <p/>
+         *
+         * @param arg
+         * @return a string
+         * @throws IllegalArgumentException if none of the conditions mentioned above are met
+         */
+        public static int extractInteger(Object arg) throws IllegalArgumentException {
+        	try {
+	    		return Integer.parseInt(extractString(arg));
+            } catch (ClassCastException cce) {
+            	if (arg instanceof IntegerValue) {
+            		return (int) ((IntegerValue) arg).longValue();
+            	}
+                throw new IllegalArgumentException("Parameter MUST point to an integer, single element or text node.", cce);
+        	} catch (NumberFormatException nfe) {
+                throw new IllegalArgumentException("Parameter MUST point to an integer, single element or text node.", nfe);
+        	}
+        }
+        /**
          * Extract the name/value from an xml element similar too:
          * <br/>
          * {@literal <elt>

Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.bpel
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.bpel?rev=691733&r1=691732&r2=691733&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.bpel (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.bpel Wed Sep  3 12:01:42 2008
@@ -21,8 +21,11 @@
  xmlns:tns="http://ode/bpel/unit-test/TestSubTreeAssign"
  xmlns:prb="http://ode/bpel/unit-test/ProbeService.wsdl"
  xmlns:types="http://ode/bpel/unit-test/TestSubTreeAssign.wsdl.types"
+ xmlns:foo="http://ode/bpel/unit-test/TestSubTreeAssign.wsdl.types"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:wns="http://ode/bpel/unit-test/TestSubTreeAssign.wsdl"
+ xmlns:ode="http://www.apache.org/ode/type/extension"
+ xmlns:fn="http://www.w3.org/2005/xpath-functions"
  xmlns="http://docs.oasis-open.org/wsbpel/2.0/process/executable"
  targetNamespace="http://ode/bpel/unit-test/TestSubTreeAssign"
  name="TestSubTreeAssign"
@@ -36,67 +39,201 @@
 	<import location="../ProbeService/probeService.wsdl"
 		namespace="http://ode/bpel/unit-test/ProbeService.wsdl"
 		importType="http://schemas.xmlsoap.org/wsdl/"/>
-	
-	
-	<partnerLinks>
-		<partnerLink name="request" partnerLinkType="wns:TestSubTreeAssignRequest" myRole="TestSubTreeAssignService"/>
-	</partnerLinks>
-	<variables>
-		<variable name="request" messageType="wns:requestMessage"/>
-		<variable name="testType1" element="types:aTestMessage"/>
-		<variable name="testType2" element="types:aTestMessage"/>
-		<variable name="testType3" type="xsd:string"/>
-		<variable name="testType4" type="xsd:string"/>
-		<variable name="reply" messageType="wns:replyMessage"/>
-	</variables>
-	<sequence>
-		<receive name="receive1" partnerLink="request" portType="wns:TestSubTreeAssignPT" operation="request" variable="request" createInstance="yes"/>
-
-		<assign name="assign1">
-			<!-- copy a tree to a tree -->
-			<copy>
-				<from>$request.requestMessageData/typeIndicators/types:indicatorTwo</from>
-				<to variable="testType3"/>
-			</copy>
-			<copy>
-				<from variable="request" property="wns:testPath"/>
-				<to variable="testType4"/>
-			</copy>
-			<copy>
-				<from variable="request" part="requestMessageData"/>
-				<to variable="testType1"/>
-			</copy>
-			<copy>
-				<from variable="testType1"/>
-				<to variable="testType2"/>
-			</copy>
-			<!-- copy value into tree -->
-			<copy>
-				<from>
-					<literal><![CDATA[pass]]></literal>
-				</from>
-				<to>$testType1/typeIndicators/types:indicatorTwo</to>
-			</copy>		
-		</assign>
-	
-		<assign name="assignG">
-			<!-- copy subtree to tree -->
-			<copy>
-				<from>$testType1/typeIndicators</from>
-				<to>$testType2/typeIndicators</to>
-			</copy>
-		</assign>
-		<assign name="assign3">			
-			<copy>
-				<from>$testType2/requestID</from>
-				<to variable="reply" part="replyID"/>
-			</copy>
-			<copy>
-				<from>$testType2/typeIndicators/types:indicatorTwo</from>
-				<to>$reply.replyText</to>
-			</copy>
-		</assign>
-		
-		<reply name="reply" partnerLink="request" portType="wns:TestSubTreeAssignPT" operation="request" variable="reply"/>
-	</sequence>
-</process>
+ 	
+ 	<partnerLinks>
+ 		<partnerLink name="request" partnerLinkType="wns:TestSubTreeAssignRequest" myRole="TestSubTreeAssignService"/>
+ 	</partnerLinks>
+ 	<variables>
+ 		<variable name="request" messageType="wns:requestMessage"/>
+ 		<variable name="testType1" element="types:aTestMessage"/>
+ 		<variable name="testType2" element="types:aTestMessage"/>
+ 		<variable name="testType3" type="xsd:string"/>
+ 		<variable name="testType4" type="xsd:string"/>
+ 		<variable name="reply" messageType="wns:replyMessage"/>
+ 	</variables>
+ 	<sequence>
+ 		<receive name="receive1" partnerLink="request" portType="wns:TestSubTreeAssignPT" operation="request" variable="request" createInstance="yes"/>
+ 
+ 		<assign name="assign1">
+ 			<!-- copy a tree to a tree -->
+ 			<copy>
+ 				<from>$request.requestMessageData/typeIndicators/types:indicatorTwo</from>
+ 				<to variable="testType3"/>
+ 			</copy>
+ 			<copy>
+ 				<from variable="request" property="wns:testPath"/>
+ 				<to variable="testType4"/>
+ 			</copy>
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType1"/>
+ 			</copy>
+ 			<copy>
+ 				<from variable="testType1"/>
+ 				<to variable="testType2"/>
+ 			</copy>
+ 			<!-- copy value into tree -->
+ 			<copy>
+ 				<from>
+ 					<literal><![CDATA[pass]]></literal>
+ 				</from>
+ 				<to>$testType1/typeIndicators/types:indicatorTwo</to>
+ 			</copy>		
+ 		</assign>
+ 	
+ 		<assign name="assign2">
+ 			<!-- copy subtree to tree -->
+ 			<copy>
+ 				<from>$testType1/typeIndicators</from>
+ 				<to>$testType2/typeIndicators</to>
+ 			</copy>
+ 		</assign>
+ 		
+ 		<assign name="assign3">			
+ 			<copy>
+ 				<from>$testType2/requestID</from>
+ 				<to variable="reply" part="replyID"/>
+ 			</copy>
+ 			<copy>
+ 				<from>$testType2/typeIndicators/types:indicatorTwo</from>
+ 				<to>$reply.replyText</to>
+ 			</copy>
+ 		</assign>
+ 
+ 		<!-- test update functions -->
+ 		<!-- delete and insert as last into -->
+ 		<assign name="assign4">			
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType1"/>
+ 			</copy>
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType2"/>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:delete($testType1/typeIndicators, $testType1/typeIndicators/types:indicatorTwo)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:insert-as-last-into($testType1/typeIndicators, $testType2/typeIndicators/types:indicatorTwo)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 		</assign>
+ 		
+ 		<if>
+ 		    <condition>fn:not(fn:deep-equal($testType1, $testType2))</condition>
+ 			<throw faultName="selectionFailure"/>
+ 		</if>
+ 		
+ 		<!-- delete and insert as first into -->
+ 		<assign name="assign5">			
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType1"/>
+ 			</copy>
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType2"/>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:delete($testType1/typeIndicators/types:indicatorOne)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:insert-as-first-into($testType1/typeIndicators, $testType2/typeIndicators/types:indicatorOne)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 		</assign>
+ 		
+ 		<if>
+ 		    <condition>fn:not(fn:deep-equal($testType1, $testType2))</condition>
+ 			<throw faultName="selectionFailure"/>
+ 		</if>
+ 		
+ 		<!-- delete and insert before -->
+ 		<assign name="assign6">			
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType1"/>
+ 			</copy>
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType2"/>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:delete($testType1/typeIndicators/types:indicatorOne)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:insert-before($testType1/typeIndicators, $testType1/typeIndicators/types:indicatorTwo, $testType2/typeIndicators/types:indicatorOne)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 		</assign>
+ 		
+ 		<if>
+ 		    <condition>fn:not(fn:deep-equal($testType1, $testType2))</condition>
+ 			<throw faultName="selectionFailure"/>
+ 		</if>
+ 		
+ 		<!-- delete and insert after -->
+ 		<assign name="assign7">			
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType1"/>
+ 			</copy>
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType2"/>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:delete($testType1/typeIndicators/types:indicatorTwo)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:insert-after($testType1/typeIndicators/types:indicatorOne, $testType2/typeIndicators/types:indicatorTwo)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 		</assign>
+ 		
+ 		<if>
+ 		    <condition>fn:not(fn:deep-equal($testType1, $testType2))</condition>
+ 			<throw faultName="selectionFailure"/>
+ 		</if>
+ 		
+ 		<!-- rename twice -->
+ 		<assign name="assign7">			
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType1"/>
+ 			</copy>
+ 			<copy>
+ 				<from variable="request" part="requestMessageData"/>
+ 				<to variable="testType2"/>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:rename($testType1/typeIndicators/types:indicatorTwo, "foo:indicatorOne")</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:rename($testType1/typeIndicators/types:indicatorOne[2], "foo:indicatorTwo")</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:rename($testType1/typeIndicators/types:indicatorTwo, QName("http://ode/bpel/unit-test/TestSubTreeAssign.wsdl.types", "foo:indicatorOne"))</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 			<copy>
+ 				<from>ode:rename($testType1/typeIndicators/types:indicatorOne[2], $testType2/typeIndicators/types:indicatorTwo)</from>
+ 				<to>$testType1/typeIndicators</to>
+ 			</copy>
+ 		</assign>
+ 		
+ 		<if>
+ 		    <condition>fn:not(fn:deep-equal($testType1, $testType2))</condition>
+ 			<throw faultName="selectionFailure"/>
+ 		</if>
+ 		
+ 		<reply name="reply" partnerLink="request" portType="wns:TestSubTreeAssignPT" operation="request" variable="reply"/>
+ 	</sequence>
+ </process>

Modified: ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.wsdl
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.wsdl?rev=691733&r1=691732&r2=691733&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.wsdl (original)
+++ ode/branches/APACHE_ODE_1.X/bpel-test/src/test/resources/bpel/2.0/TestSubTreeAssign/TestSubTreeAssign.wsdl Wed Sep  3 12:01:42 2008
@@ -35,19 +35,21 @@
                 xmlns:xsd="http://www.w3.org/2001/XMLSchema">
       
       <xsd:element name="aTestMessage" type="testMessage"></xsd:element>
+	  <xsd:element name="indicator" type="xsd:string" abstract="true"/>
+	  <xsd:element name="indicatorOne" type="xsd:string" substitutionGroup="indicator"/>
+	  <xsd:element name="indicatorTwo" type="xsd:string" substitutionGroup="indicator"/>
       
       <xsd:complexType name="typeIndicator">
-	  <xsd:sequence>
-	    <xsd:element name="indicatorOne" type="xsd:string"/>
-	    <xsd:element name="indicatorTwo" type="xsd:string"/>
+	    <xsd:sequence>
+	         <xsd:element ref="indicatorOne"/>
+	         <xsd:element ref="indicatorTwo"/>
         </xsd:sequence>
-	</xsd:complexType>
-  
+	  </xsd:complexType>
       <xsd:complexType name="testMessage">
         <xsd:sequence>
-          <xsd:element name="requestID" type="xsd:string"/>
-          <xsd:element name="requestText" type="xsd:string"/>
-          <xsd:element name="typeIndicators" type="typeIndicator"/>
+             <xsd:element name="requestID" type="xsd:string"/>
+             <xsd:element name="requestText" type="xsd:string"/>
+             <xsd:element name="typeIndicators" type="typeIndicator"/>
         </xsd:sequence>
       </xsd:complexType>
 

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=691733&r1=691732&r2=691733&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 Wed Sep  3 12:01:42 2008
@@ -49,6 +49,7 @@
     public static final String WSDL_11 = "http://schemas.xmlsoap.org/wsdl/";
     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 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");



Mime
View raw message