You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by va...@apache.org on 2015/06/11 12:24:52 UTC

[1/2] ode git commit: fixes ODE-991. Thanks to Ciaran Jessup for the patch.

Repository: ode
Updated Branches:
  refs/heads/master e9a4f89d5 -> 768cb6dce
  refs/heads/ode-1.3.x 2eb6ba8cf -> 37c6cecfa


fixes ODE-991. Thanks to Ciaran Jessup for the patch.


Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/37c6cecf
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/37c6cecf
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/37c6cecf

Branch: refs/heads/ode-1.3.x
Commit: 37c6cecfad04672374957465c4ef379107ffe427
Parents: 2eb6ba8
Author: Tammo van Lessen <tv...@gmail.com>
Authored: Thu Jun 11 12:18:09 2015 +0200
Committer: Tammo van Lessen <tv...@gmail.com>
Committed: Thu Jun 11 12:18:09 2015 +0200

----------------------------------------------------------------------
 .../xpath20/runtime/JaxpFunctionResolver.java   | 22 +++++++++++++++++++-
 .../runtime/XPath20ExpressionRuntimeTest.java   | 12 +++++++++++
 .../src/test/resources/xpath20/variables.xml    | 10 +++++++++
 3 files changed, 43 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/37c6cecf/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
----------------------------------------------------------------------
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
index 4f5aab3..9016eab 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
@@ -35,11 +35,13 @@ import javax.xml.xpath.XPathFunction;
 import javax.xml.xpath.XPathFunctionException;
 import javax.xml.xpath.XPathFunctionResolver;
 
+import net.sf.saxon.dom.DOMNodeList;
 import net.sf.saxon.dom.NodeWrapper;
 import net.sf.saxon.trans.XPathException;
 import net.sf.saxon.value.DayTimeDurationValue;
 import net.sf.saxon.value.IntegerValue;
 import net.sf.saxon.value.QNameValue;
+import net.sf.saxon.value.SequenceExtent;
 import net.sf.saxon.value.YearMonthDurationValue;
 
 import org.apache.commons.httpclient.URIException;
@@ -885,6 +887,15 @@ public class JaxpFunctionResolver implements XPathFunctionResolver {
                     targetNodes.add((Element) ((NodeWrapper) delete).getUnderlyingNode());
                 } else if (delete instanceof Element) {
                     targetNodes.add((Element) delete);
+                } else if (delete instanceof SequenceExtent) {
+                    try {
+                        DOMNodeList nodeList= DOMNodeList.checkAndMake((SequenceExtent)delete);
+                        for (int i=0;i<nodeList.getLength();i++){
+                            targetNodes.add(nodeList.item(i));
+                        }
+                    } catch (XPathException e) {
+                        throw new XPathFunctionException(e);
+                    }
                 } else {
                     throw new XPathFunctionException("Unexpected argument type: " + delete.getClass());
                 }
@@ -918,12 +929,21 @@ public class JaxpFunctionResolver implements XPathFunctionResolver {
 		            }
 	            }
             }
+            // 2xLoops as previously the contents of the 'children' list appeared to
+            // be being changed by the clonedElmt.removeChild call, meaning the position
+            // offset was incorrect, a possibly better approach would be to sort the position
+            // indices and iterate *backwards* but for my needs this approach suffices.
+            List<Node> clonedChildrenToRemove = new ArrayList<Node>();
             final 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);
+	            clonedChildrenToRemove.add(deleteElmt);
+            }
+            for (Node deleteElmt : clonedChildrenToRemove) {
+                clonedElmt.removeChild(deleteElmt);
             }
