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 2008/05/29 02:14:47 UTC

svn commit: r661165 - in /ode/branches/APACHE_ODE_1.1: bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/ bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/

Author: mriou
Date: Wed May 28 17:14:47 2008
New Revision: 661165

URL: http://svn.apache.org/viewvc?rev=661165&view=rev
Log:
ODE-297 Custom function to convert an XML document in the BPEL to a literal string value

Modified:
    ode/branches/APACHE_ODE_1.1/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java
    ode/branches/APACHE_ODE_1.1/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java
    ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java

Modified: ode/branches/APACHE_ODE_1.1/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.1/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java?rev=661165&r1=661164&r2=661165&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java (original)
+++ ode/branches/APACHE_ODE_1.1/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/Constants.java Wed May 28 17:14:47 2008
@@ -53,6 +53,7 @@
     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 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.1/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.1/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java?rev=661165&r1=661164&r2=661165&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java (original)
+++ ode/branches/APACHE_ODE_1.1/bpel-compiler/src/main/java/org/apache/ode/bpel/elang/xpath20/compiler/JaxpFunctionResolver.java Wed May 28 17:14:47 2008
@@ -80,6 +80,8 @@
             } else if (Constants.NON_STDRD_FUNCTION_COMPOSE_URL.equals(localName)
                     || Constants.NON_STDRD_FUNCTION_EXPAND_TEMPLATE.equals(localName)) {
                 return new ComposeUrl();
+            } else if ( Constants.NON_STDRD_FUNCTION_DOM_TO_STRING.equals(localName)) {
+            	return new DomToString();
             }
         }
 
@@ -155,6 +157,15 @@
             }
             return "";
         }
+    }    
+
+    public static class DomToString implements XPathFunction {
+        public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() != 1) {
+                throw new CompilationException(__msgs.errInvalidNumberOfArguments(Constants.NON_STDRD_FUNCTION_DOM_TO_STRING));
+            }
+            return "";
+        }
     }
 
     public static class ComposeUrl implements XPathFunction {

Modified: ode/branches/APACHE_ODE_1.1/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.1/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java?rev=661165&r1=661164&r2=661165&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java (original)
+++ ode/branches/APACHE_ODE_1.1/bpel-runtime/src/main/java/org/apache/ode/bpel/elang/xpath20/runtime/JaxpFunctionResolver.java Wed May 28 17:14:47 2008
@@ -103,6 +103,8 @@
                 return new ComposeUrl();
             } else if (Constants.NON_STDRD_FUNCTION_EXPAND_TEMPLATE.equals(localName)) {
                 return new ComposeUrl(true, "expandTemplateInvalidSource");
+            } else if ( Constants.NON_STDRD_FUNCTION_DOM_TO_STRING.equals(localName)) {
+            	return new DomToString();
             }
         }
 
@@ -298,6 +300,40 @@
             }
         }
     }
+    
+    public class DomToString implements XPathFunction {
+    	public Object evaluate(List args) throws XPathFunctionException {
+            if (args.size() != 1)
+                throw new XPathFunctionException(new FaultException(new QName(Namespaces.ODE_EXTENSION_NS, "domToStringInvalidSource"), "Invalid arguments"));
+
+            if (__log.isDebugEnabled()) {
+                __log.debug("domToString call(context=" + _ectx + " args=" + args + ")");
+            }
+            
+            Element varElmt;
+            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.qnXsltInvalidSource,
+                                    "The bpws:domToString function MUST be passed a single " +
+                                            "element node."));
+                    varElmt = (Element) elmts.get(0);
+                } else {
+                    if (args.get(1) instanceof NodeWrapper)
+                        varElmt = (Element) ((NodeWrapper) args.get(1)).getUnderlyingNode();
+                    else varElmt = (Element) args.get(1);
+                }
+            } catch (ClassCastException e) {
+                throw new XPathFunctionException(
+                        new FaultException(_oxpath.getOwner().constants.qnXsltInvalidSource,
+                                "The bpws:domToString function MUST be passed a single " +
+                                        "element node."));
+            }    
+            String result= DOMUtils.domToString(varElmt); 
+            return result;
+    	}
+    }
 
     /**
      * Compile time checking for the non standard ode:splitToElements function.