You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mr...@apache.org on 2006/10/02 19:03:28 UTC
svn commit: r452121 -
/incubator/ode/trunk/bpel-el-xpath20/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpVariableResolver.java
Author: mriou
Date: Mon Oct 2 10:03:28 2006
New Revision: 452121
URL: http://svn.apache.org/viewvc?view=rev&rev=452121
Log:
[ODE-51] This is a tricky one. The replaceContent / replaceElement semantic of assign presupposes that we can have a proper lvalue pointer on the lvalue node tree. However when we're doing XPath evaluation, we're also expected to return simple types when require (to allow simple computations like '1+1=2'). Ideally we should always return the right java mapped simple type when selecting an rvalue and always a nodeset when selecting an lvalue. However resolvers have no idea what we're selecting for.
This fix will make things work for all cases when the lvalue isn't computable (not an integer or a float for example), which is the most common (it's rare to have a number selected as an lvalue). However there's always edge cases.
Modified:
incubator/ode/trunk/bpel-el-xpath20/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpVariableResolver.java
Modified: incubator/ode/trunk/bpel-el-xpath20/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpVariableResolver.java
URL: http://svn.apache.org/viewvc/incubator/ode/trunk/bpel-el-xpath20/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpVariableResolver.java?view=diff&rev=452121&r1=452120&r2=452121
==============================================================================
--- incubator/ode/trunk/bpel-el-xpath20/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpVariableResolver.java (original)
+++ incubator/ode/trunk/bpel-el-xpath20/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpVariableResolver.java Mon Oct 2 10:03:28 2006
@@ -95,9 +95,9 @@
if (variableNode == null)
throw new FaultException(variable.getOwner().constants.qnSelectionFailure, "Unknown variable " + variableName.getLocalPart());
if (variable.type instanceof OXsdTypeVarType && ((OXsdTypeVarType)variable.type).simple)
- return getSimpleContent(variableNode.getTextContent(),((OXsdTypeVarType)variable.type).xsdType);
+ return getSimpleContent(variableNode,((OXsdTypeVarType)variable.type).xsdType);
if (part.type instanceof OXsdTypeVarType && ((OXsdTypeVarType)part.type).simple)
- return getSimpleContent(variableNode.getTextContent(),((OXsdTypeVarType)part.type).xsdType);
+ return getSimpleContent(variableNode,((OXsdTypeVarType)part.type).xsdType);
// Saxon expects a nodelist, everything else will result in a wrong result...
//Document doc = DOMUtils.newDocument();
@@ -112,8 +112,9 @@
}
}
- private Object getSimpleContent(String text, QName type) {
- try {
+ private Object getSimpleContent(Node simpleNode, QName type) {
+ String text = simpleNode.getTextContent();
+ try {
return XSTypes.toJavaObject(type,text);
} catch (Exception e) { }
// Elegant way failed, trying brute force
@@ -123,7 +124,8 @@
try {
return Double.valueOf(text);
} catch (NumberFormatException e) { }
- return text;
+ // Remember: always a node set
+ return simpleNode.getParentNode().getChildNodes();
}
}