+
             // Saxon doesn't like clones with no children, so I'll oblige
             if (clonedElmt.getChildNodes().getLength() == 0) {
             	try {

http://git-wip-us.apache.org/repos/asf/ode/blob/37c6cecf/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java
----------------------------------------------------------------------
diff --git a/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java b/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java
index a6482ef..e20a98e 100644
--- a/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java
+++ b/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java
@@ -19,6 +19,7 @@
 package org.apache.ode.bpel.elang.xpath20.runtime;
 
 import junit.framework.TestCase;
+
 import org.apache.ode.bpel.common.FaultException;
 import org.apache.ode.bpel.compiler.bom.Expression;
 import org.apache.ode.bpel.elang.xpath20.compiler.XPath20ExpressionCompilerBPEL20;
@@ -30,6 +31,7 @@ import org.apache.ode.bpel.o.OMessageVarType.Part;
 import org.apache.ode.bpel.o.OProcess.OProperty;
 import org.apache.ode.bpel.o.OScope.Variable;
 import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.Namespaces;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -109,6 +111,14 @@ public class XPath20ExpressionRuntimeTest extends TestCase implements Evaluation
         assertNull(DOMUtils.getFirstChildElement((Element)retVal));
     }
 
+    public void testODE911() throws Exception {
+        OXPath20ExpressionBPEL20 exp = compile("ode:delete($ODE991var/tns:empty)");
+        Element retVal = (Element)_runtime.evaluateNode(exp, this);
+        assertNotNull(retVal);
+        assertEquals(3, retVal.getElementsByTagNameNS("http://foobar", "notempty").getLength());
+        assertEquals(0, retVal.getElementsByTagNameNS("http://foobar", "empty").getLength());
+    }
+
     public Node readVariable(Variable variable, Part part) throws FaultException {
         return _vars.get(variable.name);
     }
@@ -153,6 +163,8 @@ public class XPath20ExpressionRuntimeTest extends TestCase implements Evaluation
         doc.appendChild(e);
         e.appendChild(doc.createTextNode(xpath));
         Expression exp = new Expression(e);
+        exp.getNamespaceContext().register("tns", "http://foobar");
+        exp.getNamespaceContext().register("ode", Namespaces.ODE_EXTENSION_NS);
         return (OXPath20ExpressionBPEL20)_compiler.compileLValue(exp);
     }
     

http://git-wip-us.apache.org/repos/asf/ode/blob/37c6cecf/bpel-runtime/src/test/resources/xpath20/variables.xml
----------------------------------------------------------------------
diff --git a/bpel-runtime/src/test/resources/xpath20/variables.xml b/bpel-runtime/src/test/resources/xpath20/variables.xml
index 7588891..61ac09d 100644
--- a/bpel-runtime/src/test/resources/xpath20/variables.xml
+++ b/bpel-runtime/src/test/resources/xpath20/variables.xml
@@ -62,4 +62,14 @@
                          </tns:ApplicationData>
 
 	</elementVar>
+	<elementVar name="ODE991var"  xmlns:tns="http://foobar" >
+					<tns:ApplicationData>
+						<tns:empty/>
+						<tns:notempty/>
+						<tns:empty/>
+						<tns:notempty/>
+						<tns:empty/>
+						<tns:notempty/>
+                    </tns:ApplicationData>
+	</elementVar>
 </variables>
\ No newline at end of file


[2/2] ode git commit: fixes ODE-991. Thanks to Ciaran Jessup for the patch.

Posted by va...@apache.org.
fixes ODE-991. Thanks to Ciaran Jessup for the patch.


Project: http://git-wip-us.apache.org/repos/asf/ode/repo
Commit: http://git-wip-us.apache.org/repos/asf/ode/commit/768cb6dc
Tree: http://git-wip-us.apache.org/repos/asf/ode/tree/768cb6dc
Diff: http://git-wip-us.apache.org/repos/asf/ode/diff/768cb6dc

Branch: refs/heads/master
Commit: 768cb6dcee7f97a2d606ea7ae60f35a79e03238d
Parents: e9a4f89
Author: Tammo van Lessen <tv...@gmail.com>
Authored: Thu Jun 11 12:18:09 2015 +0200
Committer: Tammo van Lessen <tv...@gmail.com>
Committed: Thu Jun 11 12:24:33 2015 +0200

----------------------------------------------------------------------
 .../xpath20/runtime/JaxpFunctionResolver.java   | 22 +++++++++++++++++++-
 .../runtime/XPath20ExpressionRuntimeTest.java   | 13 +++++++++++-
 .../src/test/resources/xpath20/variables.xml    | 10 +++++++++
 3 files changed, 43 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/768cb6dc/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
----------------------------------------------------------------------
diff --git a/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java b/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
index aa29367..3bceb21 100644
--- a/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
+++ b/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java
@@ -35,11 +35,13 @@ import javax.xml.xpath.XPathFunction;
 import javax.xml.xpath.XPathFunctionException;
 import javax.xml.xpath.XPathFunctionResolver;
 
+import net.sf.saxon.dom.DOMNodeList;
 import net.sf.saxon.dom.NodeWrapper;
 import net.sf.saxon.trans.XPathException;
 import net.sf.saxon.value.DayTimeDurationValue;
 import net.sf.saxon.value.IntegerValue;
 import net.sf.saxon.value.QNameValue;
+import net.sf.saxon.value.SequenceExtent;
 import net.sf.saxon.value.YearMonthDurationValue;
 
 import org.apache.commons.httpclient.URIException;
@@ -885,6 +887,15 @@ public class JaxpFunctionResolver implements XPathFunctionResolver {
                     targetNodes.add((Element) ((NodeWrapper) delete).getUnderlyingNode());
                 } else if (delete instanceof Element) {
                     targetNodes.add((Element) delete);
+                } else if (delete instanceof SequenceExtent) {
+                    try {
+                        DOMNodeList nodeList= DOMNodeList.checkAndMake((SequenceExtent)delete);
+                        for (int i=0;i<nodeList.getLength();i++){
+                            targetNodes.add(nodeList.item(i));
+                        }
+                    } catch (XPathException e) {
+                        throw new XPathFunctionException(e);
+                    }
                 } else {
                     throw new XPathFunctionException("Unexpected argument type: " + delete.getClass());
                 }
@@ -918,12 +929,21 @@ public class JaxpFunctionResolver implements XPathFunctionResolver {
                     }
                 }
             }
+            // 2xLoops as previously the contents of the 'children' list appeared to
+            // be being changed by the clonedElmt.removeChild call, meaning the position
+            // offset was incorrect, a possibly better approach would be to sort the position
+            // indices and iterate *backwards* but for my needs this approach suffices.
+            List<Node> clonedChildrenToRemove = new ArrayList<Node>();
             final Element clonedElmt = (Element) parentElmt.cloneNode(true);
             children = clonedElmt.getChildNodes();
             for (int target = 0; target < positions.length; target++) {
-                Element deleteElmt = (Element) children.item(positions[target]);
+	            Element deleteElmt = (Element) children.item(positions[target]);
+	            clonedChildrenToRemove.add(deleteElmt);
+            }
+            for (Node deleteElmt : clonedChildrenToRemove) {
                 clonedElmt.removeChild(deleteElmt);
             }
+
             // Saxon doesn't like clones with no children, so I'll oblige
             if (clonedElmt.getChildNodes().getLength() == 0) {
                 try {

http://git-wip-us.apache.org/repos/asf/ode/blob/768cb6dc/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java
----------------------------------------------------------------------
diff --git a/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java b/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java
index 3968b05..137a848 100644
--- a/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java
+++ b/bpel-runtime/src/test/java/org/apache/ode/bpel/elang/xpath20/runtime/XPath20ExpressionRuntimeTest.java
@@ -18,11 +18,11 @@
  */
 package org.apache.ode.bpel.elang.xpath20.runtime;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import java.net.URI;
@@ -44,6 +44,7 @@ import org.apache.ode.bpel.o.OMessageVarType.Part;
 import org.apache.ode.bpel.o.OProcess.OProperty;
 import org.apache.ode.bpel.o.OScope.Variable;
 import org.apache.ode.utils.DOMUtils;
+import org.apache.ode.utils.Namespaces;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -230,6 +231,14 @@ public class XPath20ExpressionRuntimeTest implements EvaluationContext {
         	fail("Missing '"+insertElementName+"' element has not been inserted");
         }
     }
+    
+    public void testODE911() throws Exception {
+        OXPath20ExpressionBPEL20 exp = compile("ode:delete($ODE991var/tns:empty)");
+        Element retVal = (Element)_runtime.evaluateNode(exp, this);
+        assertNotNull(retVal);
+        assertEquals(3, retVal.getElementsByTagNameNS("http://foobar", "notempty").getLength());
+        assertEquals(0, retVal.getElementsByTagNameNS("http://foobar", "empty").getLength());
+    }
 
     public Node readVariable(Variable variable, Part part) throws FaultException {
         return _vars.get(variable.name);
@@ -274,6 +283,8 @@ public class XPath20ExpressionRuntimeTest implements EvaluationContext {
         doc.appendChild(e);
         e.appendChild(doc.createTextNode(xpath));
         Expression exp = new Expression(e);
+        exp.getNamespaceContext().register("tns", "http://foobar");
+        exp.getNamespaceContext().register("ode", Namespaces.ODE_EXTENSION_NS);
         return (OXPath20ExpressionBPEL20)_compiler.compileLValue(exp);
     }
 

http://git-wip-us.apache.org/repos/asf/ode/blob/768cb6dc/bpel-runtime/src/test/resources/xpath20/variables.xml
----------------------------------------------------------------------
diff --git a/bpel-runtime/src/test/resources/xpath20/variables.xml b/bpel-runtime/src/test/resources/xpath20/variables.xml
index 919cbc3..38c5996 100644
--- a/bpel-runtime/src/test/resources/xpath20/variables.xml
+++ b/bpel-runtime/src/test/resources/xpath20/variables.xml
@@ -71,4 +71,14 @@
 		</tns:ExampleMessage>
 	</messageTypeVar>
 
+	<elementVar name="ODE991var"  xmlns:tns="http://foobar" >
+					<tns:ApplicationData>
+						<tns:empty/>
+						<tns:notempty/>
+						<tns:empty/>
+						<tns:notempty/>
+						<tns:empty/>
+						<tns:notempty/>
+                    </tns:ApplicationData>
+	</elementVar>
 </variables>
\ No newline at end of file